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

  • SEARCH
  • Home
  • 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 833369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:30:27+00:00 2026-05-15T04:30:27+00:00

As per the official documentation of lxml, if one wants to validate a xml

  • 0

As per the official documentation of lxml, if one wants to validate a xml document against a xml schema document, one has to

  1. construct the XMLSchema object (basically, parse the schema document)
  2. construct the XMLParser, passing the XMLSchema object as its schema argument
  3. parse the actual xml document (instance document) using the constructed parser

There can be variations, but the essense is pretty much the same no matter how you do it, – the schema is specified ‘externally’ (as opposed to specifying it inside the actual xml document).

If you follow this procedure, the validation occurs, sure enough, but if I understand it correctly, that completely ignores the whole idea of the schemaLocation and noNamespaceSchemaLocation attributes from xsi

This introduces a whole bunch of limitations, starting with the fact, that you have to deal with instance<->schema relation all by yourself (either store it externally or write some hack to retrieve the schema location from the root element of the instance document), you can not validate the document using multiple schemata (say, when each schema governs its own namespace) and so on.

So the question is: maybe I am missing something completely trivial or doing it wrong? Or are my statements about lxml’s limitations regarding schema validation true?

To recap, I’d like to be able to:

  • have the parser use the schema location declarations in the instance document at parse/validation time
  • use multiple schemata to validate a xml document
  • declare schema locations on non-root elements (not of extreme importance)

Maybe I should look for a different library? Although, that’d be a real shame, – lxml is a de-facto xml processing library for python and is regarded by everyone as the best one in terms of performace/features/convenience (and rightfully so, to a certain extent)

  • 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-15T04:30:28+00:00Added an answer on May 15, 2026 at 4:30 am

    Caution: this is not the full answer to this, because I don’t know all that much about lxml in particular.

    In can just tell you that:

    • Ignoring schemalocations in documents and instead managing a namespace -> schema file mapping in an application is almost always better, unless you can guarantee that the schema will be in a very specific location compared to the file. If you want to move it out of code, use a catalogue or come up with a configuration file.
    • If you do want to use schemaLocation, and want to validate multiple schemas, just include them all in one schemaLocation attribute, separated by spaces, in namespace URI/location pairs: xsi:schemaLocation="urn:schema1 schema1.xsd urn:schema2 schema2.xsd.
    • Finally, I don’t think any processor will find schemaLocation attributes declared on non-root elements. Not that it matters: just put them all on the root.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Per documentation, Doctrine_Record after saving should set id of newly created record as object
Per the Java documentation, the hash code for a String object is computed as:
Per the documentation , String.Format will throw a FormatException if either (A) the format
The official documentation states: Raw byte size (GB) of all item IDs + 45
I am trying to integrate Google Analytics in my Activities. As per the official
Per title - I am using the official mongodb driver and I am looking
Per the SWIG Documentation (21.9.1 Default primitive type mappings), the C uint8_t is mapped
I have a GridView with 4 images per row, and normally has more than
Per protocol ref, windowWillReturnFieldEditor should be called for any text-displaying object when it needs
I implemented the official Creating the Blog Application project as per the directions given.

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.