gpt4 book ai didi

java - XSD XSOM : How to parse xs:anyAttribute using XSOM Java library?

转载 作者:行者123 更新时间:2023-12-01 05:05:14 25 4
gpt4 key购买 nike

我正在尝试解析这个复杂类型,但无法使用 XSOM JAVA 获取

知道如何解析它吗?

      <xsd:sequence>

<xsd:any namespace="##other" processContents="lax" maxOccurs="unbounded"/>

</xsd:sequence>

<xsd:anyAttribute namespace="##other" processContents="lax"/>

最佳答案

假设此测试 XSD:

<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="test">
<xsd:sequence>
<xsd:any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute namespace="##other" processContents="lax"/>
</xsd:complexType>
</xsd:schema>

您需要此代码:

    XSOMParser parser = new XSOMParser();
//parser.setErrorHandler(...);
//parser.setEntityResolver(...);

parser.parse(new File(...));

XSSchemaSet sset = parser.getResult();
XSComplexType xt = sset.getComplexType("http://tempuri.org/XMLSchema.xsd", "test");
XSWildcard anyAttr = xt.getAttributeWildcard();

关键是getAttributeWildcard API。

关于java - XSD XSOM : How to parse xs:anyAttribute using XSOM Java library?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12816033/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com