

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
16 messages in org.apache.xmlbeans.userRe: Creating complexType objects...| From | Sent On | Attachments |
|---|---|---|
| Kent Spaulding | Jul 26, 2005 11:47 am | |
| Don Stewart | Jul 27, 2005 1:58 am | |
| Caroline Wood | Jul 27, 2005 2:01 am | |
| Kent Spaulding | Jul 27, 2005 8:05 am | |
| Cezar Andrei | Jul 27, 2005 9:55 am | |
| Dave Harrison | Jul 27, 2005 10:09 am | |
| steph | Jul 27, 2005 10:41 am | |
| Dave Harrison | Jul 27, 2005 11:09 am | |
| Kent Spaulding | Jul 27, 2005 11:28 am | |
| Stephane Morucci | Jul 27, 2005 11:29 am | |
| Kent Spaulding | Jul 27, 2005 11:44 am | |
| Cezar Andrei | Jul 27, 2005 2:10 pm | |
| Dave Harrison | Jul 27, 2005 2:44 pm | |
| Kent Spaulding | Jul 27, 2005 3:31 pm | |
| Dave Harrison | Jul 28, 2005 5:43 am | |
| Kent Spaulding | Jul 28, 2005 9:56 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: Creating complexType objects... | Actions... |
|---|---|---|
| From: | Dave Harrison (dav...@stacker.me.uk) | |
| Date: | Jul 28, 2005 5:43:57 am | |
| List: | org.apache.xmlbeans.user | |
Hi Kent,
What you do to build the XMLDoc? Use a text editor?
Yep. The examples I used were cut and paste from a previous post with some free hand editing in the mail client, so apologies if there are any slight errors.
In my case, I build messages to send over, for example, http by using the bindings - I don't have a doc to parse, I want to create that doc using the code.
When creating documents via XmlBeans I use __Document.newInstance() then add the elements via the generated API calls...
But none of the elements that I want to send in the xs:any body of my request is a top-level globally defined element, so I cannot create them through that idiom (doc.interface.factory) anyway.
...(or XmlCursors when I have to).
WRT to parsing - how do you know the type of the object in advance?
XmlObject.Factory.parse() will try to map to the correct type as long as the generated types can be found on the classpath. I've never had to deal with unknown document types in the real world, only unknown and invalid types within those documents, so I've never actually put this into real code, other than the early days when I always parsed via XmlBeans (through ignorance), but I still knew the Document type.
However, after the reading the javadoc for the SchemaType interface I'd try something like this: (comments from the javadocs)
XmlObject obj = XmlObject.Factory.parse(xmlString); if(AddRequest.type.isAssignableFrom(obj.type) // True if the specified type derives from this type (or if it is the same type). { AddRequest addRequest = (AddRequest)obj.changeType(AddRequest.type); //Changes the schema type associated with this data and returns a new XmlObject instance whose schemaType is the new type. } etc.
As I said, I've never done this, but it seems to be what the docs suggest. I'll try to find some time to play with this over the weekend as I'm sure I'll need it one day! Any feedback would be appreciated too.
Thanks,
Dave.







