[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: merging generic elements in a parent-child relatio
Hello Matias,
the following stylesheet will do the job: The key indexes als <b/> and <c/> by their @ida and @idb attribute values. This key is later used to access the "childs". The key('abc', @id) with this <xsl:key/> means <xsl:apply-templates select="(../b|../c)[@ida = current()/@id or @idb = current()/@id]"/> <xsl:key name="abc" match="b|c" use="@ida|@idb"/> <xsl:template match="root"> <xsl:copy> <xsl:apply-templates select="a"/> </xsl:copy> </xsl:template> <xsl:template match="a|b|c"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates select="key('abc', @id)"/> </xsl:copy> </xsl:template> Of course using the key is a bit more readable and normally much faster (dependent on the file size). Furthermore you can use a more validating version to avoid or at least ignore errors in writing XML. The following changed key-declaration for example ignores @ida on c-elements. <xsl:key name="abc" match="b" use="@ida"/> <xsl:key name="abc" match="c" use="@idb"/> Regards, Joerg Matias Woloski wrote: Hi! I have this xml 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
|