xsl-list
[Top] [All Lists]

Re: problem with handling conditional for loops

2005-04-27 10:06:06
Aron Bock wrote:


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

<xsl:otherwise>
<xsl:variable name="Values"
select="document(Second.xml)/SubConcepts/SubConcept/Value/@name[.=$clsName]"/>
<xsl:variable name="nodeToProcess" select="$Values[1]">
</xsl:otherwise>
</xsl:when>
<<<

You probably want:

<xsl:variable name="nodeToProcess">
   <xsl:choose>
   ...
  </xsl:choose>
</xsl:variable>

The choose should be inside the variable definition; else the variable goes out of scope when the choose finishes.


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>

So I want that $nodeToProcess contains both 'Hello' and '1234' say of the form 'Hello,1234' or 'Hello 1234'.

I tried out a few ways of doing it but none worked!

Suggestions
Rahil


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--