Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Want to know when an element is not in a node

Reply
Thread Tools

Want to know when an element is not in a node

 
 
rosemm
Guest
Posts: n/a
 
      01-21-2005
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?

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-22-2005


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>
<xsltherwise>
<xsl:text>NOTHING</xsl:text>
</xsltherwise>
</xsl:choose>
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      01-22-2005

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

David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to select all the node names beneath a given node thecolour XML 2 06-27-2007 10:46 AM
I want to select all the node names beneath a given node thecolour XML 0 06-26-2007 04:01 PM
how to delete last node of a Linked list if you only know the address of last node. sangram C Programming 16 12-01-2006 08:57 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM



Advertisments