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: document() loops


You either need an absolute path to univ-xml[2], or you need to store it in a
i tried doing the absolute path..
by using.
<second-xml>
<xsl:for-each select="document(/univ-xml-list/univ-xml[2])/university-records/univ-ids/univ">
<!-- TO ITERATE THROUGH THE 2nd XML -->
<xsl:value-of select="name"/>
</xsl:for-each>
</second-xml>

It still doesnt work


From: Peter Davis <pdavis152@attbi.com>
Reply-To: xsl-list@lists.mulberrytech.com
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] document() loops
Date: Fri, 13 Sep 2002 06:27:29 -0700

On Friday 13 September 2002 06:10, Laura Jenkins wrote:
> <xsl:for-each
> select="document(univ-xml[1])/university-records/univ-ids/univ">
> <xsl:element name= "univ{position()}">
> <xsl:value-of select="name"/>
> </xsl:element>
> <xsl:if test= "position() = last()">
> <second-xml>
> <xsl:for-each
> select="document(univ-xml[2])/university-records/univ-ids/univ">
^^^^^^^^

There is your problem: you have a relative XPath expression. The first
for-each evaluates its expression in the context of whatever node you
selected outside the for-each, presumably a univ-xml-list from your example.
The second for-each is evaluating its expression in the context of what was
selected from the first for-each, which is
"/university-records/univ-ids/univ". For this to work, the document loaded
by the first document() would have to look like this:

<university-records>
<univ-ids>
<univ>
<univ-xml>ignored</univ-xml>
<univ-xml>this is univ-xml[2]</univ-xml>
</>

I'm guessing that's not what you want. If it is, ignore me.

You either need an absolute path to univ-xml[2], or you need to store it in a
variable before the first for-each changes the context. For example:

<xsl:variable name="univ-xml-2" select="univ-xml[2]"/>
<xsl:for-each select="document(univ-xml[1])/...">
...
<xsl:for-each select="document($univ-xml-2)/...">
...
</>

HTH

--
Peter Davis

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



_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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]