Re: [xsl] Document() Problem:

Subject: Re: [xsl] Document() Problem:
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 21 Jun 2001 23:39:07 +0100

] <xsl:variable name="xml" select="document('names.xml')//root"/>
the // there makes the processor search the entire document for all
elements called root, and return all of them. You know there's only one,
at the top, but it doesn't:

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

would be quicker.
(by the way it's really confusing to call the document element "root"
as it confuses the issue with the document root (/) which is something
else entirely)

} <xsl:value-of select="$xml/name/."/>

<xsl:value-of select="$xml/name"/>

would select all  the name elements, which is what I think you want.
but then as you use value-of it will take th estring value of the node
set which is the string value of the first node in the set in document
order, ie just the first name.

Perhaps you want

<xsl:value-of select="$xml"/>
the string value of the (single element node, root) is the concatenation
of the values of its children, ie all th enames.

or more likely you want
<xsl:apply-templates select="$xml/name"/>
or for-each, to do something with th enames individually.

> I get null + the number of elements/attributes.
This doesn't make sense, null isn't an XSL value, what do you get?


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:

Current Thread