I'm generating OpenOffice XML using JAXB, and need to apply an xml:space="preserve"
attribute to a t
element.
我使用JAXB生成OpenOffice XML,并需要应用XML:space=“保存”属性到t元素。
<r>
<t>
foo
</t>
</r>
Should be
应该是
<r>
<t xml:space="preserve">
foo
</t>
</r>
I've used JAXB to generate Java classes from Open Office schemas. <t>
type is represented as a String in the CTRElt Java class, so there is no way to set this attribute. When I unmarshall from an existing document and marshall, previously existing space
attributes are no longer present.
我使用JAXB从开放的办公模式生成Java类。
The relevant portions of the schema are as follows:
模式的相关部分如下:
<xsd:element name="t" type="ST_Xstring" minOccurs="1" maxOccurs="1"> <xsd:annotation> <xsd:documentation>Text</xsd:documentation> </xsd:annotation> </xsd:element>
<xsd:simpleType name="ST_Xstring"> <xsd:annotation> <xsd:documentation>Escaped String</xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:string" /> </xsd:simpleType>
simpleType名称="ST_Xstring">
How can I generate XML which has this required space
attribute? Modifying the schema is not an option. Do I need to customize JAXB?
如何生成具有所需空间属性的XML ?修改模式不是一个选项。需要自定义JAXB吗?
1 个解决方案
#1
0
I ended up generating the XML and using a regex to add the attribute :(
最后生成了XML,并使用regex添加属性:(
#1
0
I ended up generating the XML and using a regex to add the attribute :(
最后生成了XML,并使用regex添加属性:(