You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by a_...@comcast.net on 2007/05/22 05:06:00 UTC

How to discover doc type and cast accordingly

Hi,

I'm pretty new to xmlbeans, have couple questions that may seem pretty basic...

Assuming I am Parsing an xml instance using :

XmlObject xobj = XmlObject.Factory.parse(myinstance)

I now want to :

1. ) discover what is the specific document type (CherryDocument, AppleDocument, etc) and 2) Once I know the specific doc type, cast the generic XmlObject accordingly.

Constraints:
a) the code can have no knowledge of any document types, therefore i cannot go thru a series of "instanceof" to check what the incoming type is, because I cannot know what types even exist.

So, I am hoping to do something like

XmlObject xobj = XmlObject.Factory.parse(myinstance)

type = xobj.getDocType( );

Class type = (type)xobj;


...or similar. When I do getClass, it comes up with something like PineappleDocumentImpl, from which i need the PineappleDocument.

I am having tough time figuring how to work this with Class.forName and similar to make this happen. How can i get the specific document type from XmlObject  then cast the instance to that specific type?    Any hints?

Thanks,

Alan J.



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