I'm trying to create grammars using the exificient-grammars library in Android 15 (c is context)
Grammars g = GrammarFactory.newInstance().createGrammars(c.getAssets().open("svg.xsd"));
from svg.xsd, which imports two more schemas: xlink.xsd and namespace.xsd. Those two files came along svg.xsd (as you can see they lie in the root directory along svg.xsd here). But instead of creating the grammars I get this exception:
com.siemens.ct.exi.exceptions.EXIException: Problem occured while building XML Schema Model (XSModel)!
. [xs-warning] schema_reference.4: Failed to read schema document 'xlink.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>.
. [xs-warning] schema_reference.4: Failed to read schema document 'namespace.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>.
The two lines of the svg.xsd
that use import are these:
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"/>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="namespace.xsd"/>
What I've tried so far:
- I've naively tried to merge the two xsd in the svg.xsd to only understand that I was simply unaware of how xsd files work.
- Followed the source up to
SchemaInformedGrammars.class
but I don't understand whatsystemId
is. - (edit) Following the suggestions of the support here (second post) I used
com.siemens.ct.exi.grammars.XSDGrammarsBuilder
to create the grammars:
XSDGrammarsBuilder xsd = XSDGrammarsBuilder.newInstance();
xsd.loadGrammars(c.getAssets().open("namespace.xsd"));
xsd.loadGrammars(c.getAssets().open("xlink.xsd"));
xsd.loadGrammars(c.getAssets().open("svg.xsd"));
SchemaInformedGrammars sig = xsd.toGrammars();
exiFactory.setGrammars(sig);
Only to get the exact same error...
My question: The problem seems to be that the parser cannot locate the two other files. Is there a way to include those files somehow so the parser can locate them?