我想,以产生对XSLT是如何构建一个文档与一般XSLT来显示我的XSLT。 我得到了一些帮助,在这里计算器,但仍有一些细节,我想我能够做到的自己,但unfortunatley没有。
上一篇: 生成XSL文件
这是我想它的工作:
我的XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<head>
<title>My sample</title>
</head>
<body>
My sample element: <xsl:value-of select="root/element1"/>
</body>
</xsl:template>
</xsl:stylesheet>
请求的输出:
<html>
<head>
<title>My sample</title>
</head>
<body>
My sample element: root/element1
</body>
</html>
如果可能的话,标识也喜欢显示,每个循环和if语句。 有没有人这样做,可能与我分享索姆代码?
我也做了一些改变,我认为它可以帮助你,PLZ检查代码并在您输入XSLT运行它:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="text"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:value-of select="concat('<', name())" />
<xsl:apply-templates select="@*" />
<xsl:value-of select="'>'" />
<xsl:apply-templates/>
<xsl:value-of select="concat('</', name(), '>')" />
</xsl:template>
<xsl:template match="@*">
<xsl:value-of select="concat(' ', name(), '="', ., '"')" />
</xsl:template>
<xsl:template match="xsl:*">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xsl:value-of">
<xsl:value-of select="@select" />
</xsl:template>
<!-- add appropriate templates for the other XSLT elements -->
</xsl:stylesheet>