validate:xsd-report - resolving imports
Thursday, 7 August 2025 · 2 messages · last reply 8 Aug 2025
HR
Hans-Juergen Rennau7 Aug 2025 20:42 #
Dear BaseX people,
using function '
validate:xsd-report' I notice a surprising behaviour:
- if supplying the XSD via URI, it works as expected- if supplying the XSD as node, the imports cannot be resolved Is this a known behaviour and intended?
In case it is not, see PS for simple code reproducing the behaviour. Kind regards,Hans-Jürgen
PS:(1) doc.xml<doc b:att="99" xmlns:b="http://basex.org"/>(2) schema1.xsd<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b="http://basex.org" elementFormDefault="qualified"> <xs:import namespace="http://basex.org" schemaLocation="schema2.xsd"/> <xs:element name="doc"> <xs:complexType> <xs:attribute ref="b:att"/> </xs:complexType> </xs:element></xs:schema>
(3) schema2.xsd<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://basex.org" elementFormDefault="qualified"> <xs:attribute name="att" type="xs:integer"/></xs:schema>
(4) validate.xqvalidate:xsd-report('doc.xml', 'schema1.xsd'),'===',validate:xsd-report('doc.xml', doc('schema1.xsd'))CG
Christian Grün8 Aug 2025 07:12 #
Hi Hans-Jürgen,
Quoted text · Hans-Juergen Rennau · 6 lines
> using function 'validate:xsd-report' I notice a surprising behaviour: > > - if supplying the XSD via URI, it works as expected > - if supplying the XSD as node, the imports cannot be resolved > > Is this a known behaviour and intended?
Yes, this is known: Validation is done by an external process (i.e., not performed by BaseX itself). In order to pass supplied nodes to this pocess, they are serialized and written to a temporary file, which will have a different base URI.
We cannot simply supply the underlying base URI, as there is no guarantee that the resource will still exist, as illustrated by the following example:
let $schema := 'schema1.xsd', $schema-doc := doc($schema)
return (
file:delete($schema),
validate:xsd-report('doc.xml', $schema)
)Hope this helps,
Christian
Quoted text · Hans-Juergen Rennau · 34 lines
Von: Hans-Juergen Rennau via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Donnerstag, 7. August 2025 20:42 An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] validate:xsd-report - resolving imports Dear BaseX people, using function 'validate:xsd-report' I notice a surprising behaviour: - if supplying the XSD via URI, it works as expected - if supplying the XSD as node, the imports cannot be resolved Is this a known behaviour and intended? In case it is not, see PS for simple code reproducing the behaviour. Kind regards, Hans-Jürgen PS: (1) doc.xml <doc b:att="99" xmlns:b="http://basex.org"/> (2) schema1.xsd <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b="http://basex.org" elementFormDefault="qualified"> <xs:import namespace="http://basex.org" schemaLocation="schema2.xsd"/> <xs:element name="doc"> <xs:complexType> <xs:attribute ref="b:att"/> </xs:complexType> </xs:element> </xs:schema> (3) schema2.xsd <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://basex.org" elementFormDefault="qualified"> <xs:attribute name="att" type="xs:integer"/> </xs:schema> (4) validate.xq validate:xsd-report('doc.xml', 'schema1.xsd'), '===', validate:xsd-report('doc.xml', doc('schema1.xsd'))
Written for BaseX 12.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery