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. Advertisements

  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. Advertisements

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

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

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,909
  2. Patient Guy
    Replies:
    8
    Views:
    919
    Roy Schestowitz
    Feb 13, 2005
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,715
    Dimitre Novatchev
    Aug 24, 2006
  4. sangram
    Replies:
    16
    Views:
    2,349
  5. thecolour
    Replies:
    0
    Views:
    513
    thecolour
    Jun 26, 2007
  6. thecolour
    Replies:
    2
    Views:
    573
    thecolour
    Jun 27, 2007
  7. Simon Egginton

    LOOK! i just want to know does anyone know...

    Simon Egginton, Jul 26, 2004, in forum: Javascript
    Replies:
    3
    Views:
    352
    Dr John Stockton
    Jul 26, 2004
  8. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    488
    Gregory Toomey
    Apr 23, 2004
Loading...