xsl-list
[Top] [All Lists]

RE: accessing parent element in if clause

2005-01-20 06:49:03
You want 

<xsl:if test="parent::definition">

Or better still, build this into the match pattern for the template:

<xsl:template match="definition/node">

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Rahil Qamar Yahoo [mailto:qamar_rahil(_at_)yahoo(_dot_)co(_dot_)uk] 
Sent: 20 January 2005 12:01
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] accessing parent element in if clause

Hi

Im sure its a fairly basic question for most but Im just 
starting out on 
XSLT and cant find any resources to solve my problem.

I want to perform an operation based on an 'if' clause as shown below

-----------------------------------
<xsl:template match="/">
    <PrimeConcept><xsl:apply-templates 
select="/archetype/definition/node"/>
    </PrimeConcept>
</xsl:template>

<xsl:template match="node">
    <xsl:if test="parent::node()=definition">
        <xsl:attribute name="id"><xsl:value-of 
select="@id"/></xsl:attribute>
        <xsl:attribute name="type"><xsl:value-of 
select="@rm_class"/></xsl:attribute>
    </xsl:if>
</xsl:template>
----------------------------------

Theres a problem with the <xsl:if> statement where Im trying to 
determine whether the <node> element is the child of the <definition> 
element. I think theres a problem in the way Im trying to access the 
parent node but cant figure out the right way.

Could someone please help.

Thanks
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>
--~--




--~------------------------------------------------------------------
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>
--~--