[XML-SIG] XSLT magic

Nicolas Chauvat Nicolas.Chauvat@logilab.fr
Thu, 6 Dec 2001 17:22:06 +0100 (CET)


Hi Lists,

Context: Logilab has an xmldiff tool[1] that can output the diff of two
documents as a set of xupdate elements.

With that xupdate and the original revision of the document as inputs, I
want to ouput a modified document that reflects the changes and can be
turned into HTML then styled to highlight the changes (red = removed,
yellow = changed, green = added), very much alike diffmk[2].

My problem is that I am not sure how to write the XSLT that will transform
my original document into the revision-tagged one.

So far, I chose to transform the former into the latter passing the
xupdate filename as an argument to the processor. The idea is to copy over
every node from the first document, adding @revisionflag attributes on
nodes removed/changed/added. But how do I know that a node was
added/changed/removed? What I have on the xupdate nodes are string
attributes that represent xpaths and I do not know how to figure out
wether the current node is matched by the xpath of a particular node.

Example :

	<article>
	<title>My Title</title>
	<para>my text</para>
	<para>other text</para>
	</article>

and 

	<xupdate:remove select="/article[0]/para[1]"/>

would output

	<article>
	<title>My Title</title>
	<para>my text</para>
	<para revisionflag="removed">other text</para>
	</article>

tentative algorithm in the stylesheet would be

match any node
	copy current node
	if current node is pointed to by the xpath of one of the xupdate
	   nodes :
		add an attribute revisionflag whose value depends on the
			node name of the above xupdate node

My current problem is with "current node is pointed to by the xpath"...

Any ideas will be welcome.

References:
1: http://www.logilab.org/xmldiff
2: http://www.sun.com/xml/developers/diffmk/

-- 
Nicolas Chauvat

http://www.logilab.com - "Mais oł est donc Ornicar ?" - LOGILAB, Paris (France)