[Home] [By Thread] [By Date] [Recent Entries]
At 2010-01-18 01:48 +0100, cvergara@xxxxxxxxxxxxxxxxxx wrote:
Hello, It looks like all you are doing is starting the reconstituted A with a new first child and then processing the original content as is. An example is below, but I'm guessing I'm missing something from your description. Your behaviour for <B> would be added to my solution with a template matching it. BTW, I know you don't have attributes for <A> but I left handling for that in the solution. I hope this helps. . . . . . . . . . . Ken t:\ftemp>type cristobal.xml
<A>
... <- unknown/variable amount of nodes
<B>
<C attrC="value1"/>
<D attrD="value2"/>
</B>
</A>t:\ftemp>xslt cristobal.xml cristobal.xsl <?xml version="1.0" encoding="utf-8"?><A><new_element attrC="value1" attrD="valu e2"/> ... <- unknown/variable amount of nodes <B> <C attrC="value1"/> <D attrD="value2"/> </B> </A> t:\ftemp>type cristobal.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="A">
<xsl:copy>
<xsl:copy-of select="@*"/>
<new_element attrC="value1" attrD="value2"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template><xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> t:\ftemp>
|

Cart



