|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSLT - update attribute with new value
> Hi David and Michael, It's best not to address questions to specific people. Sometimes in an initial response I try to point people in the right direction, but that doesn't necessarily mean I'm prepared to hold their hands all the way down the road - whereas someone else might well be happy to do so. > > Now I have one final question. I want to add an attribute/value to the > xml tree only if that attribute does not exist anywhere in > the document > source tree. > > Is there a way to do that in XSLT? You can test whether the attribute is absent from the tree with <xsl:if test="not(//@x)"> But remember that your stylesheet code must be structured to mirror the result tree structure, not the source tree structure. So you have to put this code in the template rule for the element that is to carry the new attribute. If this template rule is evaluated repeatedly, it will be more efficient to put the condition <xsl:variable name="x-is-absent" select="not(//@x)"/> in a global variable. Michael Kay http://www.saxonica.com/
|
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
|

Cart








