[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using attributes with XPath
Mike,
How about simply <xsl:template match="list/@type"> ... cool code ... </xsl:template> which is more concise and easier to maintain than either a distinct mode, or name-testing on the parent (which shouldn't require passing a parameter in any case)? More generally, I think problems like Jacqueline's are usually dealt with most simply at the level of the list, where the "natural" mapping to the result element will be: <xsl:template match="list"> do stuff for lists </xsl:template> <xsl:template match="list[@type='special']"> do stuff for special lists </xsl:template> Because of the template matching rules, the second template will apply when it can, and the first will apply when the second one can't. Note that when you've matched an attribute, <xsl:apply-templates/> won't get you the contents of the element since they're not inside the attribute. So matching attributes is most common when we're just adding a bit of generated text or some such. Cheers, Wendell At 01:07 AM 8/24/2006, you wrote: Jackie, If you want to write templates for common attributes, you can distinguish them in two ways (XSLT 1.0).
|
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
|