XML & Web services: Implementing XSLT constraint
We are trying to enforce a couple of business constrainrs with XPATH . A sample xml node is as follows: ..... ..... IE browser Navigate http://www.....com/ ....... ....... If we need to ensure that the XML has ATLEAST one 'element' node containing text as "IE" we do: ERROR: Atleast one IE element needed 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. IE .... Navigate ...Logout... How do we enforce this occuurrence constraint through template?
You should consider investigating Schematron to check this, but you can also do it yourself in XSLT or in anything that implements XPath. You basically have two XPath queries that need to come back true: count(//event[element = 'IE']) >= 1 count(//event[(element = 'IE') and contains(value, 'Logout')]) >= 1 Cheers, Tony. -- Anthony B. Coates Author, XML APIs chapter Advanced XML Applications from the Experts at The XML Guild http://www.amazon.com/XML-Power-Comprehensive-Guide-Guides/dp/1598632140/