|
Subject: Re: [xsl] Node Position & Relationship! From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx> Date: Fri, 11 Feb 2005 06:30:40 -0800 (PST) |
Hi Adam,
I'll try to answer your question in parts..
q1) to create an xsl if element that tests the current
node to see if it is a level 0 tree_node element.
Ans -
<xsl:if test="self::tree_node and
not(parent::tree_node)">
</xsl:if>
If you are at a given node, this if condition
evaluates true if the node is at level 0(i.e., if it
is a tree_node element, and it has no tree_node
parent)
In the XML you gave, this condition will be true for
<tree_node id="7" value="Test"> node..
q2) how can I find out if a particular node is a
child, ancestor or peer of any given node.
Ans - Suppose node X is the context node, and there is
another node Y ;
X is child of Y, if this condition is true
<xsl:if test="parent::Y">
</xsl:if>
Y is an ancestor of X, if this condition is true
<xsl:if test="ancestor::Y">
</xsl:if>
Y is peer of X(following or preceding sibling), if
this condition is true
<xsl:if test="(following-sibling::Y) or
(preceding-sibling::Y)">
</xsl:if>
Regards,
Mukul
--- Adam J Knight <adam@xxxxxxxxxxxxxxxxx> wrote:
> Given the following xml structure, I want to create
> an xsl if element that
> tests the current node to see if it is a level 0
> tree_node element.
>
> <?xml version="1.0"?>
> <tree>
> <tree_node id="7" value="Test">
> <tree_node id="8" value="Test Sub"/>
> <tree_node id="9" value="Test Sub One">
> <tree_node id="10" value="Test Sub Two"/>
> </tree_node>
> </tree_node>
> </tree>
>
>
> Here is my attached, pretty sad!!!!!
>
> <xsl:if test="{count(self::*)=1}">
> <xsl:apply-templates select="tree_node"/>
> </xsl:if
>
> Can someone give me the correct way to achieve this.
> Also how can I found out if a particular node is a
> child, ancestor or peer
> Of any given node.
>
> Thanks to anyone who response, muchly appreciated.
>
> Cheers,
> Adam
>
> NB: "Pray as if everything depended upon God and
> work as if everything
> depended upon man."
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Node Position & Relationship!, Adam J Knight | Thread | RE: [xsl] Node Position & Relations, Andrew Welch |
| [xsl] Node Position & Relationship!, Adam J Knight | Date | RE: [xsl] Node Position & Relations, Andrew Welch |
| Month |