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

Re: equivalent for 'while'

Subject: Re: equivalent for 'while'
From: RQamar <qamar_rahil@xxxxxxxxxxx>
Date: Fri, 18 Feb 2005 15:24:02 +0000
xsl equivalent for while
Hi

I've managed to retrieve the grandchild of 'Pain' in the following way (not sure its the best way though):
-------------------------------------
<xsl:template match="DEFCONCEPT" mode="top">
<xsl:if test="@name = $prime"> <!--resolves to Pain-->
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:element name="PrimeName"><xsl:value-of select="@name"/></xsl:element><!-- e.g. Pain-->
<xsl:if test="//*[@name = $constraint]"> <!--resolves to Headache-->
<xsl:element name="SubConcepts">
<xsl:element name="SubConcept">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:if>
</xsl:if> </xsl:template>
-----------------------------------


The resulting output is such

------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Top>
<PrimeConcept id="10180">
<PrimeName>Pain</PrimeName>
<SubConcepts>
<SubConcept id="10180" name="Pain"/>
</SubConcepts>
</PrimeConcept>
</Top>
------------------------------
I have two problems though. First, my <SubConcept> element tag displays 'Pain' and '10180' instead of 'Headache' and '10279'. Is that because the control still remains at the 'Pain' element?


Second, the actual output I'd like is
<PrimeConcept></PrimeConcept>
<SubConcepts>
   <SubConcept></SubConcept>
</SubConcepts>

but I'm not sure how to create a top-level node <SubConcepts> from within the <PrimeConcept> if clause.

Could someone please help me out with this?

Thank you
Rahil

Andrew Welch wrote:



It's not immediately obvious how you arrived at your output, for example where does the SubConcept/id value of '11000' come from?







Oh the '11000' is just an id I made up for completing the XML document. However it comes from some other part of document 2 which I havent shown in the post (to avoid lengthy chunks of code).



That didn't help matters then...

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.