java如何使用Xpath读取更多XSD模式?
我首先有两个XSD模式。xsd和second。xsd 首先。xsd是:
<xs:include schemaLocation="second.xsd" />
我想用秒来读取元素。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")); }
问题是程序并没有在秒中找到元素列表。xsd。 我可以这样定义一些吗
Document xmlDocument = builder.parse(new FileInputStream("first.xsd","second.xsd"));
是作为LSResourceResolver的东西,但这是用于验证的。 我可以用它来写代码吗? 谢谢你的建议
共 (0) 个答案