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

RE: comparing a part of the XML tree

Subject: RE: comparing a part of the XML tree
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 15 Jul 2007 18:15:01 +0100
RE:  comparing a part of the XML tree
> My situation is as follows: My user selects a subset of the 
> original XML file. After this action I need to compare the 
> selection of the user to the original. Once I find the 
> location of the selection inside the original I have to 
> surround this selection with a new tag, say "<selected>", and 
> "</selected>". I have placed an example of text online at 
> http://www.jborsje.nl/example.txt, so you can see what I mean.
> 
> One way I can think of is iterating over all of the elements 
> of the original, each time calling the "deep-equal()" 
> function, but I do not know if that is the best approach.

It seems you only have access to the content of the data that the user
selected, and no information about where it was selected from. The best
design of course would be one in which you don't lose that information in
the first place.

Calling deep-equal on every element would do the trick. It could potentially
be quite expensive, but with luck deep-equal doesn't take very long when the
arguments are obviously not equal, for example when they are elements with
different names.

Michael Kay
http://www.saxonica.com/

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-2007 All Rights Reserved.