Sent: Monday, November 26, 2018 at 11:30 PM
From: kgi <kgi@gmx.com>
To: "Christian Grün" <christian.gruen@gmail.com>
Subject: Re: [basex-talk] including xsd files
Hi Christian,
Thank you so much for your explanation and your code. That's really helpful.
cheers,
Kevin.
Sent: Monday, November 26, 2018 at 10:56 PM
From: "Christian Grün" <christian.gruen@gmail.com>
To: kgi@gmx.com
Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] including xsd files
Hi Kevin,
Validation with multiple schema files is currently limited to files on
hard disk. The reason is that we are using external libraries for
validation, which (at least for now) cannot locate files in a
database.
I have attached two sample files which demonstrate how you can
temporarily write referenced schema files to a temporary directory. If
you install the .xqm file in your BaseX repository, you can omit the
import location (at 'validation.xqm'). It’s just a stub as you’ll see;
depending on the characteristics of your schema files, you’ll need to
further enhance the provided code.
Best,
Christian
> I have run into the following problem. My XML coming from a client will be validated against XSD schema files. I would like to store the XSD documents in BaseX as well as the XML data. If I put the entire schema in one XSD file and add it to the database, all is fine and validate:xsd-info behaves as expected. However if I have two XSD files (a.xsd and b.xsd) and I include b.xsd in a.xsd with <xs:include.../>, validate:xsd-info returns an error:
> 7:40: src-resolve: Cannot resolve the name 'B' to a(n) 'type definition' component.
> where type B is defined in the included file.
>
> Is it possible to include a document stored in the database in this way?
>
> If you want more detail about what I tried it is below.
>
> Thanks!
> Kevin.
>
> What I tried:
>
> 1. start basexserver and launch basexgui (the commands below were executed in the gui)
>
> 2. create file a.xsd:
> <?xml version="1.0" encoding="UTF-8" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:include schemaLocation="b.xsd"/>
> <xs:element name="root">
> <xs:complexType>
> <xs:choice>
> <xs:element name="a" type="xs:string"/>
> <xs:element name="b" type="B"/>
> </xs:choice>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> 3. create b.xsd:
> <?xml version="1.0" encoding="UTF-8" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:complexType name="B">
> <xs:sequence>
> <xs:element name="c" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
> 4. create new database xsdtest in the gui
>
> 5. add the xsd files to the database:
> db:add("xsdtest", "//home/.../a.xsd")
> db:add("xsdtest", "//home/.../b.xsd")
>
> 6. run validation:
> validate:xsd-info('<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a.xsd"></root>', doc('/xsdtest/a.xsd'))
> As mentioned above, I get the error:
> 7:40: src-resolve: Cannot resolve the name 'B' to a(n) 'type definition' component.
>
> I tried with "schemaLocation" instead of "noNamespaceSchemaLocation"
> I tried having a.xsd include "/xsdtest/b.xsd" as well as just "b.xsd" (xsdtest is the DB name)
>