[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: comparing nodesets to each other

Subject: Re: comparing nodesets to each other
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 11 Apr 2005 16:35:20 +0100
xsl copy of nodesets attributes
without seeing what your source xml looks like, or what output format
you want to generate it's fairly impossible to give any specific advice,
but a few observations.

      <xsl:variable name="variation">
   ...

this means that $variation will hole a result tree fragment, which means
that

      <xsl:for-each select="$variation">

will generate an error on a conformant XSLT 1.0  processor, if you are
using XSLT 2, best to say so, as any answeres are likely to be rather
different in that case. For XSLT1 you'd need a node-set extension
function.


In general it's rather hard to define "difference" (see a long thread on
exactly that subject lastweek)

for example if your two fragments are

<a>
 <b/>
 <c/>
 <d/>
</a>

and

<a>
 <x/>
 <b/>
 <c/>
 <d/>
</a>

What do you want to mark as the "difference", is it that an element x
was added (this does actually correspond to the edit I made to generate
the text above) or do you want to mark that the frst child changed from
b to x, the second from c to b, the third from d to c, and a new fourth
child, d added.

Depending on which of those two answers you want, the code is likely to
be radically different. 



         <xsl:if test=". != $compare-node">
            <xsl:copy-of select="."/>
            <xsl:attribute name="different">current</xsl:attribute>
         </xsl:if>

This will always generate an error if teh test is true.
The copy-of . copies an element node, and then xsl:attribute tries to
add an attribute to the currently open node, ie the parent of teh node
just copied, and you can not add attributes to an element once a child
has been added.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.