xsl-list
[Top] [All Lists]

Re: RE:

2003-07-29 13:16:02
Guys,

At 06:10 AM 7/29/2003, Simon wrote:
> <xsl:variable name="myxml" select="document('somefile.xml')"/>
>
> you would then perform transformations on it by refering to the variable
>
> e.g.
> <xsl:value select="$myxml//test"/>
>
> would output the value of a <test/> element.

I thought this thing was not working with XSL 1.0 since the variable would
only contain text, and not a node-set.

Even in XSLT 1.0, the $myxml variable declared as above would be bound to a node set. All is fine; no extension element is necessary.

This is the difference between

<xsl:variable name="myxml" select="document('somefile.xml')"/>

and

<xsl:variable name="myxml">
  <xsl:copy-of select="document('somefile.xml')"/>
</xsl:variable>

The second variable is bound to a result tree fragment (a *copy* of the original node set).

> btw you will have to understand about RTF and using the common node-set
extension function if you want to get any further doing stuff with this.
>

Could you please elaborate a little bit more on that point. Just reading the
EXSLT doc was not enough for me to understand the use of the new node-set
function.

The function allows you to turn any RTF, such as the copy just described, into an honest-to-goodness node set. So it won't make any difference how it's declared. It'll also let you do things like

<xsl:variable name="myRTF">
  <xsl:apply-templates select="document('somefile.xml')"/>
</xsl:variable>

<xsl:variable name="myNodeSet" select="exslt:node-set($myRTF)"/>

and then process the nodes in the variable as if they were a source document (even though they are themselves the result of a transform).

This allows chaining or "pipelining" of transforms within a single stylesheet process. Powerful, if sometimes a bit tricky to debug....

Shouldn't this thread have a subject line?

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



<Prev in Thread] Current Thread [Next in Thread>
  • RE:, Jim Fuller
    • Re: RE:, Simon Bretin
      • Re: RE:, Wendell Piez <=