|
[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
<xsl:template match="Level3">
<xsl:element name="Level3">
simpler to write <Level3>
<xsl:copy-of select="*[not(name()='ChildElementToChange')]" />
better to do *[not(self::ChildElementToChange)]
<xsl:variable name="L3Attr" select="@L3Attr" />
No need to use a variable here, just means you access with $ instead of
../@
<xsl:for-each select="ChildElementToChange">
<xsl:call-template name="ChangeChildElement">
It would probably have been simpler to just use
<xsl:apply-templates select="ChildElementToChange"/>
rather than use a named template in for-each, but if you are using a
named template then
<xsl:with-param name="L3Attr"><xsl:value-of select="$L3Attr"
/></xsl:with-param>
This could more simply be expressed as
<xsl:with-param name="L3Attr" select="../@L3Attr"/>
but you don't need a parameter at all as the named template has access
this to this data as @L3Attr
</xsl:call-template>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template name="ChangeChildElement">
as noted above, it would probably have been simpler
to have <xsl:template match="ChildElementtoChange">
<xsl:param name="L3Attr" />
and you don't need this param.
<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>
the above lines could be written as
<ChildElementToChange>
<NewElement>
<xsl:copy-of select="@OldValue|@NewValue|../@L3Attr"/>
</NewElement>
</ChildElementToChange>
</xsl:template>
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
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
|

Cart








