简体   繁体   中英

How to automatically add xsd:attribute to xsd:complexType in Apache XMLBeans?

We're running into some trouble with supplied XSDs of the following kind:

<xsd:complexType name="foo">
    ...
    <xsd:attribute name="version" fixed="1" />
</xsd:complexType>

The XML-Result is then expected look something like this:

<foo version="1">...</foo>

Since this is not how fixed attribute values are actually supposed to work XMLBeans will not generate such a result for us by default. We have hundreds of XSDs like this with varying versions and want to avoid adding them all by hand.

Does anyone know of a way to programmatically determine the values of fixed attributes of a given XMLObject so we can add them generically?

如上面Petru Gardea的评论所提供的文档中所述,您可以使用SchemaTypeSystem访问有关XMLObjects模式,其属性及其默认值的信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM