Not sure why you have the doctype declaration in there... perhaps your parser is missing XMLSchema.dtd? In my xml.xsd there is no such declaration, I fetched it from https://www.w3.org/2001/xml.xsd
Best, Daniel
Von: BaseX-Talk basex-talk-bounces@mailman.uni-konstanz.de Im Auftrag von Hans-Juergen Rennau Gesendet: Mittwoch, 31. August 2022 21:21 An: BaseX basex-talk@mailman.uni-konstanz.de Betreff: [basex-talk] Problem with validate:xsd-report
Dear BaseX people,
I encounter a problem with validate:xsd-report(), more particular with using a schema importing the well-known xml.xsd. The imported attribute declaration (xml:base) is not found.
I am pretty sure that it is my fault, but I just can't find my error - could you take a look?
(1) Document: doc.xml
<book xml:base="/a/b/c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd"> <author>xyz</author> </book>
(2) Schema: schema.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> <xs:element name="book"> xs:complexType xs:sequence <xs:element name="author" type="xs:string"/> </xs:sequence> <xs:attribute ref="xml:base"/> </xs:complexType> </xs:element> </xs:schema>
(In the same folder, a downloaded copy of xml.xsd is stored - for a snippet, see PS)
(3) Query: validate.xq
let $doc := 'doc.xml' let $xsd := 'schema.xsd' return validate:xsd-report($doc, $xsd)
(4) Result:
basex validate.xq => <report> <status>invalid</status> <message level="Fatal" line="9" column="43" url="file:/C:/projects/d2type/jats/test-validation/schema.xsd">src-resolve: Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component. </message> </report>
I do not understand why the import seems to be ignored. Validating with oXygen works fine, but I suppose that oXygen ignores the @schemaLocation.
If you see the reason, please let me know.
Cheers, Hans-Jürgen
PS: Snippet from xml.xsd, stored in the same folder:
<?xml version='1.0'?> <!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" > <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en"> ... <xs:attribute name="base" type="xs:anyURI"> xs:annotation xs:documentationSee http://www.w3.org/TR/xmlbase/ for information about this attribute.</xs:documentation> </xs:annotation> </xs:attribute> ... </xs:schema>