JAXB XJC编译器忽略XML Schema文档中的mixed = true [英] JAXB XJC compiler disregarding mixed=true on XML Schema documents

查看:129
本文介绍了JAXB XJC编译器忽略XML Schema文档中的mixed = true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XJC似乎完全忽略了我的XML Schema元素上的 mixed =true,因此不允许我提取文本内容。从下面的示例XML中,我需要能够提取标题文本。如果没有 mixed =true被识别,则不会创建访问者,也不会从XML中解组:

XJC seems to be completely ignoring mixed="true" on my XML Schema elements thereby not allowing me to extract text content. From the sample XML below, I need to be able to extract "Title Text." Without mixed="true" being recognized, no accessor is created nor is it unmarshalled from XML:

<?xml version="1.0" encoding="UTF-8"?>
<title xmlns="urn:hl7-org:v3" integrityCheck="true">Title Text</title>

这是一个完整但最小化的模式,用于演示问题:

Here's a complete but minimized schema that demonstrates the problem:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema targetNamespace="urn:hl7-org:v3"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns="urn:hl7-org:v3"
  xmlns:mif="urn:hl7-org:v3/mif"
  elementFormDefault="qualified">

  <xs:complexType name="ST" mixed="true">
  <xs:complexContent>
         <xs:restriction base="ED">
            <xs:sequence>
               <xs:element name="reference" type="xs:string" minOccurs="0" maxOccurs="0"/>
               <xs:element name="thumbnail" type="xs:string" minOccurs="0" maxOccurs="0"/>
            </xs:sequence>
            <xs:attribute name="compression" type="xs:string" use="prohibited"/>
         </xs:restriction>
      </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="ED" mixed="true">
    <xs:complexContent>
      <xs:extension base="BIN">
        <xs:sequence>
          <xs:element name="reference" type="xs:string" minOccurs="0" maxOccurs="1" />
          <xs:element name="thumbnail" minOccurs="0" maxOccurs="1" type="xs:string" />
            </xs:sequence>
        <xs:attribute name="compression" type="xs:string" use="optional" />
        <xs:attribute name="integrityCheck" type="xs:string" use="optional" />
        <xs:attribute name="integrityCheckAlgorithm" type="xs:string" use="optional" default="SHA-1" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="BIN" abstract="true" mixed="true">
    <xs:complexContent>
      <xs:extension base="ANY">
        <xs:attribute name="representation" use="optional" type="xs:string" default="TXT" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="ANY" abstract="true">
    <xs:attribute name="nullFlavor" type="xs:string" use="optional" />
  </xs:complexType>

  <xs:element name="title" type="ST" />
</xs:schema>

请注意,在上面我混合了=true。尽管如此,生成的模式片段不包含对它的引用,生成的类也不使用 XmlMixed 注释,也不使用值或内容访问器:

Note that in the above I have mixed="true". Despite that, the generated schema fragment doesn't contain a reference to it, nor does the generated class use the XmlMixed annotation, nor a value or contents accessor:

/**
 * <p>Java class for ST complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.                                                                                                                                              
 * 
 * <pre>
 * <complexType name="ST">
 *   <complexContent>
 *     <restriction base="{urn:hl7-org:v3}ED">
 *       <sequence>
 *         <element name="reference" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="0" minOccurs="0"/>
 *         <element name="thumbnail" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="0" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * </pre>
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ST")
public class ST
    extends ED
{
}

为什么XJC / JAXB完全无视我的混合内容字段?我已经尝试了JAXB 2.1和JAXB 2.2,但生成的代码中只有微不足道的差异。

Why is XJC / JAXB completely disregarding my mixed content fields? I have tried both JAXB 2.1 and JAXB 2.2 but only trivial differences are present in the generated code.

注意:我无法更改作为实际模式的模式是符合标准的医疗保健(HL7)模式。

Note: I can't change the schema as the actual schema is a standards-compliant healthcare (HL7) schema.

推荐答案

经过更多的研究,我只能得出结论这是我提交的一个错误。它被认为是 JAXB问题#792

After more research I could do nothing but conclude it was a bug which I filed. It was acknowledged as JAXB issue #792.

这篇关于JAXB XJC编译器忽略XML Schema文档中的mixed = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆