2

我有这个...

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common">

  <xsl:variable name="data">
    <root>
      <test>1000</test>
      <test>2000</test>
      <test>3000</test>
     </root>
   </xsl:variable>   

   <xsl:template match="/">
     <xsl:for-each select="$data/root/test">
        <xsl:for-each select="."/>
     </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

而且我认为对于 XSLT 1.1,$data 变量将被视为节点集,因此标准的 XSLT 东西——比如 for-each——应该可以工作。

我没有收到错误,但没有输出 - 好像 $data 节点集完全为空。

我也试过这个

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common">

      <xsl:variable name="data">
        <root>
          <test>1000</test>
          <test>2000</test>
          <test>3000</test>
         </root>
       </xsl:variable>   

       <xsl:template match="/">
         <xsl:for-each select="exslt:node-set($data)/root/test">
            <xsl:for-each select="."/>
         </xsl:for-each>
       </xsl:template>

</xsl:stylesheet>

结果相同。(事实上​​,我以前做过这个没有问题)我正在使用撒克逊人。

我错过了什么?(顺便说一句,我无法使用 XSLT 2.0)

谢谢

4

2 回答 2

1

你写了:

我没有收到错误,但没有输出

问题在这里:

<xsl:for-each select="."/> 

你的问题:

我错过了什么?

答:您缺少模板

于 2010-06-22T19:02:53.947 回答
0
<xsl:template match="/"> 
  <xsl:for-each select="exslt:node-set($data)/root/test">

     <xsl:for-each select="."/> 
  </xsl:for-each>     </xsl:template>

错误在以下(空)指令中

    <xsl:for-each select="."/> 

这(可能)必须是

<xsl:value-of select="."/>

或者

<xsl:copy-of select="."/>

或者 ... ?

于 2010-06-22T19:12:38.923 回答