Martin Thomas | 1 May 04:55

Re: Whoops, Internal Error

I have attached the file to be validated and the schema that was causing
a problem (there are 5 more schemas involved but I didn't think you
needed them - either download them or ask me to email them) as well as a
python script that I used to create the problem.

The output is as follows:
ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
xmlSchemaIDCRegisterMatchers, Could not find an augmented IDC item for
an IDC definition.
ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
xmlSchemaValidateElem, calling xmlSchemaValidateElemDecl().
ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
xmlSchemaDocWalk, calling xmlSchemaValidateElem().

The line number in ios.xml corresponds to a cpe-list that is defined in
the attached schema.  If I remove it from ios.xml, everything else
passes.

Cheers // Martin

 On Mon, 2007-04-30 at 11:12 -0500, martin <at> martinthomas.net wrote:
> Using the lxml rpm for FC6 and Python 2.4, I get an internal error  
> when I try validating a document against a XMLschema document.  The  
> xml document that I am trying to validate and the XMLschema which I am  
> validating against both came from NIST (contained in the 'Complete  
> 1.1.3 Schema Bundle .zip' at http://nvd.nist.gov/scap/xccdf/xccdf.cfm).
> 
> The error message reads Internal error: xmlSchemaIDCRegisterMatchers,  
> Could not find an augmented IDC item for an IDC definition.
> 
(Continue reading)

Stefan Behnel | 1 May 08:52
Picon
Favicon
Gravatar

Re: Whoops, Internal Error

Hi Martin,

a quick test (after renaming cpe-1.0.xsd to xccdf-1.1.xsd) didn't show any
problem with lxml trunk and libxml2 2.6.17. Since you didn't mention any of
the versions of lxml or libxml2 you are using, I assume it's just a problem
with an older libxml2 version. XML-Schema is still under development in
libxml2, so any newer version is likely to provide better support and bug
fixes. Please upgrade and retry.

Regards,
Stefan

Martin Thomas wrote:
> I have attached the file to be validated and the schema that was causing
> a problem (there are 5 more schemas involved but I didn't think you
> needed them - either download them or ask me to email them) as well as a
> python script that I used to create the problem.
> 
> The output is as follows:
> ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
> xmlSchemaIDCRegisterMatchers, Could not find an augmented IDC item for
> an IDC definition.
> ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
> xmlSchemaValidateElem, calling xmlSchemaValidateElemDecl().
> ios.xml:41:ERROR:SCHEMASV:SCHEMAV_INTERNAL: Internal error:
> xmlSchemaDocWalk, calling xmlSchemaValidateElem().
> 
> The line number in ios.xml corresponds to a cpe-list that is defined in
> the attached schema.  If I remove it from ios.xml, everything else
> passes.
(Continue reading)

martin | 1 May 16:06

Re: Whoops, Internal Error

Stefan,

I can reproduce this problem on Cygwin and Fedora Core 6 which have
libxml2 2.6.26 and 2.6.26 respectively.

Sorry if I have confused things by sending that schema doc.  There are
6 different schema documents involved:
xccdf-1.1.xsd
xccdfp-1.1.xsd
xml.xsd
platform-0.2.3.xsd
cpe-1.0.xsd
simpledc20021212.xsd

They are available from nist.gov in the zip file at the URL I gave earlier.
I only attached the CPE schema because the element causing the
internal error belongs in the CPE namespace and I didn't want to
attach documents that are publicly available.

As it turns out, this is an error in libxml2.. if I use xmllint, I get  
the same error message.  I'll send them a bug report.

Thanks // M

Quoting Stefan Behnel <stefan_ml <at> behnel.de>:

> Hi Martin,
>
> a quick test (after renaming cpe-1.0.xsd to xccdf-1.1.xsd) didn't show any
> problem with lxml trunk and libxml2 2.6.17. Since you didn't mention any of
(Continue reading)

Holger Joukl | 3 May 11:42
Picon
Picon

etree.XMLSchema generic error "Document is not valid XML Schema"

Hi,
is there any chance to expose more detailed information on why a schema
document is not a valid XML Schema?
A brief look at libxml2 schema API did not really tell me anything.

Regards,
Holger

_______________________________________________
lxml-dev mailing list
lxml-dev <at> codespeak.net
http://codespeak.net/mailman/listinfo/lxml-dev
Tres Seaver | 3 May 19:20
Gravatar

Re: etree.XMLSchema generic error "Document is not valid XML Schema"


Holger Joukl wrote:
> Hi,
> is there any chance to expose more detailed information on why a schema
> document is not a valid XML Schema?
> A brief look at libxml2 schema API did not really tell me anything.

Can you try validating it with xmllint?  If you get the same error
message, then the bug / problem is in libxml2, rather than lxml.

Tres.
--
===================================================================
Tres Seaver          +1 540-429-0999          tseaver <at> palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
jholg | 4 May 09:23
Picon
Picon

Re: etree.XMLSchema generic error "Document is not valid XML Schema"

Hi,

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Holger Joukl wrote:
> > Hi,
> > is there any chance to expose more detailed information on why a schema
> > document is not a valid XML Schema?
> > A brief look at libxml2 schema API did not really tell me anything.
> 
> Can you try validating it with xmllint?  If you get the same error
> message, then the bug / problem is in libxml2, rather than lxml.

This is not a bug in libxml2 nor lxml, it's a feature request. I know that the schema is not a valid schema, but
I'd like to see the reason why. lxml does currently not present any errors from the libxml2 layer when
instantiating a schema. If this is possible at all, I don't know.
Of course, it is always possible to use another tool, like a good schema editor, but for quick small hacks it
would be really convenient to see what you missed.

Holger
--

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
Erik Swanson | 4 May 18:23
Picon

lxml.sax.saxify breaks on comments; `make test` failure on MacPython 2.5.1

There appears to be a bug with lxml.sax's handling of comments, as the following code causes lxml.sax.saxify to fail:

"""
import lxml.etree , lxml.sax, xml.sax.handler
from cStringIO import StringIO

p = lxml.etree.HTMLParser(remove_blank_text=True)
h = xml.sax.handler.ContentHandler()
f = StringIO("<body><!-- foo --><p>bar</p></body>")
t = lxml.etree.parse(f, p)
lxml.sax.saxify(t, h)
"""

"""
Traceback (most recent call last):
  File "saxBug.py", line 11, in <module>
    lxml.sax.saxify(t, h)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 178, in saxify
    return ElementTreeProducer(element_or_tree, content_handler).saxify()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 130, in saxify
    self._recursive_saxify(self._element, {})
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 160, in _recursive_saxify
    self._recursive_saxify(child, prefixes)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 160, in _recursive_saxify
    self._recursive_saxify(child, prefixes)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 149, in _recursive_saxify
    ns_uri, local_name = _getNsTag(element.tag)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/lxml- 1.3beta-py2.5-macosx-10.4-i386.egg/lxml/sax.py", line 8, in _getNsTag
    if tag[0] == '{':
TypeError: 'builtin_function_or_method' object is unsubscriptable
"""

I have been able to replicate the above error with both release and svn lxml, as well as with both Apple-supplied libxml2/libxslt and up-to-date libraries.

Also, and I doubt this is related, but `make test` fails for me on OS X 10.4.9 with MacPython 2.5.1 (python.org binary):

"""
python test.py -p -v 

TESTED VERSION:
    Python:            (2, 5, 1, 'final', 0)
    lxml.etree :        (1, 3, -1, 42667)
    libxml used:       (2, 6, 28)
    libxml compiled:   (2, 6, 28)
    libxslt used:      (1, 1, 20)
    libxslt compiled:  (1, 1, 20)

 733/733 (100.0%): Doctest: xpathxslt.txt                                                                       
======================================================================
FAIL: test_module_HTML_unicode ( lxml.tests.test_htmlparser.HtmlParserTestCaseBase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/unittest.py", line 260, in run
    testMethod()
  File "/Users/erik/Projects/lxml/src/lxml/tests/test_htmlparser.py", line 33, in test_module_HTML_unicode
    self.uhtml_str)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/unittest.py", line 334, in failUnlessEqual
    (msg or '%r != %r' % (first, second))
AssertionError: u'<html><head><title>test \xc3\x83\xc2\xa1\xef\xa3\x92</title></head><body><h1>page \xc3\x83\xc2\xa1\xef\xa3\x92 title</h1></body></html>' != u'<html><head><title>test \xc3\xa1\uf8d2</title></head><body><h1>page \xc3\xa1\uf8d2 title</h1></body></html>'

----------------------------------------------------------------------
Ran 733 tests in 1.380s

FAILED (failures=1)
"""

--
Erik Swanson
_______________________________________________
lxml-dev mailing list
lxml-dev <at> codespeak.net
http://codespeak.net/mailman/listinfo/lxml-dev
Stefan Behnel | 4 May 19:26
Picon
Favicon
Gravatar

Re: lxml.sax.saxify breaks on comments; `make test` failure on MacPython 2.5.1

Hi,

Erik Swanson wrote:
> There appears to be a bug with lxml.sax's handling of comments, as the
> following code causes lxml.sax.saxify to fail:
> 
> """
> import lxml.etree , lxml.sax, xml.sax.handler
> from cStringIO import StringIO
> 
> p = lxml.etree.HTMLParser(remove_blank_text=True)
> h = xml.sax.handler.ContentHandler()
> f = StringIO("<body><!-- foo --><p>bar</p></body>")
> t = lxml.etree.parse(f, p)
> lxml.sax.saxify(t, h)
> """

ah, yes, thanks for the report. This is due to the way ElementTree handles
Element.tag for comments and processing instructions. They actually return
their factory functions and lxml.etree follows them for compatibility.

But the real problem is obviously in lxml.sax. It should handle comments
correctly. I'll fix it.

> Also, and I doubt this is related, but `make test` fails for me on OS X
> 10.4.9 with MacPython 2.5.1 (python.org <http://python.org> binary):
> 
> """
> python test.py -p -v 
> 
> TESTED VERSION:
>     Python:            (2, 5, 1, 'final', 0)
>     lxml.etree :        (1, 3, -1, 42667)
>     libxml used:       (2, 6, 28)
>     libxml compiled:   (2, 6, 28)
>     libxslt used:      (1, 1, 20)
>     libxslt compiled:  (1, 1, 20)
> 
>  733/733 (100.0%): Doctest: xpathxslt.txt                              
>                                         
> ======================================================================
> FAIL: test_module_HTML_unicode (
> lxml.tests.test_htmlparser.HtmlParserTestCaseBase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/unittest.py",
> line 260, in run
>     testMethod()
>   File "/Users/erik/Projects/lxml/src/lxml/tests/test_htmlparser.py",
> line 33, in test_module_HTML_unicode
>     self.uhtml_str)
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/unittest.py",
> line 334, in failUnlessEqual
>     (msg or '%r != %r' % (first, second))
> AssertionError: u'<html><head><title>test
> \xc3\x83\xc2\xa1\xef\xa3\x92</title></head><body><h1>page
> \xc3\x83\xc2\xa1\xef\xa3\x92 title</h1></body></html>' !=
> u'<html><head><title>test \xc3\xa1\uf8d2</title></head><body><h1>page
> \xc3\xa1\uf8d2 title</h1></body></html>'
> 
> ----------------------------------------------------------------------
> Ran 733 tests in 1.380s
> 
> FAILED (failures=1)
> """

Good to know. Not a big problem, but an annoying one, as it breaks the test
suite. I'll look into that, too.

Thanks for the reports,
Stefan
Stefan Behnel | 5 May 12:30
Picon
Favicon
Gravatar

prepending PIs and serialising them - finally

Hi,

since the problem came up again when fixing the SAX issue, I finally decided
that it was time for a way to prepend processing instructions to a tree.

Elements now have general methods 'el.addprevious(sibling)' and
'el.addnext(sibling)'. They move the new sibling either before or after the
element. The methods also check that you can't create a second root node next
to another (TypeError) and will discard the tail text if adding at the top
level. So they will (try to) prevent you from creating broken XML. Only PIs
and comments are allowed as siblings of a root node, but any element can be
used inside the tree.

While I was at it, I also fixed the issue with writing out comments and PIs
that are siblings of a root node. Note that only root nodes are special cased
here, so that you get the complete document if you serialise the root node.
Elements in the tree will not write out their siblings if you serialise them.

Another step towards a shining new lxml 1.3, I'd say. :)

Have fun,
Stefan
Stefan Behnel | 5 May 19:10
Picon
Favicon
Gravatar

feedback on XPath docs?

Hi all,

I happened to take a deeper skip over the XPath documentation page of lxml,
and since there was loads of stuff missing, I decided to give it half a
rewrite. Now I'm interested in feedback to see if it is understandable or if
any other important (or interesting) stuff is missing.

http://codespeak.net/lxml/dev/xpathxslt.html

Any comments?

Stefan

PS: feed back on the other doc pages will be appreciated, too. :)

Gmane