relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
228 stars 69 forks source link

Why RelaxNG validator reports an error on xmlns attribute? #272

Closed angelozerr closed 2 years ago

angelozerr commented 2 years ago

I'm starting to integrate Jing in your XML Language Server to provide validation and completion for RelaxNG. I tried this sample:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_lite.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?
<?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_lite.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Title</title>
      </titleStmt>
      <publicationStmt>
        <p>Publication information</p>
      </publicationStmt>
      <sourceDesc>
        <p>Information about the source</p>
      </sourceDesc>
    </fileDesc>
  </teiHeader>
  <text>
    <body>
      <p>Some text here.</p>
    </body>
  </text>
</TEI>

that we can found at https://digital-editing.fas.harvard.edu/editor/

And I have an error on xmlns attribute:

image

Do you think it is a bug from Jing or some Jing configuration which is not done correctly?

ndw commented 2 years ago

Are you sure you're parsing with namespace support enabled? What API are you using for parsing? The "attribute" named xmlns should not be reported as an attribute if namepace support is enabled.

angelozerr commented 2 years ago

Thanks so much @ndw for your comment. I fixed my problem and it was indeed a namespace. I use Xerces SAXParser and my configuration was

org.apache.xerces.parsers.SAXParser = ...
parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);

I changed to:

org.apache.xerces.parsers.SAXParser = ...
parser.setFeature("http://xml.org/sax/features/namespace-prefixes", false);

and now it works pefectly.

Thanks again @ndw !