[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Testing for Parent Nodes of multiple types
Hi Ciaran, > Sorry maybe well-formed was not used in the correct context. It's just that you're using the term 'well-formed' when you mean 'valid'. 'Well-formed' just means that the start and end tags match and attributes have quotes around them, that kind of thing - that the XML follows the XML rules. 'Valid' means that the elements have the right children, parents and attributes. Or even if you get into schema validation that their values are of the right type. Another option to add to the raft of suggestions for testing whether a b element is a child of one of a particular set of elements is to define a key that indexes only those b elements who *are* children of those elements by their generated id: <xsl:key name="valid-bs" match="p/b | b/b | i/b | u/b | td/b" use="generate-id()" /> Since this only matches valid b elements, you can find out whether a b element is valid by seeing if using the key on its generated ID actually returns anything: <xsl:template match="b"> <xsl:if test="not(key('valid-bs', generate-id()))">...</xsl:if> ... </xsl:template> Or of course the other thing is that you could just have separate templates for the two sets of b elements: <!-- matches valid b elements --> <xsl:template match="p/b | b/b | i/b | u/b | td/b"> ... </xsl:template> <!-- matches all other b elements --> <xsl:template match="b"> ... </xsl:template> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|