Subject: Re: [xsl] Simple XML Diff|
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Mon, 14 Jul 2008 09:51:27 +0200
In my output, I need to differentiate between node1/name and node2/name. Is there a way to get the full path of the current element so I output contains the path as well as the element name?
Secondly, if a node has children, the entire RTF is tested.
A result tree fragment, or RTF, is created by filling an xsl:variable using the content instead of the @select attribute. An RTF is a bit odd, as it's not a first class node-set. But here, we have node-sets, not RTFs.
is there a way to omit RTF's containing more than one node
I think what you're trying to avoid having flagged here is element nodes containing other element nodes. You can do this by adding the following template to the stylesheet contained in my second post:
<xsl:template match="*[*]"> <xsl:apply-templates select="*|@*"/> </xsl:template>
This will match element nodes containing other element nodes, not generate any output but simply carry on processing down the tree.
Note, however, that differences involving mixed content (element and text nodes interspersed) will escape your notice if you adopt this approach. Let's say there is an element that has other element children but also text children, and there is a difference in the text children with regard to your reference document. This difference won't get detected; you'd need something more refined here. If you know, on the other hand, that you don't have mixed content there is no problem.