After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 387550 - xmllint displays incorrect line numbers for files over 65,535 lines in length
xmllint displays incorrect line numbers for files over 65,535 lines in length
Status: RESOLVED WONTFIX
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-19 16:02 UTC by John Cassidy
Modified: 2007-11-25 02:30 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description John Cassidy 2006-12-19 16:02:30 UTC
Please describe the problem:
I'm working with some very long xml files, some have a length of over 400,000 lines.  When I run xmllint it reports all the errors as occuring on line 65,535 (The maximum value of an unsigned 16 bit integer).

Steps to reproduce:
Generate an xml file along these lines

<?xml version="1.0" encoding="UTF-8"?>
<yadayada>
    <foo><bar/></foo>
    <foo><bar/></foo>
    <foo><bar/></foo>
    <foo><bar/></foo>
    <!-- and so on  -->
    
    <!-- then somewhere after 65,535 lines -->
    <foo>
        <this-causes-an-error/>
    </foo>
</yadayada>

This script may be used to generate this sort of file

#!/usr/bin/python

outFile=open('testLineNumbers.xml','w')

outFile.write("""<?xml version="1.0" encoding="UTF-8"?>
<yadayada>
""")

line="<foo><bar/></foo>\n"

# write a bunch of OK lines
for i in range(65540):
    outFile.write(line)
    
# write a bad line
outFile.write('<foo><this-causes-an-error/></foo>\n')

# write 10 more good lines
for i in range(10):
    outFile.write(line)


outFile.write('</yadayada>')
outFile.close()


Validate the file against this schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="yadayada">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="foo" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="foo">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="bar"/>
        </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>




Actual results:
You get the following error:

testLineNumbers.xml:65535: element foo: Schemas validity error : Element 'foo' [CT local]: The element content is not valid.
testLineNumbers.xml fails to validate

Looking at the line 65535 (vi +65535 testLineNumbers.xml) indicates that the line number is not the correct location of the error


Expected results:
Line number should be correct.  I'm guessing that the type of the variable that tracks the line number must be changed short to int or int to long.  The format specifier in the printf that displays this variable may also need to be changed.

Does this happen every time?
yes

Other information:
Comment 1 Daniel Veillard 2006-12-19 16:09:17 UTC
XSD validates a precompiled tree. The tree has only room for 16 bits,
I will not make an API/ABI incompatible change just for this. Try the
streaming version which works on an even flow for which 32bits may
be available
    xmllint --stream --schemas ...

Sorry WONTFIX otherwise, I will not change the tree structure for this.

Daniel
Comment 2 John Cassidy 2006-12-19 16:44:12 UTC
If I'm reading the man page correctly the --stream option only works when you are validating with either a DTD or a relaxNG schema.  Is there a workaround for use with a W3C schema?
Comment 3 Daniel Veillard 2006-12-19 17:17:30 UTC
make 100% sure you're using the latest version.
--stream does work with --schemas
at worse it's a documentation problem

Daniel
Comment 4 Sven Neuhaus 2007-10-10 15:00:34 UTC
Using --stream is not a valid workaround because it doesn't display the line numbers at all!? Is there another way to fix this?
Comment 5 Daniel Veillard 2007-10-12 09:13:58 UTC
See my answer on the list:
 http://mail.gnome.org/archives/xml/2007-October/msg00006.html

Daniel
Comment 6 Starlight 2007-11-25 02:30:12 UTC
John,

A simple patch to resolve the line number problem can
be found in bug 325533.

Regards