在使用 JAXB 取消编组时,从 xml 模式中的 <xs:schema 获取版本号



我有一个xml模式:

<xs:schema xmlns:xs=... version="1.0">

使用 JAXB 解组后如何获取版本号?

我试过使用它:

<xs:element name="schemaVersion" type="xs:string"/>
<xs:element name="echoSchemaVersion">
<xs:complexType>
<xs:sequence>
<xs:element ref="schemaVersion"/>
</xs:sequence></xs:complexType></xs:element></xs:schema>

我缺少将我的元素连接到

这可能是一个解决方案。

我在解组后通过将其添加为属性将架构版本设置为常量

<xs:attribute name="schemaver" type="xs:string" fixed="1.2">
<xs:annotation><xs:appinfo><jx:property fixedAttributeAsConstantProperty="true"/>
</xs:appinfo></xs:annotation></xs:attribute>

我还必须在模式根元素中添加 jx:version="2.1"。

相关内容

最新更新