• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validating xpath against xml schema

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
How can I validate an XPath against an xml schema (not against the actual
xml document) ? So - I want to take a subset of an xml document and I want to validate only this subset against an xml schema.
Any idea how to handle this?
Is there a library supporting me in doing so?
I would be happy to receive some answers
or suggestions from you.
Thanx in advance!
- Thomas -
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, honestly, I have absolutely no clue.
But, your requirement draws a lot of curiosity...
May I ask the circumstances in which you need to do this...
I am positive there's a very valid reason and
I am curious to know what it is.
Thanks.
- madhav
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does it have to XPath with which you obtain that "part" to validate? You could just go the blunt force way and create an org.w3c.dom.DocumentFragment out of each piece of the DOM tree you want to validate. Then, write the fragment into an XML string and parse it back into a Document with schema validation turned on.
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx to both of you!
My requirements are as follows:
I've just a schema and no xml document.
Someone has to enter an xpath (selecting a subset of a currently
not existing xml document).
Now I want to check against the schema whether the xpath is valid
(to the schema) or if it's not.
O.k. - Now you think I'm nuts. But this requirements were given me
by my manager and I'm new to xpath and schemas and stuff.
That's why I posted that (maybe stupid) question into this
forums
- Thomas -
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you explain the criteria based on which a given XPath expression is considered to be valid or invalid?
For example, does the XPath need to always match some elements or is it enough that it might or might not match? Considering that element <foo> is specified to have 0..n children of type <bar>, would "foo/bar[2]" be considered valid or invalid (since the schema doesn't guarantee that there will be 2 children...)?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...I'm nuts. But this requirements were given me
by my manager


Ok, will sleep on this and post if I have any good thoughts...
Do you get the absolute XPath ? (meaning XPath from the Root
node) or will it be a partial XPath ?

- m
[ February 19, 2004: Message edited by: Madhav Lakkapragada ]
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx for your help, guys!
Lasse pointed out why this thread can be closed by now:
The requirements that were given me, can't be satisfied
with simply validating an XPaht against a schema. It's possible
that there will occur equivocations regarding the structure
of the xml document which definitely will result in serious
problems. The structure of the xml document would have to be
that much fixed so such equivocations wont exist. But in this
case I'm not forced to validate the XPath against a schema, but
against the xml document by itself.
Thanx, Lasse & Madhav!
You both did me a great favor!
Best regards,
- Thomas -
 
This is my favorite tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic