This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Variable with node list...


Hello Brad!

> I get the following error from Microsoft's parser when processing the
> included document and stylesheet.
That parser is probably right :) <xsl:for-each> needs node-set to iterate through, whereas you give it result tree fragment instead.
> 
>   Reference to variable or parameter 'properties' must evaluate to a node
> list.
> 
> Has anyone else run across this? (MSXML3, IE6, Windows 2000 Server)
Yeah, it seems to me all of us have to try to do it once in the life.

>     <xsl:variable name="properties">
>       <property>one</property>
>       <property>two</property>
>       <property>three</property>
>     </xsl:variable>
This variable actually holds result tree fragment, not node-set, see http://www.w3.org/TR/xslt#section-Result-Tree-Fragments.

I know 2 ways to resort:
1. use msxsl:node-set(rtf) extension function (see more in msxml doc) to convert result tree fragment to node-set.
2. Redesign you stylesheet this way:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:user="http://user.com/ns";>
  <user:properties>
    <property>one</property>
    <property>two</property>
    <property>three</property>
  </user:properties>
  <xsl:template match="root">
    <foo>
      <xsl:for-each select="document('')/*/user:properties/property">
        <bar>
          <xsl:value-of select="."/>
        </bar>
      </xsl:for-each>
    </foo>
  </xsl:template>
</xsl:stylesheet>

---
Oleg Tkachenko,
Multiconn International, Israel 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]