oreillymedia / HTMLBook

Let's write books in HTML!
http://oreillymedia.github.io/HTMLBook
MIT License
650 stars 100 forks source link

WXS schema schema/htmlbook.xsd failed to compile (ailed to load external entity "http://www.w3.org/2001/xml.xsd") #217

Open dac514 opened 6 years ago

dac514 commented 6 years ago

Steps to reproduce:

git clone https://github.com/oreillymedia/HTMLBook.git
cd HTMLBook
xmllint --noout --schema schema/htmlbook.xsd samples/alices_adventures_in_wonderland.html

Output:

warning: failed to load external entity "http://www.w3.org/2001/xml.xsd"
schema/svg/xlink.xsd:27: element import: Schemas parser warning : Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'http://www.w3.org/2001/xml.xsd'. Skipping the import.
schema/svg/xlink.xsd:171: element attribute: Schemas parser error : attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}lang' does not resolve to a(n) attribute declaration.
schema/svg/SVG.xsd:337: element attribute: Schemas parser error : attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}base' does not resolve to a(n) attribute declaration.
schema/svg/SVG.xsd:343: element attribute: Schemas parser error : attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}lang' does not resolve to a(n) attribute declaration.
schema/svg/SVG.xsd:344: element attribute: Schemas parser error : attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}space' does not resolve to a(n) attribute declaration.
schema/svg/SVG.xsd:1389: element attribute: Schemas parser error : attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}space' does not resolve to a(n) attribute declaration.
WXS schema schema/htmlbook.xsd failed to compile

Help?

dac514 commented 6 years ago

In schema/svg/xlink.xsd, changing:

<xs:import namespace="http://www.w3.org/XML/1998/namespace" 
schemaLocation="http://www.w3.org/2001/xml.xsd"/>

To:

<xs:import namespace="http://www.w3.org/XML/1998/namespace" 
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>

Resolves the issue but I'm not sure this is right? I'm a bit surprised http://www.w3.org/2001/XMLSchema would vanish?

gimsieke commented 6 years ago

I’d rather use the file that is guaranteed to remain available (unless someone removes it from this repo), xml.xsd. See PR #218

jenstroeger commented 3 years ago

I think I just encountered a similar problem using Python and lxml:

Python 3.7.9 (default, Sep  6 2020, 16:32:30) 
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml.etree
>>> lxml.etree.XMLSchema(file="htmlbook.xsd")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/lxml/xmlschema.pxi", line 88, in lxml.etree.XMLSchema.__init__
lxml.etree.XMLSchemaParseError: attribute use (unknown), attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}lang' does not resolve to a(n) attribute declaration., line 171

@gimsieke*, your suggested workaround didn’t work for me, but considering that svg/xml.xsd is checked into the repo I changed this line

https://github.com/oreillymedia/HTMLBook/blob/465453a7663609d241045288a3d6a619e8079fa2/schema/svg/xlink.xsd#L27

to

 <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>

and I could load the schema file:

>>> lxml.etree.XMLSchema(file="htmlbook.xsd")
<lxml.etree.XMLSchema object at 0x10f913a70>

————— * Hallo nach Leebsch vonnem annern Sachsn! ☺️

gimsieke commented 3 years ago

Isn’t that exactly what I suggested in https://github.com/gimsieke/HTMLBook/commit/04ab437ea32962e84d817c5d7d776a6d2caf8f96, mei Guudsder?

jenstroeger commented 3 years ago

Indeed you did 👍🏼 (Nu klor!)