• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT constraint using XPath

 
Ranadhir Nag
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are trying to enforce a couple of business constrainrs with XPATH .
A sample xml node is as follows:
.....
.....
<event>
<element>IE</element>
<elementtype>browser</elementtype>
<eventtype>Navigate</eventtype>
<value>http://www.....com/</value>
</event>
.......
.......

If we need to ensure that the XML has ATLEAST one 'element' node containing text as "IE" we do:
<xsl:template match="element[count(IE) < 1]" >
<xsl:text>ERROR: Atleast one IE element needed</xsl:text>
</xsl:template>

But we need to ensure that ATLEAST one of the IE 'event' nodes has a combination of 'element' as IE and 'value' node containing the text "Logout" i.e.

<event>
<element>IE</element>
<elementtype>....</elementtype>
<eventtype>Navigate</eventtype>
<value>...Logout...</value>
</event>

How do we enforce this occuurrence constraint through template?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic