[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: problem with handling conditional for loops

Subject: Re: problem with handling conditional for loops
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Wed, 27 Apr 2005 12:48:45 -0500
xsl remember values
Hi Rahil,


> Sorry trouble already. $nodeToProcess now correctly contains values
> found in either the <xsl:when> or <xsl:otherwise> statement.
>
> However how can I also add the value of the 'id' attribute to
> $nodeToProcess so that I can look for references to the result based on
> its id at a later stage ?
>
> E.g. <Value id="1234">Hello</Value>

I have a feeling you are having some problems with the difference
between selecting node-sets and result tree fragments...see
http://www.dpawson.co.uk/xsl/sect2/nodeset.html for more on that.

But a better answer is I think you might be better served by templates
in here.  Since I'm not sure of the complete structure of your code
I'll have to guess a little bit.

But we use the structure like we had before but instead of assigning a
variable for later processing we will pass it to a template that will
generate the appropriate result:

<xsl:choose>
<xsl:when
test="document(Second.xml)/SubConcepts/SubConcept[1]/Value[$clsName=text()]">

<xsl:call-template name="processNode">
<xsl:with-param name="nodeToProcess"
select="document(Second.xml)/SubConcepts/SubConcept[1]/Value[$clsName=text()]
"/>
<xsl:with-param name="$ontSecondVal" select="$ontSecondVal" />
<!-- and whatever other parameters you need to produce the appropriate
output -->
</xsl:when>
<xsl:otherwise>
<xsl:variable name="Values"
select="document(Second.xml)/SubConcepts/SubConcept/Value/@name[.=$clsName]"/
>
<xsl:call-template name="processNode">
<xsl:with-param name="nodeToProcess" select="$Values[1]">
</xsl:otherwise>
</xsl:when>

...
<xsl:template name="processNode">
<xsl:param name="processNode" />
...
</xsl:template>

This might be difficult, but it seems to be the best way to preserve
the nodeset.  But I'm pretty sure there is a better way to do
it.....can't think of it now.


Jon Gorman

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.