Thanks Dave,
Okay - I see that; in the case of DsmlAttr in the DSMLv2.xsd; it is not
a top-level element, so there is no corresponding Document class.
In the case of this schema (ADDRESSES.xsd) - with XmlBeans 2.0.0 I don't
see ADDRESSESDocument.ADDRESS.Factory.
Has this part of the API has changed?
(I haven't used 1.x; just read samples).
--Kent
Dave Harrison wrote:
Kent,
I'm guessing that Foo is not a global element, so as it cannot form a
document root there is no FooDocument.Foo. As it can only represent a
fragment of an xml document it is wrapped with the <xml-fragment> tags.
For example, given the .xsd:
<xsd:complexType name="ADDRESS">
<xsd:sequence>
<xsd:element name="STREET" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ADDRESSES">
<xsd:sequence>
<xsd:element name="ADDRESS"
type="ADDRESS" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ADDRESSES" type="ADDRESSES" />
...and the code:
ADDRESSESDocument addressesDoc = ADDRESSESDocument.Factory.parse(new
File("doc.xml"));
ADDRESS address = addressesDoc.getADDRESSES().addNewADDRESS();
address.setSTREET("New Street Address");
System.out.println(address); // 1
System.out.println(addressesDoc); // 2
Will give you:
1. As ADDRESS is not a global element the out put here is:
<xml-fragment>
<xsip:STREET>New Street Address</xsip:STREET>
</xml-fragment>
2. ADDRESSES is a global element that can form a valid doc so the output
will be something like:
<ADDRESSES>
<ADDRESS>
<STREET>New Street Address</STREET>
</ADDRESS>
</ADDRESSES>
Dave.
Kent Spaulding wrote:
Thanks for the replies - I'll try to address both in this message.
1) I was just using print(foo) as short-hand. The xmlText is still
<xml-fragment>...</xml-fragment> ( I was really doing
System.out.println("footext = " + foo) )
2) In xmlbeans 2.0.0 there is no FooDocument.Foo.Factory chain of
objects; at least not for these schemas. (You can find the schema I'm
using at OASIS for DSML -
http://www.oasis-open.org/committees/dsml/docs/DSMLv2.xsd)
Basically, a DsmlAttr is used in a number of different Request
objects, e.g. AddRequest. So we have AddRequestDocument, and
AddRequest, as Java types, but no DsmlAttrDocument.
Further, there is no AddRequestDocument.AddRequest.Factory chain in
2.0.0.
Is there an API changes document from 1.0 to 2.0 document somewhere?
Thanks again - I really do appreciate the replies.
--Kent
Caroline Wood wrote:
I think what you need to do is:
FooDocument fooDocument = FooDocument.Factory.newInstance();
FooDocument.Foo foo = FooDocument.Foo.Factory.newInstance();
foo.setName("blah blah");
fooDocument.setFoo(foo);
print(fooDocument);
Give at a go and let us know what happens!
Best,
Caroline.
-----Original Message-----
From: Don Stewart [mailto:[EMAIL PROTECTED] Sent: 27 July 2005
09:59
To: [email protected]
Subject: RE: Creating complexType objects...
Kent,
In the first example replace print(foo); with print(foo.xmlText());
Regards
Don
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 26
July 2005 19:48
To: [email protected]
Subject: Creating complexType objects...
I've looked over all the doc, and archives, and haven't found if there's
an easier to do what I'd like in XmlBeans 2.0.0.
It looks like to create an XmlObject that has a name other than
"xml-fragment" in the first element, you need to go through an object
type that contains that type.
i.e. If I have Foo defined as a type with just a name attribute:
Foo foo = Foo.Factory.newInstance();
foo.setName("name");
print(foo);
gives:
<xml-fragment name="name"/>
If I want <foo name="name"/> as the xml - I need to find a type (let's
call it Bar) that encloses the Foo type and do:
Bar bar = Bar.Factory.newInstance();
Foo foo = bar.addNewFoo();
foo.setName("name");
foo.set(bar);
now foo is:
<foo name="name"/>
Is this really what's required?
If this made no sense; I can send a more concrete example.
Thanks for the help,
--Kent
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]