• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

Comparing XML files with same schema using xslt, javascript

I need to write some code that will allow comparing tag elements of two xml files with the same schema.  

I'm currently creating xslt files using Altova SytleVision to allow the xml to be viewed in a web browers as formatted (html).

I've learned that several popular web browsers don't understand xslt 2.0.  And, I don't think it's possible to have xlst deal with more than one xml file in xslt 1.0.

I'm not worked much with html and have just completed a tutorial on javascript.  I'm thinking there might be an easy way to use xslt created from Style vision (that works on a single file) with some javascript to get what I need.

Does this sound like a reasonable approach?  Any example to get me started?

Thanks,

Dave Thomas

0
DaveThomasPilot
Asked:
DaveThomasPilot
  • 4
  • 2
1 Solution
 
Geert BormansInformation ArchitectCommented:
> I've learned that several popular web browsers don't understand xslt 2.0

That is an understatement. There simply is no browser that supports XSLT2.0,
and that is not likely going to change real soon

> And, I don't think it's possible to have xlst deal with more than one xml file in xslt 1.0.

That is not correct. Using the document() function, you can pull in as many documents as you please

Stylesvision isn't exactly on my list of favorite tools, the XSLT coming out of it is very hard to maintain
If the comparisson you will need is predictable, it can easily be done in XSLT
0
 
DaveThomasPilotAuthor Commented:
Hey, that sounds promising!

I'm using StyleVision, since I didn't really have to learn xslt and the drag/drop from the schema elements to create a formatted view of the xml was really nice.  And it's very convenient for  creating nice looking static elements in the xslt

The comparison I need to do is very predictable.  There are several elements that I want to show side by side with additional columns for difference, and perhaps percent difference (for the numeric fields).

I also want to sum across several elements and have columns to compare sums in a similar manner.

It would be nice to use SytleVision, for the reasons I stated, butI don's see how to do it.  I thought the answer to the a question I posted on their foroum was that it was only possible with xslt2.0, but maybe that's a limitation of their tool, not xslt1.0.  So, I'll revisit that.

But, maybe I can use StyleVision to create templates with the static part of the form using a single "working" xml file for the fields to diff.  Then make edits to change xslt to refer to elements in different xml files?

If I do just code the xslt manually, how does it work?  Could you show a simple example that references the same element in two xml files and shows them side by side?

Thanks,

Dave Thomas
0
 
Geert BormansInformation ArchitectCommented:
It likely is a limitation of their tool, it seems pretty tough to make such a compare in Stylevision.

I think the best way to proceed is that you show us the two XML files an d how you want the compare to look like,
I will then make a first shot at it
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
DaveThomasPilotAuthor Commented:
Ok, that will take a little work on my part.  I really can't post the actual xml files, since the data is company confidential (and maybe even the schema).

But I can make up some xml that shows what I'm trying to do.  I won't be able to get to that today, but I will probably have something some time tomorrow.

Also, I found this:

http://www.xml.com/pub/a/2002/03/06/xslt.html

Which describes how to do in straight xslt.

Thanks,

Dave Thomas
0
 
DaveThomasPilotAuthor Commented:
I found out I can actually use document() in StyleVision and received an example of how to do it.

But,since the original answer corrected my assumption that document() was only supported in xslt2.0, I"m awarding points.

Thanks,

Dave Thomas
0
 
DaveThomasPilotAuthor Commented:
Instead of the xslt example, since I"m using StyleVision, any chance you can send simple javascript that prompts for two files and uses those files as arguments for document()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now