如何制作XHTML?

时间:2016-08-01 23:35:13

标签: xslt xhtml

我有代码* xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xhtml" indent="yes" />
<xsl:variable name="with" select="'File2.xml'" />

<xsl:template match="/">
<html>
<body>
<h1>WEB Service</h1><br/>
</body>
</html>
</xsl:template>

<xsl:template match="@* | node()">

<xsl:copy>
  <xsl:apply-templates select="@* | node()" />
</xsl:copy>

</xsl:template>

<xsl:template match="data">
<xsl:copy>
  <xsl:apply-templates select="@* | node()" />
  <xsl:variable name="info" select="document($with)/Xml/data[ClassId=current()/ClassId]/." />
  <xsl:for-each select="$info/*">
    <xsl:if test="name()!='ClassId'">
      <xsl:copy-of select="." />
    </xsl:if>
  </xsl:for-each>
 </xsl:copy>
 </xsl:template>
 </xsl:transform>

即时尝试制作XHTML,当我运行时只显示html不包含xml片段..

任何人都可以帮助我吗?

感谢

1 个答案:

答案 0 :(得分:1)

  

当我运行时只显示html不包含xml片段..

原因是XSLT处理器首先应用匹配/根节点的模板。此模板不包含xsl:apply-templates条指令,因此处理在此处结束。