You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Dogan Atay <DA...@aflac.com> on 2005/01/10 15:12:35 UTC

How to determine which Document to use

Hi,

I just switched from JaxMe to XMLBeans and here is my first question
already.

 

I have a schema with several global elements.  When compiled I end up with
several XXXDocument classes.

 

I have written a client that has a method like this

 

public Object getObject(String xml)

{

}

 

What I want to do here is 

1)       determine which XXXDocument class to use to parse this xml.

2)       parse the xml with that XXXDocument.factory and return the
XXXDocument

 

I could not find a clean way to do this.

 

2 clumsy solutions come to my mind but I am wondering if any of you have a
better solution.

 

In the fist solution I search the xml string for a tag named by my global
element.

In the second solution I create a list of available Document.Factory classes
and parse the xml using each of them until I receive no XmlException.

 

How else can I determine which Document.Factory to use?

 

Thanks,

 

Dogan Atay