FAQ
Hello all,

Is somebody has an example of the way to parse an xml file against a
"grammary" file.xsd.
The default parser is checking closing tags and attributes but I would
like to validate a XSD
file.

I use the module ElementTree.

Regards
Karim

Search Discussions

  • Karim at Dec 22, 2010 at 6:28 pm

    On 12/22/2010 07:07 PM, Karim wrote:
    Is somebody has an example of the way to parse an xml file against a
    "grammary" file.xsd.
    I found this:

    http://www.velocityreviews.com/forums/t695106-re-xml-parsing-with-python.html

    Stefan is it still true the limitation of etree in python 2.7.1 ?

    Regards
    Karim
  • Stefan Behnel at Dec 22, 2010 at 8:56 pm

    Karim, 22.12.2010 19:28:
    On 12/22/2010 07:07 PM, Karim wrote:

    Is somebody has an example of the way to parse an xml file against a
    "grammary" file.xsd.
    I found this:

    http://www.velocityreviews.com/forums/t695106-re-xml-parsing-with-python.html

    Stefan is it still true the limitation of etree in python 2.7.1 ?
    Yes, ElementTree (which is in Python's stdlib) and lxml.etree are separate
    implementations. If you want validation, use the lxml package.

    Stefan
  • Karim at Dec 22, 2010 at 9:09 pm
    Thanks Stefan for answering.
    That's what I come up with.

    Using lxml (except for the different import) will be fully compliant
    with the ET code.
    Do I have to adapt it?

    I saw your fantastic benchmarks! Why the hell lxml is not integrated
    into the stdlib.
    I thought they put in it things which works at best for python interest ?

    Regards
    Karim
    On 12/22/2010 09:56 PM, Stefan Behnel wrote:
    Karim, 22.12.2010 19:28:
    On 12/22/2010 07:07 PM, Karim wrote:

    Is somebody has an example of the way to parse an xml file against a
    "grammary" file.xsd.
    I found this:

    http://www.velocityreviews.com/forums/t695106-re-xml-parsing-with-python.html


    Stefan is it still true the limitation of etree in python 2.7.1 ?
    Yes, ElementTree (which is in Python's stdlib) and lxml.etree are
    separate implementations. If you want validation, use the lxml package.

    Stefan

    _______________________________________________
    Tutor maillist - Tutor at python.org
    To unsubscribe or change subscription options:
    http://mail.python.org/mailman/listinfo/tutor
  • Stefan Behnel at Dec 22, 2010 at 9:32 pm

    Karim, 22.12.2010 22:09:
    Using lxml (except for the different import) will be fully compliant with
    the ET code.
    Do I have to adapt it?
    There are certain differences.

    http://codespeak.net/lxml/compatibility.html

    This page hasn't been changed for ages, but it should still be mostly accurate.

    I saw your fantastic benchmarks! Why the hell lxml is not integrated into
    the stdlib.
    I thought they put in it things which works at best for python interest ?
    I proposed it but it was rejected with the argument that it's a huge
    dependency and brings in two large C libraries that will be hard to control
    for future long-term maintenance. I think that's a reasonable objection.

    Stefan
  • Karim at Dec 22, 2010 at 10:13 pm

    On 12/22/2010 10:32 PM, Stefan Behnel wrote:
    Karim, 22.12.2010 22:09:
    Using lxml (except for the different import) will be fully compliant
    with
    the ET code.
    Do I have to adapt it?
    There are certain differences.

    http://codespeak.net/lxml/compatibility.html

    This page hasn't been changed for ages, but it should still be mostly
    accurate.
    I will have a look. Anyway, I must delivered my current version.
    I got 300 lines of codes which should be easily translated for
    the improved future version.
    I saw your fantastic benchmarks! Why the hell lxml is not integrated
    into
    the stdlib.
    I thought they put in it things which works at best for python
    interest ?
    I proposed it but it was rejected with the argument that it's a huge
    dependency and brings in two large C libraries that will be hard to
    control for future long-term maintenance. I think that's a reasonable
    objection.
    One can never says never...
    They will reconsider it I think.

    Thanks for your support!
    Regards
    Karim

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouptutor @
categoriespython
postedDec 22, '10 at 6:07p
activeDec 22, '10 at 10:13p
posts6
users2
websitepython.org

2 users in discussion

Karim: 4 posts Stefan Behnel: 2 posts

People

Translate

site design / logo © 2022 Grokbase