いくつかの異なるスキーマに対してXMLファイルを検証しようとしています(不自然な例についてはお詫びします)。
- a.xsd
- b.xsd
- c.xsd
特にc.xsdはb.xsdをインポートし、b.xsdはa.xsdをインポートします。
<xs:include schemaLocation="b.xsd"/>
私は次の方法でXercesを介してこれを行おうとしています:
XMLSchemaFactory xmlSchemaFactory = new XMLSchemaFactory();
Schema schema = xmlSchemaFactory.newSchema(new StreamSource[] { new StreamSource(this.getClass().getResourceAsStream("a.xsd"), "a.xsd"),
new StreamSource(this.getClass().getResourceAsStream("b.xsd"), "b.xsd"),
new StreamSource(this.getClass().getResourceAsStream("c.xsd"), "c.xsd")});
Validator validator = schema.newValidator();
validator.validate(new StreamSource(new StringReader(xmlContent)));
しかし、これは3つのスキーマすべてを正しくインポートできず、名前'blah'をa(n)'group'コンポーネントに解決できません。
Pythonを使用してこれを正常に検証しましたが、Java6.0とXerces2.8.1で実際の問題が発生しています。ここで何が問題になっているのか、またはXMLドキュメントを検証するためのより簡単なアプローチを誰かが提案できますか?