Want to know when an element is not in a node

Discussion in 'XML' started by rosemm, Jan 21, 2005.

  1. rosemm

    rosemm Guest

    I am having another problem. I need to know when an element is not in a
    node. Here is an example

    .......
    <NODE>
    <Element1/>
    <Element2/ value="SOMETHING">
    </NODE>
    <NODE>
    <Element1/>
    </NODE>
    ......

    I would like to output "SOMETHING" for the first NODE shown and
    "NOTHING" for the second node shown. Is there a way of knowing when an
    element is not a child of a certain node?
     
    rosemm, Jan 21, 2005
    #1
    1. Advertising

  2. rosemm wrote:

    > I need to know when an element is not in a
    > node. Here is an example
    >
    > ......
    > <NODE>
    > <Element1/>
    > <Element2/ value="SOMETHING">
    > </NODE>
    > <NODE>
    > <Element1/>
    > </NODE>
    > .....
    >
    > I would like to output "SOMETHING" for the first NODE shown and
    > "NOTHING" for the second node shown. Is there a way of knowing when an
    > element is not a child of a certain node?


    For example in the template for NODE elements
    <xsl:template match="NODE">
    <xsl:choose>
    <xsl:when test="Element2">
    <xsl:value-of select="Element2/@value" />
    </xsl:when>
    <xsl:eek:therwise>
    <xsl:text>NOTHING</xsl:text>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 22, 2005
    #2
    1. Advertising

  3. <xsl:if test="not(element2)"> .... no element2 child here ....

    David
     
    David Carlisle, Jan 22, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,649
  2. Tjerk Wolterink
    Replies:
    2
    Views:
    1,508
    Dimitre Novatchev
    Aug 24, 2006
  3. sangram
    Replies:
    16
    Views:
    2,081
  4. thecolour
    Replies:
    0
    Views:
    394
    thecolour
    Jun 26, 2007
  5. thecolour
    Replies:
    2
    Views:
    445
    thecolour
    Jun 27, 2007
Loading...

Share This Page