Click to See Complete Forum and Search --> : XSLT constraint through XPATH


ranadhir
02-27-2007, 05:40 AM
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 occurrence constraint through template?

alx_web
03-07-2007, 09:26 AM
Why don't you use a DTD to constrain the XML?

Alx