我有2个XSD架构first.xsd和second.xsd 在first.xsd中是:
<xs:include schemaLocation="second.xsd" />
我希望在second.xsd中读取元素。 我已定义:
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document xmlDocument = builder.parse(new FileInputStream("first.xsd"));
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList result1 = null;
result1 = (NodeList) xPath.compile("//element[@name='List']").evaluate(xmlDocument, XPathConstants.NODESET);
for (int k = 0; k < result1.getLength(); k++) {
Element ele = (Element)result1.item(k);
System.out.println(ele.getAttribute("type")); }
问题是程序没有在second.xsd中找到元素列表。 我能定义一些吗?
Document xmlDocument = builder.parse(new FileInputStream("first.xsd","second.xsd"));
是LSResourceResolver,但是用于验证。 我可以将它用于我的代码吗? 谢谢你的建议。