[ http://issues.apache.org/jira/bro
wse/XMLBEANS-220?page=comments#action_12431672 ]
Radu Preotiuc-Pietro commented on XMLBEANS-220:
-----------------------------------------------
Glad it works now!
Schema compliance is too general a word to use. XMLBeans
does guarantee Schema compliance in the sense that if you
pass in a Schema, it is processed if correct and then XML
documents are correctly validated against it, which is kind
of the essence of Schema.
What's not guaranteed is that generating documents from
scratch by using APIs will result in valid documents, which
is far less problematic of a restriction. The main idea
behind this is that people may want to generate invalid
documents for various reasons (like intermediate revisions
of a document that is not yet final). While in general it is
prohibitively difficult to ensure that all documents
generated are valid, it would be possible to add an option
so that some reasonable attempts are made at serializing
something that is valid, that would be useful.
> XmlObject.xmlText(XmlOptions) outputs
xsi:nil="true" where schema definition is
minOccurs="0" and default value for
nillable="false"
>
------------------------------------------------------------
------------------------------------------------------------
------------
>
> Key: XMLBEANS-220
> URL: htt
p://issues.apache.org/jira/browse/XMLBEANS-220
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject
> Affects Versions: Version 2
> Environment: Windows XP, JDK 1.4.2_05
> Reporter: James Webster
>
> We have defined a type in the schema as...
> <xsd:complexType name="MyType">
> <xsd:element name="mandatoryElement"
type="xsd:string"/>
> <xsd:element name="optionalElement"
minOccurs="0" type="xsd:string"/>
> </xsd:complexType>
> According to the XML Schema specification, false is the
default value for the optional 'nillable' attribute on
xsd:element. So the 'optionalElement' element is
nillable='false'.
> We instantiate an instance of the MyType class, set the
mandatory element and get the value of xmlText()...
> MyType type = MyType.Factory.newInstance();
> type.setMandatoryElement("someValue");
> String xmlText = type.xmlText();
> The value of xmlText generated by XMLBeans v2.0 is...
> <MyType>
>
<mandatoryElement>someValue</mandatoryElement>
> <optionalElement xsi:nil="true"/>
> </MyType>
> BUT, we would expect (given that optionalElement is NOT
nillable) to see the following...
> <MyType>
>
<mandatoryElement>someValue</mandatoryElement>
> </MyType>
> Our investigations into the XMLBeans API suggests that
it is not possible (via XmlOptions, etc) to suppress the
xsi: attributes, so we believe this may be a bug? We are at
no point explicitly setting the optionalElement to null.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the
administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atl
assian.com/software/jira
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe xmlbeans.apache.org
For additional commands, e-mail: dev-help xmlbeans.apache.org
|