xsl-list
[Top] [All Lists]

Re: Node Position & Relationship!

2005-02-11 08:24:08
I'm doing it like this:

<xsl:variable name="level" select="count(ancestor::Menu)"/>
(...)
<xsl:choose>
        <xsl:when test="$level=0">
                <xsl:text>1</xsl:text>   ----> this node is visible
        </xsl:when>

where Menu is your tree_node.


On Sat, 12 Feb 2005 00:08:36 +1000, Adam J Knight
<adam(_at_)brightidea(_dot_)com(_dot_)au> 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."

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