Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 254327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:50:14+00:00 2026-05-11T21:50:14+00:00

You can verify an XPath expression against an XML doc to verify it, but

  • 0

You can verify an XPath expression against an XML doc to verify it, but is there an easy way to verify the same XPath expression against the schema for that document?

Say I have an XSD schema like this:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... etc>
  <xsd:element name="RootData">
    <xsd:complexType>
      <xsd:sequence minOccurs="0">
        <xsd:element name="FirstChild">
          <xsd:complexType>
            <xsd:sequence minOccurs="0">
              <xsd:element name="FirstGrandChild">
... etc etc

Is there an easy or built-in way to verify that the XPath:

/RootData/FirstChild/FirstGrandChild

would be valid against any XML documents that may be based on that schema? (Edit: I guess I mean potentially valid; the actual XML document might not contain those elements, but that XPath could still be considered potentially valid for the schema. Whereas, say, /RootData/ClearlyInvalidChild/ThisElementDoesntExistEither is clearly invalid.)

Of course I could only expect this to work against canonical XPath expressions rather than ones of arbitrary complexity, but that’s fine.

I’m specifically thinking in .NET but am curious if other implementations make it possible. It’s not so important that I want to roll my own, for example I don’t really want to write my own code to transform that XPath expression into another one like:

/xsd:schema/xsd:element[@name='RootData']/xsd:complexType/xsd:sequence/xsd:element[@name='FirstChild']/...etc...

… though I know I could do that if I really had to.

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:50:15+00:00Added an answer on May 11, 2026 at 9:50 pm

    We actually did a research project on this, and implemented an XPath verifier, sometime around 2000. This was for XPath 1. I am not aware of any currently available libraries that you can use to do this.

    If you want to go and implement this yourself, here are some hints:

    • You will not be able to transform a path over an instance document into a path over a schema as you do above. For example, /a//b does not transform into /xsd:element[@name='a']//xsd:element[@name='b'] because element b may be defined at the top level of the schema, not underneath b.

    • Remember that while an XML document is a tree, a schema is a graph. If you search descendant paths like //a, you will have to decide when to terminate the search or it may continue forever (e.g. imagine in a element “a” that contains “b”, which contains “a”)

    • Some paths will be undecidable or at least very hard to decide. For example //*[starts-with(@name, 'foo')]

    If you’re still up for it, I suggest using a library like eclipse’s XSD or the .NET schema loading classes to load the schema into memory and do your checking in code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any tools that can verify whether a jQuery plugin will be compatible
How can I verify a given xpath string is valid in C#/.NET? I'm not
How can I verify an X509 (or DER-formatted) certificate against the Java certificate store
There are many online judge sites which can verify your program by comparing its
I would like to know how I can verify a user's credential against an
I create the cookie in jQuery. I can verify it in Firefox. But when
I have some memory which is initialized in initWithCoder:. I can verify that before
Hopefully there are some WCF wizards out there that can spot my mistake here.
I've been through the forums for awhile and I can verify that my issue
Can somebody point me to a resource that explains how to go about having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.