473,386 Members | 1,835 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,386 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 9092
* 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.