[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    [jira] Commented: (XMLBEANS-288) Doubled wrapper elements around
From:       "Radu Preotiuc-Pietro (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date:       2006-10-16 23:20:36
Message-ID: 1574899.1161040836076.JavaMail.jira () brutus
[Download RAW message or body]

    [ http://issues.apache.org/jira/browse/XMLBEANS-288?page=comments#action_12442745 \
]   
Radu Preotiuc-Pietro commented on XMLBEANS-288:
-----------------------------------------------

Actually this is completely by design.
I haven't looked at the AXIS bug (yet) but let me explain it on this example because \
it's simpler.

What happens is that when you do Foo foo = Foo.Factory.parse() it parses the XML that \
you pass in as the _content_ of the Foo type. say foo is declared like:
<complexType name="foo">
  <sequence>
    <element name="a" type="string"/>
  </sequence>
</complexType>

and you pass in:
<a>text</a>

then you have an instance of the Foo type which matches it's content model. that can \
be assigned to any element of type Foo, like in

<element name="foo" type="tns:foo"/>
<element name="bar" type="tns:foo"/>

fooDoc.setFoo(foo);
results in <foo><a>text</a></foo>

barDoc.setBar(foo);
results in <bar><a>text</a></bar>

The fact that the type is called "Foo" has no influence on the resulting document, \
which is what you'd expect from an XML Schema-compliant product.

The thing however that makes it a little confusing is that XMLBeans binds "anything" \
to the Foo type even if it doesn't match the content of the type (which is useful in \
other scenarios). You can however call foo.validate() to check that the document was \
actually valid.

So I would say based on how many "foo" tags you want (nothing stops you from having a \
schema like: <complexType name="foo">
  <sequence>
    <element name="foo" type="string"/>
  </sequence>
</complexType>
<element name="foo" type="tns:foo"/>
in which case you really want two "foo" tags) decide whether it's appropriate to \
parse using Foo and save using FooDocument or use another combination as appropriate.


> Doubled wrapper elements around XMLBeans-generated XML
> ------------------------------------------------------
> 
> Key: XMLBEANS-288
> URL: http://issues.apache.org/jira/browse/XMLBEANS-288
> Project: XMLBeans
> Issue Type: Bug
> Components: Binding, Compiler, DOM, XmlObject
> Affects Versions: Version 2.1
> Environment: Windows XP, Apache Axis2 Nightly build
> Reporter: Derek Foster
> 
> This issue is a copy and slight restatement of AXIS2-1129, copied here because it \
> apparently is an XMLBeans problem which has little to do with AXIS2 per se. Please \
> consult AXIS2-1129 to see some of the analysis history and discussion of this bug, \
> as well as a proposed workaround. The essence of this bug is that the following \
> code (consisting of a generated Foo type parsed from an XML schema, and a generated \
> FooDocument type which represents an XML document whose top-level element is a Foo \
> instance): Foo foo = Foo.Factory.parse("<foo>Stuff</foo>")
> FooDocument fooDocument = FooDocument.Factory.newInstance();
> fooDocument.setFoo(foo);
> System.out.println(fooDocument.toString());
> that the output of this is similar to this:
> <foo><foo>Stuff</foo><foo>
> when it should be this:
> <foo>Stuff</foo>
> Also note that the workaround proposed in AXIS2-1129 by Dims seems to involve \
> having to modify the XML schema to use qualified references to access various parts \
> of itself, in ways that should be totally invisible to any standards-abiding XML \
> schema parser. (It should make no difference if the schema uses qualified \
> references or not if the meaning is unchanged) which might possibly indicate \
> another bug.

-- 
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.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic