Referencing a XSD schema within jar file

后端 未结 1 1465
眼角桃花
眼角桃花 2020-12-06 02:11

I have two schema files one is imported from the other. When executing the code in Eclipse schemas are found but when executing the code from jar schema files are not found

1条回答
  •  一生所求
    2020-12-06 02:29

    If Liso.xsd is importing LisoXml.xsd, then it is just sufficient to define Liso.xsd to the schema factory as shown below. The api is smart enough the load the imported/included schema(s).

    SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema")
    Schema compiledSchema = schemaFactory.newSchema(getClass().getClassLoader().getResource("Liso.xsd"))
    

    I verified this worked on both 1.5 and 1.6. On 1.6, you might hit in to this issue as well if using DOM.

    0 讨论(0)
提交回复
热议问题