开发者

XSLT 1.1 nodeset

开发者 https://www.devze.com 2023-01-04 04:20 出处:网络
I have this... <xsl:stylesheet version=\"1.1\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:exslt=\"http://exslt.org/common\">

I have this...

<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>

And I thought that with XSLT 1.1 that the $data variable would be treated as a node-set and that therefore standard XSLT stuff - like for-each - should work.

I don't get an error, but I get no output - it's as though the $data nodeset is completely empty.

I've also tried this

<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:t开发者_运维问答emplate match="/">
         <xsl:for-each select="exslt:node-set($data)/root/test">
            <xsl:for-each select="."/>
         </xsl:for-each>
       </xsl:template>

</xsl:stylesheet>

With the same results. (Infact, I've done this before with no problems) I'm using Saxon.

What am I missing? (I'm not in a position to use XSLT 2.0 by the way)

Thanks


You wrote:

I don't get an error, but I get no output

The problem is here:

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

Your question:

What am I missing?

Answer: You are missing your template.


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

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

The error is in the following (empty) instruction:

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

This (probably) has to be:

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

or

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

or ... ?

0

精彩评论

暂无评论...
验证码 换一张
取 消