R
Ryan Nordman
Hey XML gurus,
Is there a way to write a template so that it will compare two XML
subtrees wholesale? I can't quite get my head around this problem.
Let's say I have these two XML trees, both have the same structure,
but one of them has a few different pieces of text than the other.
So my basic thoughts here are to first create a key that in essence
makes a catalog of all the elements in one of the subtrees, call it
tree A, with the key being simply the name of the nodes. Then I call
a template on the root node of tree B, and basically, for each node, I
generate the key so I can pull up the matching node in tree A and
compare them somehow.
By compare though, for each node in tree A I actually want to compare
all of it's children with all of the children in tree B so that if
they're all equal, I can ignore them. If a node in A has some child
that doesn't match it's equivalent child in B, then I need to write
that node. Otherwise, I ignore it and it is not in my XSLT output.
Does this make sense? Am I thinking about this problem the wrong
way? Any kind of discussion or pointing me in the right direction
would really help.
Is there a way to write a template so that it will compare two XML
subtrees wholesale? I can't quite get my head around this problem.
Let's say I have these two XML trees, both have the same structure,
but one of them has a few different pieces of text than the other.
So my basic thoughts here are to first create a key that in essence
makes a catalog of all the elements in one of the subtrees, call it
tree A, with the key being simply the name of the nodes. Then I call
a template on the root node of tree B, and basically, for each node, I
generate the key so I can pull up the matching node in tree A and
compare them somehow.
By compare though, for each node in tree A I actually want to compare
all of it's children with all of the children in tree B so that if
they're all equal, I can ignore them. If a node in A has some child
that doesn't match it's equivalent child in B, then I need to write
that node. Otherwise, I ignore it and it is not in my XSLT output.
Does this make sense? Am I thinking about this problem the wrong
way? Any kind of discussion or pointing me in the right direction
would really help.