Want to know when an element is not in a node

R

rosemm

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?
 
M

Martin Honnen

rosemm said:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top