【发布时间】:2012-09-30 03:50:48
【问题描述】:
我目前正在做 XML 和 XSLT,我有一个问题
我已经完成了所有工作并且验证良好,但没有给我正确的答案。一种运行良好的解决方案是使用 CDATA,但我想使用 xmlns="http://www.w3.org/xhtml。
这是我的相关代码
XML 架构
<xs:element name="bb">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml"
minOccurs="0"
maxOccurs="unbounded"
processContents="skip"/>
</xs:sequence>
</xs:complexType>
</xs:element>
XSLT
<xsl:template match="xsi:bb">
<div style="font-family:calibri;font-size:16">
<span style="color:#000">
Babo is:
</span>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
XML
<bb>
<li xmlns="http://www.w3.org/1999/xhtml">
hoby
</li>
<li xmlns="http://www.w3.org/1999/xhtml">
the best
</li>
</bb>
根据我的理论,它应该返回(当我将 XML 转换为 HTML 时)
但它只是回报最好的爱好。
为什么?
【问题讨论】:
-
您的 XML 无效。没有打开
<p>也没有关闭</li>。此外,在您的 XSLT 中,您希望<xsl:template match="xsi:description">在您的输入 XML 中匹配什么? -
抱歉错误的例子已经修复了。即使 XMl 有效仍然返回错误!