This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: after use of document(): selecting parts of the obtained node-set
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 11 Apr 2002 18:15:51 -0400
- Subject: Re: [xsl] after use of document(): selecting parts of the obtained node-set
- Reply-to: xsl-list at lists dot mulberrytech dot com
Ralph,
You're almost there; you only have to fix a couple of little errors:
At 06:04 PM 4/11/2002, you wrote:
>I use the document function to load a document from within a stylesheet,
>and store the resulting nodeset in a variable:
>
><xsl:variable name="itn" select="document(itn.xml)" />
This should be select="document('itn.xml')". As it stands it is taking the
value of the <itn.xml> element child of the context node as its argument.
Since you have none, it comes back empty.
>Now I'd like to access certain parts of this nodeset, like this:
>
><xsl:template>
>
>...
>
> <xsl:apply-templates select="$itn/logo" />
>
>...
>
></xsl:template>
The select="$itn/logo" looks good *except* your node set has a root node
above the <itn> element, so there is no such node (no <logo> child of the
root node). select="$itn/itn/logo" will work (or just set your variable to
document('itn.xml')/itn to begin with.
>and for the sub-nodeset $itn/logo I have the following template:
>
><xsl:template match="itn/logo">
> extract data
></xsl>
This will work fine.
>Unfortunately, whenever I try this combination, the result of my
><xsl:apply-templates select="$itn/logo"> is empty. The same is true when I
>do a select like <xsl:apply-templates select="$itn//logo">.
$itn//logo will work, though be less efficient than $itn/itn/log or
$itn/*/logo.
>Maybe I haven't understood the functionality of document() or how to
>access parts of a node set that is returned by document()? Can someone
>help me, please?
No, you get it, you just have some syntax buglets.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.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