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

Re: Friday challenge: XSLT thats creates XPaths for m

Subject: Re: Friday challenge: XSLT thats creates XPaths for meaningfully equivalent comparisons of XML files
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Fri, 13 Apr 2007 16:20:39 +0100
Re:  Friday challenge: XSLT thats creates XPaths for  m
On 4/13/07, David Carlisle <davidc@xxxxxxxxx> wrote:
<checkXML>
   <xml src="file:/C:/test.xml">
      <check>/root[1]/foo[1]/text[1] = 'foo'</check>
      <check>/root[1]/foo[1]/@fooatt = 'att'</check>
      <check>/root[1]/bar[1]/text[1] = 'bar'</check>
      <check>/root[1]/bar[2]/text[1] = 'baz'</check>
   </xml>
</checkXML>

If you were looking for an existing format for that you could write the above
as a schematron fairly easily.

I looked briefly at Schematron and I'm afraid I wasn't that impressed. I didn't see the reason to learn a new language for it to be converted into an XSLT 1.0 stylesheet that I could do a better job of writing myself.

This is why CheckXML was born - apply XSDs, XPaths and XSLTs (and
XQueries and RNGs) to your XML to check the correctness - you have the
full expressive power of the checking language to give you the best
possible error message and you can write all the checks in the
language you're already familiar with.

Also, (and don't flame me if I'm too wide of the mark here) the assert
statements in XML Schema 1.1 will effectively make Schematron
redundant.


In either case though there is the usual nuisance about serialising
xpaths and reading them back later of getting the namespace context
right.

The beta Schematron has some code to generate namespace-safe xpaths
from any node, which could be used, see:
http://eccnet.eccnet.com/pipermail/schematron-love-in/2007-February/000558.html


In either case though it seems like you could be generating a lot of xpaths and then having to iterate over them, while schematron, or what I guess checkXML could do is more general, for the specific job of checking two documents can't you have a stylesheet that just tree walks over the two trees in tandem, that way you never (much) need to generate namespace-safe xpaths, as you can get the relevant node names as Qnames and do namespace aware QName comparisons. It's just serialising the names to an Xpath string that loses the context.

I'm planning on taking mappings from the xml... I know this may not be the "correct" way, but I really think "/a:b/a:b" is an acceptable xpath when applied against an XML document where the user has supplied both the xpath and the xml document...

cheers
andrew

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.