因此,這可能是一個奇怪的請求,但我會放棄它。我有一個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