因此,这可能是一个奇怪的请求,但我会放弃它。我有一个XML文档用于生成XML中指定的html标记的XSLT
<?xml version="1.0" encoding="utf-8" ?>
<Page>
<ID>Site</ID>
<Object>
<ID>PostCode</ID>
<Type>div</Type>
<Class>display-label</Class>
<Value>PostCode</Value>
</Object>
<Object>
<ID>PostCodeValue</ID>
<Type>div</Type>
<Class>display-field</Class>
<Value>$PostCode</Value>
</Object>
</Page>
和我使用这个XSL将其改造成一个HTML页面
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head>
</head>
<body>
<xsl:for-each select="Page/Object">
<<xsl:value-of select="Type"/>>
<xsl:value-of select="Value"/>
</<xsl:value-of select="Type"/>>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
正如你可以看到我想要生成正确的HTML标签取决于类型节点在xml中。问题是“<”在xsl中不被接受并且编码会阻止它被识别为标记。
任何建议我会怎么做呢?
预先感谢
+1尼斯。在http://www.w3schools.com/xsl/ – Johan 2010-01-18 13:35:49
进行测试时,它的工作原理我将如何使用类值填充此元素 – 2010-01-18 15:29:11
您是否需要为'div'添加类属性?您可以使用''(例如' foo xsl:attribute > xsl:attribute> xsl:element>') –
2010-01-18 16:13:50