Re: problem with handling conditional for loops
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/Value[$clsName=text()]"> <xsl:call-template name="processNode"> <xsl:with-param name="nodeToProcess" select="document(Second.xml)/SubConcepts/SubConcept/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"> </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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format