Subject: Re: [xsl] Replacing matching values with values from another document? From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 6 Mar 2007 00:50:05 GMT |
I had to modify your input to make it well formed, but something like this works, in practice, you may need position() or some such as part of your "same element" criterion, but as you posted it, just using unique names, this seems to work: <docA> <a></a> <b>fred</b> <c att="value1"/> <e>e</e> <!-- no "override" in docB, so it comes forward into the result--> </docA> <docB> <a/> <!-- no need to change docA--> <b>ethel</b> <!-- "fred" in docA would have to be changed to "ethel"--> <c att="value2"/> <!-- "value1" in docA has to become "value2"--> <d att="foo"> doesn't match </d> <!-- dropped on floor, no element name--> match </docB> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*[key('b',name(),doc('docB.xml'))]"> <xsl:copy-of select="key('b',name(),doc('docB.xml'))"/> </xsl:template> <xsl:key name="b" match="*" use="name()"/> </xsl:stylesheet> $ saxon8 docA.xml doc.xsl <?xml version="1.0" encoding="UTF-8"?><docA> <a/> <b>ethel</b> <c att="value2"/> <e>e</e> </docA>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Replacing matching values wit, Edmund Mitchell | Thread | [xsl] Static Validation of XSL Tran, Anders Møller |
[xsl] Replacing matching values wit, Edmund Mitchell | Date | [xsl] Static Validation of XSL Tran, Anders Møller |
Month |