0

我正在使用 Apache Xerces 来解析 xml,由于某些原因,我需要找到一个元素在 xsd 中定义了多少个属性。element.getAttributes 只是给了我所有存在的属性。任何想法 ?

4

1 回答 1

1
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
XSImplementation impl = (XSImplementation) registry.getDOMImplementation("XS-Loader");
XSLoader schemaLoader = impl.createXSLoader(null);
XSModel xsModel = schemaLoader.loadURI(xsdResource.getURL().getPath());
((XSComplexTypeDecl) xsModel.getComponents(XSTypeDefinition.COMPLEX_TYPE).itemByName(xsdName, "typeName")).getAttrGrp().getAttributeUses();
于 2013-05-16T08:06:39.877 回答