[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How to copy all child elements except specific one
Okay - the following xsl does what I need. Is it Good®, or can it be improved upon? <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="Level3"> <xsl:element name="Level3"> <xsl:copy-of select="*[not(name()='ChildElementToChange')]" /> <xsl:variable name="L3Attr" select="@L3Attr" /> <xsl:for-each select="ChildElementToChange"> <xsl:call-template name="ChangeChildElement"> <xsl:with-param name="L3Attr"><xsl:value-of select="$L3Attr" /></xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template name="ChangeChildElement"> <xsl:param name="L3Attr" /> <xsl:element name="ChildElementToChange"> <xsl:element name="NewElement"> <xsl:attribute name="L3Attr"><xsl:value-of select="$L3Attr" /></xsl:attribute> <xsl:attribute name="OldValue"><xsl:value-of select="@OldValue" /></xsl:attribute> <xsl:attribute name="NewValue"><xsl:value-of select="@NewValue" /></xsl:attribute> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> 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
|