Hello,
I've just discovered BaseX and decided to make some experiments. One of them is, suppose I have several documents (data + schemas), something like this:
sys/core.xsd
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:SYS-CORE" targetNamespace="urn:SYS-CORE"> <xs:attribute name="category" type="xs:normalizedString"/> </xs:schema>
lib/album.xsd
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:SYS-CORE ../sys/core.xsd" xmlns:sys="urn:SYS-CORE" xmlns="urn:LIB-ALBUM" targetNamespace="urn:LIB-ALBUM"> <xs:import namespace="urn:SYS-CORE"/> <xs:element name="album"> <xs:complexType> <xs:sequence> <xs:element ref="title" minOccurs="1" maxOccurs="1"/> </xs:sequence> <xs:attribute ref="sys:category" use="required"/> </xs:complexType> </xs:element> <xs:element name="title" type="xs:normalizedString"/> </xs:schema>
usr/albums/album1.xml
<?xml version="1.0"?> <album xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:LIB-ALBUM ../../lib/album.xsd" xmlns:sys="urn:SYS-CORE" sys:category="albums" xmlns="urn:LIB-ALBUM"> <title>Album #1</title> </album>
I'm uploading these documents using a Python script (I'm using BaseXClient) preserving the file system hierarchy structure I defined above. If I open the documents in IntelliJ IDEA, I can be sure that the documents are valid (I mean, I don't see XSD validation errors), therefore I'm assuming they are valid by fact. However, if I'm trying to validate the XML documents on the BaseX side
session.execute('XQUERY for $doc in collection("%s") where fn:ends-with(fn:base-uri($doc), ".xml") return validate:xsd($doc)' % database)
I'm getting the following error
[bxerr:BXVA0001] Validation failed: 1:186: schema_reference.4: Failed to read schema document '../../lib/album.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
I'm wondering, what am I doing wrong trying to validate documents directly in BaseX? Can BaseX resolve absolute/relative paths in this case?
Thanks in advance!
P.S. Apologies if I made something wrong (wrong subject, mailing list, non text/plain email, etc), this is my first time sending an email to a mailing list. P.P.S. This email may contain an ad footer since I use this free email service. If possible, please trim the ad away before it's sent/archived. Thanks!
-- реклама ----------------------------------------------------------- http://FREEhost.UA - Купи хостинг или домен и получи сертификат Google AdWords номиналом 900 грн.в подарок! - http://goo.gl/EcgF4I