473,383 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

XPath Validation using xsd Schema

Hi,

Does anyone know how can I validate XPath expressions using xsd
schema?

Thanks

May 18 '07 #1
4 9091
* sy*********@gmail.com wrote in microsoft.public.dotnet.xml:
>Does anyone know how can I validate XPath expressions using xsd
schema?
The data types defined for XML Schema cannot do that; the only type that
would come close would be regular expressions, but XPath expressions are
not regular. You could take the context-free grammar defined in the spec
and use a regular approximation technique to derive a regular expression
but that's as close as you'd get. It would be better and much simpler to
do this in code. An alternative would be to use RELAX NG instead of XML
Schema and implement a custom data type library that does this.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
May 18 '07 #2
<sy*********@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
Hi,

Does anyone know how can I validate XPath expressions using xsd
schema?
Do you mean that you'd like to validate that the XPath expression matches
something which is valid according to the schema? I don't know of a way to
do that, but if you validate the document first, then there will be nothing
in it which violates the schema. If you then use the XPath expression, and
don't get any exceptions thrown about the form of the expression being bad,
then you could conclude that the expression is valid "according to the
schema".

BTW, I don't believe that the XML Schema Recommendation defines what it
means for an XPath expression to be valid with respect to a schema.
--
John Saunders [MVP]
May 18 '07 #3
On May 17, 7:47 pm, "John Saunders [MVP]" <john.saunders at
trizetto.comwrote:
<syed.akh...@gmail.comwrote in message

news:11**********************@y80g2000hsf.googlegr oups.com...
Hi,
Does anyone know how can I validate XPath expressions using xsd
schema?

Do you mean that you'd like to validate that the XPath expression matches
something which is valid according to the schema? I don't know of a way to
do that, but if you validate the document first, then there will be nothing
in it which violates the schema. If you then use the XPath expression, and
don't get any exceptions thrown about the form of the expression being bad,
then you could conclude that the expression is valid "according to the
schema".

BTW, I don't believe that the XML Schema Recommendation defines what it
means for an XPath expression to be valid with respect to a schema.
--
John Saunders [MVP]
Thanks for replying.. , yes, you are absolutely right.. I need to
validate the XPath expression according to the schema..
I am actually working on a tool which extract data out of incomming
xml using XPath expressions, these XPath
expressions are inputed into it by some developer(s). Now at XPath
entry time I need to validate them with the schema.

I have a quick and dirty solution myself, that I can generate a fullly
populated sample xml based on xsd
and validate XPath expressions using it. But wanna to look for
something better than that which can work with xsds..
Any suggestions??

Thanks

May 18 '07 #4
An xml schema is used to describe and validate an xml document.

An XPath expression is not an XML document.

Therefore, an xsd schema cannot be used to "XPath expressions".

To do something like this one needs a *parser* for XPath.

One could also try a tool like the XPath Visualizer, which allows the user
to play and learn Xpath the fun way.
Cheers,
Dimitre Novatchev
<sy*********@gmail.comwrote in message
news:11**********************@y80g2000hsf.googlegr oups.com...
Hi,

Does anyone know how can I validate XPath expressions using xsd
schema?

Thanks

May 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kevin bailey | last post by:
i suppose what i am asking is this..... can you use xpath the reference the enumeration values for an element? thanks, kev bailey
0
by: Andrew L | last post by:
Hello all, I am using the oXygen XML editor to create and edit some GML files. I am having some problems though, and wondered if anyone may be able to help. 1. The GML (Geographic Markup...
14
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
3
by: David Elliott | last post by:
I am in the process of creating an application to scrape databases in order to create typed DataSets. One of the last pieces that I need to do is to remap database fields to something more...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
0
by: Torsten Munkelt | last post by:
Hi, I want to write an XML-schema saying that this document <root> <edge type="special"> <target type="one"/> </edge> <edge type="special"> <target type="one"/>
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
1
by: Floris Bruynooghe | last post by:
Hi I'm trying to use the .xpath('id("foo")') function on an lxml tree but can't get it to work. Given the following XML: <root><child id="foo"/></root> And it's XMLSchema: <?xml...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.