(no subject)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

(no subject)

Sandy McPherson
I am using JAXB to marshall an object.  I validate the JAXB object against
the schema before marshalling it to activeMQ and the validation passes.

The debugger in eclipse shows

nameInfoGrp NAMEINFOGRP  (id=60)
        name "" (id=65)
        type "DISPLAY" (id=66)

The XML produced is

<NAMEINFOGRP type=“DISPLAY>
        <NAME/>
</NAMEINFOGRP>

Apache CXF is unmarshalling at the other end and something is complaining
that that "NAME is missing". IMHO it is not missing it's content is empty.
I can see nothing in the schema which says the content of the NAME element
can't be the empty string, but perhaps I'm wrong.

Can anyone confirm or deny which validator is correct. (I have a feeling
that the validation of the NAME in the CXF is not a pure schema
validation, but I don't have access to the code or a proper SAX parser
exception so I can't tell).

Here is the relevant snippet of the schema:

        <xs:complexType name="NAMEINFOGRP">
                <xs:sequence>
                        <xs:element name="NAME">
                                <xs:simpleType>
                                        <xs:restriction base="xs:string">
                                                <xs:whiteSpace value="collapse"/>
                                        </xs:restriction>
                                </xs:simpleType>
                        </xs:element>
                </xs:sequence>
                <xs:attribute name="TYPE" use="required">
                        <xs:annotation>
                                <xs:documentation>Restriction:
"DISPLAY"
"ACCOUNT"
"MPS"</xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                                <xs:restriction base="xs:string">
                                        <xs:enumeration value="DISPLAY"/>
                                        <xs:enumeration value="ACCOUNT"/>
                                        <xs:enumeration value="MPS"/>
                                </xs:restriction>
                        </xs:simpleType>
                </xs:attribute>
        </xs:complexType>


JAXB has generated:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NAMEINFOGRP", propOrder = {
    "name"
})
public class NAMEINFOGRP {

    @XmlElement(name = "NAME", required = true)
    protected String name;
    @XmlAttribute(name = "TYPE", required = true)
    protected String type;

    /**
     * Gets the value of the name property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getNAME() {
        return name;
    }

    /**
     * Sets the value of the name property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setNAME(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the type property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getTYPE() {
        return type;
    }

    /**
     * Sets the value of the type property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setTYPE(String value) {
        this.type = value;
    }
}


Loading...