472,804 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 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 9040
* 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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.