xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: v1: efficient detecting if XML can be mapped to XmlPbject ...
Date Mon, 22 Mar 2004 17:21:10 GMT
Yes, getFullJavaName will return the name of the class which implements
that type.

Calling findElement will return a SchemaGlobalElement, representing the
global element definition for schemas on your path.  You can get the
SchemaType from this with getType().

For every global element XmlBeans synthesizes a "Document Type".  The
document type is simply a type which has a content model which allows
for a single element of the name of the corresponding element.  This is
the type associated with the Document node of a document (as opposed to
the document element).

Every generated document type statically contains the type of the
element from which it was generated.  Thus, FooDocument.Foo.type should
be the same SchemaType that findElement( "Foo" ).getType() returns.

So, you need only call one of these fcns, but you need to know whether
you need the type of the global element, or the type of documents which
can contain this element.

- Eric

-----Original Message-----
From: Aleksander Slominski [mailto:aslom@cs.indiana.edu] 
Sent: Friday, March 19, 2004 4:32 PM
To: xmlbeans-dev@xml.apache.org
Subject: Re: v1: efficient detecting if XML can be mapped to XmlPbject
...

Eric Vasilik wrote:

>It is a bit more complicated than this.  Take a look at
>org.apache.xmlbeans.impl.store.Root.autoTypedDocument for the
>implementation which associates the SchemaType with an instance.
>
>Basically, this function looks for a document type if there is a single
>document element at the root.  If there is a single attribute at the
>root, then an attribute document type is looked up.  If there is an
>xsi:type associated with the root (the container of a document
element),
>then a global type is looked up.
>
>If your document being parsed is not a fragment and is well formed,
then
>simply looking for a document type is sufficient:
>
>    XmlBeans.getContextTypeLoader().findDocumentType( QName )
>
>
>  
>
hi Eric,

thanks for the answer.

however in my case i need to deal with XML fragments as i want to bind 
SOAP Body parts to XmlObjects if the binding can be done. so in this 
case i guess findElement() would work as it find global element names? 
including document types or i should call both?

also AFAIU i an do getFullJavaName() on the result to find what is 
mapped name of Java class implementing XML Schemas type?

thanks,

alek

>-----Original Message-----
>From: Aleksander Slominski [mailto:aslom@cs.indiana.edu] 
>Sent: Friday, March 19, 2004 3:31 PM
>To: xmlbeans-dev@xml.apache.org
>Subject: v1: efficient detecting if XML can be mapped to XmlPbject ...
>
>hi,
>
>one way to check if XML fragment can be mapped by XmlBeans to known 
>XmlObject is try to do it:
>
>   try {
>
>            XmlObject response = XmlObject.Factory.parse(xmlString);
>
>        } catch (XmlException e) {
>            //not supported
>        }
>
>is there some better method? (efficiency)?
>
>if i know QName of top element (or its xsi:type if present) will
>
>     
>if(XmlBeans.getContextTypeLoader().findType(javax.xml.namespace.QName) 
>!= null) { ... }
>
>be the best way to do such check?
>
>thanks,
>
>alek
>
>  
>


-- 
The best way to predict the future is to invent it - Alan Kay


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message