I've implemented this in a recursive fashon but as most xml editors seem to run out of stack space I thought there should be a more efficient solution out there.
I've looked at Jenni Tenison's set difference template: http://www.exslt.org/set/functions/difference/set.difference.template.xsl
but need something slightly different. I need node equality to be defined as concat(node(.),@name).
There is a predefined set of nodes:
<a name="Adam"><!-- don't care about contents for equality purposes --></a>
<b name="Berty"><!-- don't care about contents fo开发者_JAVA百科r equality purposes --></b>
<a name="Charly"><!-- don't care about contents for equality purposes --></a>
I want to find out the subset of the below nodes that are not in the above list:
<b name="Berty"><!-- different contents --></b>
<b name="Boris"><!-- different contents --></b>
The result I'm after would be a node set of:
<b name="Boris"><!-- different contents --></b>
To complicate things I can't use Key as the nodes are in different documents (overriding imported definitions are the reason I'm trying to process this). Also this needs to be XSLT 1.0 as I need to render in IE / Firefox.
Any thoughts / suggestions / guidence wellcome!
Have you taken a look at the technique in the XSLT Cookbook?
http://books.google.com/books?id=POJkiuHIAfoC&lpg=PP1&pg=PA324#v=onepage&q=&f=false
Mr. Mangano has a recipe for set difference, and a fairly well written explanation as well. Mind you, when you are comparing two elements that seem to be the same but have two different source documents, XSLT will usually report them as different, so you must test by the value of the element, attributes, etc.
You might want to poke at the example code from the book, provided here: http://oreilly.com/catalog/9780596009748
精彩评论