Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2008, 05:41 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default XML differences

I'm working on finding differences in 2 xml files. I need to check for new text, new tags, new attributes, etc., whichever is new. I can find that there is a change. But I can't locate the exact line-number. Is there any way?
File1.xml
<?xml version="1.0" encoding="UTF-8"?>
<file1>
  <file11 href="ha">test1</file11>
  <file12 href="">test2</file12>
</file1>
File2.xml
<?xml version="1.0" encoding="UTF-8"?>
<file1>
  <file21>test2</file21>
  <file22 href="hai">test1</file22>
</file1>


__________________
Rummy
Reply With Quote
  #2 (permalink)  
Old October 6th, 2008, 06:08 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You don't say anything about the technology you are using.

Most of the standard tree models (DOM, JDOM, etc) don't give you any line number information.

It's available from SAX and StAX parsers, but that's a bit low-level.

If you're using Saxon, there's an option to maintain line numbers and retrieve them using the saxon:line-number() extension function.

Incidentally, there are products like DeltaXML that do this for you, and much better that you could hope to achieve in something home-grown.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old October 6th, 2008, 06:23 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Thanks Mike. I'm using XSLT 2.0 with Saxon processor.
I can't opt for products like DeltaXML. Is there any way to do it through code?

thanks in advance

Reply With Quote
  #4 (permalink)  
Old October 6th, 2008, 07:32 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In Saxon you can cause line numbers to be maintained using -l from the command line or the equivalent from the API (e.g TransformerFactory.setAttribute("http://saxon.sf.net/feature/linenumbering", Boolean.TRUE), and you can then access the line number using saxon:line-number(), as already mentioned.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old October 6th, 2008, 07:34 AM
Friend of Wrox
Points: 1,306, Level: 14
Points: 1,306, Level: 14 Points: 1,306, Level: 14 Points: 1,306, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Pondicherry, India
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default

Thank Mike.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mozilla/IE 7 differences Adam H-W CSS Cascading Style Sheets 2 July 9th, 2007 04:16 AM
Xcode 2.4 differences craigontour Xcode 1 November 24th, 2006 11:08 PM
Java code to find differences in XML like ExamXML alapick Java Basics 1 July 28th, 2006 04:15 AM
objDataAdapter Differences cpbittner BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 September 20th, 2004 08:09 PM
Variable Differences hugh@kmcnetwork.com ASP.NET 1.0 and 1.1 Basics 1 December 30th, 2003 12:16 AM



All times are GMT -4. The time now is 05:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.