Re: Converting from using scomp to SchemaTypeLoader.parse(...)

badger mailinglist <[email protected]> Tue, 15 Jan 2013 13:55:34 +0000
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <CAF7=XdgwV6B6wjuJZiQ-4tY4BRc1F78uNi47PskAeUMtPZYC6Q@mail.gmail.com>
--e89a8fb20078a67d6f04d3541da5
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Thanks Paul and Jacob, I guess I didn't quite read through the tutorials
far enough. It's all working now I'm *actually* compiling the xsd.

Thanks again,

Badger.


On 14 January 2013 23:27, Paul Gillen <[email protected]> wrote:

> Boy, I wish I got paid for this crap.****
>
> ** **
>
> Full answer here:
> http://www.oracle.com/technetwork/articles/entarch/incremental-compilatio=
n-xmlbeans-089127.html
> ****
>
> ** **
>
> In your first example you had compiled your schema and created an object
> to describe parsed XML.****
>
> ** **
>
> In you second example you parsed the XSD, which is after all XML, and,
> surprise, it=92s described by W3C XSD.****
>
> ** **
>
> What you want to do, and I would be interested in hearing why, is to
> compile the XSD on the fly.****
>
> ** **
>
> The output of the example below is:****
>
> D=3DTestSchema****
>
> D=3Dschema@http://www.w3.org/2001/XMLSchema****
>
> D=3DTestSchema****
>
> where the first is your first example, the second is your second example,
> and the third is from compiling the XSD on the fly.****
>
> ** **
>
> Hope this helps.****
>
> ** **
>
> Cheers,****
>
> Paul****
>
> ** **
>
> *package* com.riveralph;****
>
> ** **
>
> *import* java.io.File;****
>
> ** **
>
> *import* noNamespace.TestSchemaDocument;****
>
> ** **
>
> *import* org.apache.xmlbeans.SchemaTypeLoader;****
>
> *import* org.apache.xmlbeans.SchemaTypeSystem;****
>
> *import* org.apache.xmlbeans.XmlBeans;****
>
> *import* org.apache.xmlbeans.XmlObject;****
>
> *import* org.apache.xmlbeans.XmlOptions;****
>
> *import* org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;****
>
> ** **
>
> *public* *class* TestSchema {****
>
>       *public* *static* *void* main(String[] args) *throws* Exception {**=
*
> *
>
>             TestSchema ts =3D *new* TestSchema();****
>
>             ts.go(args);****
>
>       }****
>
> ** **
>
>       *private* *void* go(String[] args) *throws* Exception {****
>
>             {****
>
>                   XmlObject instance =3D TestSchemaDocument.Factory.*
> newInstance*(*new* XmlOptions());****
>
>                   System.*out*.println(instance.schemaType());****
>
>             }****
>
> ** **
>
>             {****
>
>                   SchemaTypeLoader loader =3D XmlBeans.*
> typeLoaderForClassLoader*(SchemaDocument.*class*.getClassLoader());****
>
>                   XmlObject instance =3D loader.parse(*new* File(
> "xsd/testschema.xsd"),*null*, *new* XmlOptions());****
>
>                   System.*out*.println(instance.schemaType());****
>
>             }****
>
> ** **
>
>             {****
>
>                   XmlObject[] schemaObj =3D *new* XmlObject[]   {
> XmlObject.Factory.*parse*(*new* File("xsd/testschema.xsd"))};****
>
>                   SchemaTypeSystem schemaTypeObj =3D XmlBeans.*
> compileXmlBeans*(*null*, *null*, schemaObj, *null*, *null*, *null*, *null=
*
> );****
>
>                   XmlObject instance =3D
> schemaTypeObj.newInstance(schemaTypeObj.documentTypes()[0], *null*);****
>
>                   System.*out*.println(instance.schemaType());****
>
>             }****
>
> ** **
>
>       }****
>
> }****
>
> ** **
>
> ** **
>
> *From:* badger mailinglist [mailto:[email protected]]
> *Sent:* Monday, January 14, 2013 6:35 AM
> *To:* [email protected]
> *Subject:* Re: Converting from using scomp to SchemaTypeLoader.parse(...)=
*
> ***
>
> ** **
>
> Ok, so I guess no one has ever tried this.
>
> Maybe there's a simpler question:
>
> If I use the SchemaTypeLoader.parse method, I struggle to get information
> about the schema from that object. I want to iterate through the attribut=
es
> and elements declared in the XSD I'm parsing, but all I seem to get is w3
> xml schema stuff. Am I trying to do something that isn't supported, or am=
 I
> just doing it wrong?
>
> Any help much appreciated,
>
> Cheers,
>
> Badger.****
>
> On 8 January 2013 15:42, badger mailinglist <[email protected]=
m>
> wrote:****
>
> Hi,
>
> Currently, I take some XSDs (see below for example), generate classes for
> them (with scomp -out generatedClasses.jar testschema.xsd), then use thos=
e
> classes in code with some like:
> final XmlObject instance =3D
> TestSchemaDocument.Factory.newInstance(xmlOptions);
>
> This process now needs to be a bit more dynamic, so I'm trying to use
> something more like the following:
>
> final SchemaTypeLoader loader =3D
> XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader());
> XmlOptions xmlOptions =3D new XmlOptions();
> final XmlObject fileParsedInstance =3D loader.parse(new
> File("C:\\testschema.xsd"), null, new XmlOptions());
>
>
> However, I would expect the XmlObject returned in both cases to be the
> same. However, if I recursively iterate through the properties of these t=
wo
> objects, I get different results i.e. calling
> instance.schemaType().getProperties() gets different results in each of t=
he
> cases.
> For the instance loaded from the class the getProperties() method returns
> one element with type 'TestSchema', which itself returns one element with
> type 'TestType' and so on as you recur.
> For the instance loaded directly from the xsd file the properties are all
> things like E=3Drestriction|D=3Drestriction@http://www.w3.org/2001/XMLSch=
ema,
> which has a property T=3DlocalSimpleType@http://www.w3.org/2001/XMLSchema=
,
> which has a property 'restriction' and so on infinitely.
>
> I've assumed that these two methods of loading the schema would do the
> same thing, but it looks like I'm wrong, can someone point me at the meth=
od
> call I need to make to load from the file properly? I'm using XmlBeans
> 2.5.0.
>
> Thanks!
>
>
> Example xsd I'm testing this with:
>
> <?xml version=3D"1.0" encoding=3D"utf-8"?>
> <xs:schema attributeFormDefault=3D"unqualified"
> elementFormDefault=3D"qualified" xmlns:xs=3D"http://www.w3.org/2001/XMLSc=
hema
> ">
>
>   <xs:element name=3D"TestSchema" type=3D"TestType" />
>
>   <xs:complexType name=3D"TestComplexType">
>     <xs:sequence>
>       <xs:element type=3D"xs:string" name=3D"thing" />
>     </xs:sequence>
>   </xs:complexType>
>
>   <xs:complexType name=3D"TestType">
>     <xs:sequence>
>       <xs:element type=3D"TestComplexType" name=3D"TestComplex"
>       maxOccurs=3D"unbounded" minOccurs=3D"0" />
>     </xs:sequence>
>   </xs:complexType>
>
> </xs:schema>****
>
> ** **
>

--e89a8fb20078a67d6f04d3541da5
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Thanks Paul and Jacob, I guess I didn&#39;t quite read through the tutorial=
s far enough. It&#39;s all working now I&#39;m *actually* compiling the xsd=
.<br><br>Thanks again,<br><br>Badger.<br><br><br><div class=3D"gmail_quote"=
>
On 14 January 2013 23:27, Paul Gillen <span dir=3D"ltr">&lt;<a href=3D"mail=
to:[email protected]" target=3D"_blank">[email protected]</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link=3D"blue" vlink=3D"purple" lang=3D"EN-US"><div><p class=3D"MsoNorm=
al"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;s=
ans-serif&quot;;color:#1f497d">Boy, I wish I got paid for this crap.<u></u>=
<u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Full answer here: <a h=
ref=3D"http://www.oracle.com/technetwork/articles/entarch/incremental-compi=
lation-xmlbeans-089127.html" target=3D"_blank">http://www.oracle.com/techne=
twork/articles/entarch/incremental-compilation-xmlbeans-089127.html</a><u><=
/u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">In your first example =
you had compiled your schema and created an object to describe parsed XML.<=
u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">In you second example =
you parsed the XSD, which is after all XML, and, surprise, it=92s described=
 by W3C XSD.<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">What you want to do, a=
nd I would be interested in hearing why, is to compile the XSD on the fly.<=
u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">The output of the exam=
ple below is:<u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-autospace:none"><span=
 style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">D=3DTestSch=
ema</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quo=
t;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in;text-autospace:none"><span=
 style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">D=3Dschema@=
<a href=3D"http://www.w3.org/2001/XMLSchema" target=3D"_blank">http://www.w=
3.org/2001/XMLSchema</a></span><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><span style=3D"font-size:=
10.0pt;font-family:&quot;Courier New&quot;">D=3DTestSchema<u></u><u></u></s=
pan></p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:=
&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">where the first i=
s your first example, the second is your second example, and the third is f=
rom compiling the XSD on the fly.<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hope this helps.<u></u=
><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Cheers,<u></u><u></u><=
/span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">Paul<u></u><u></u></span>=
</p><p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quo=
t;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></sp=
an></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">package</sp=
an></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"=
> com.riveralph;</span><span style=3D"font-size:10.0pt;font-family:&quot;Co=
urier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 java.io.File;</span><span style=3D"font-size:10.0pt;font-family:&quot;Cour=
ier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 noNamespace.TestSchemaDocument;</span><span style=3D"font-size:10.0pt;font=
-family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.SchemaTypeLoader;</span><span style=3D"font-size:10.0p=
t;font-family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.SchemaTypeSystem;</span><span style=3D"font-size:10.0p=
t;font-family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.XmlBeans;</span><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.XmlObject;</span><span style=3D"font-size:10.0pt;font-=
family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.XmlOptions;</span><span style=3D"font-size:10.0pt;font=
-family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">import</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;</span><span style=3D=
"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u></span=
></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">public</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 </span><b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&qu=
ot;;color:#7f0055">class</span></b><span style=3D"font-size:10.0pt;font-fam=
ily:&quot;Courier New&quot;"> TestSchema {</span><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0 </span><b><s=
pan style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f=
0055">public</span></b><span style=3D"font-size:10.0pt;font-family:&quot;Co=
urier New&quot;"> </span><b><span style=3D"font-size:10.0pt;font-family:&qu=
ot;Courier New&quot;;color:#7f0055">static</span></b><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"> </span><b><span style=3D"fo=
nt-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">void</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">=
 main(String[] args) </span><b><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:#7f0055">throws</span></b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;"> Exception {</span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></=
u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0 =A0=A0=A0=A0=
=A0 TestSchema ts =3D </span><b><span style=3D"font-size:10.0pt;font-family=
:&quot;Courier New&quot;;color:#7f0055">new</span></b><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;"> TestSchema();</span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></=
u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 ts.go(args);</span><span style=3D"font-size:10.0pt;font-family:&quot=
;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0 }</span><spa=
n style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u>=
</u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0 </span><b><s=
pan style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f=
0055">private</span></b><span style=3D"font-size:10.0pt;font-family:&quot;C=
ourier New&quot;"> </span><b><span style=3D"font-size:10.0pt;font-family:&q=
uot;Courier New&quot;;color:#7f0055">void</span></b><span style=3D"font-siz=
e:10.0pt;font-family:&quot;Courier New&quot;"> go(String[] args) </span><b>=
<span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#=
7f0055">throws</span></b><span style=3D"font-size:10.0pt;font-family:&quot;=
Courier New&quot;"> Exception {</span><span style=3D"font-size:10.0pt;font-=
family:&quot;Courier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 {</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 XmlObject instance =3D TestSchemaDocument.Factory.=
<i>newInstance</i>(</span><b><span style=3D"font-size:10.0pt;font-family:&q=
uot;Courier New&quot;;color:#7f0055">new</span></b><span style=3D"font-size=
:10.0pt;font-family:&quot;Courier New&quot;"> XmlOptions());</span><span st=
yle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u>=
</span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 System.</span><i><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#0000c0">out</span></i><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">.println(instance=
.schemaType());</span><span style=3D"font-size:10.0pt;font-family:&quot;Cou=
rier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 }</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 {</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 SchemaTypeLoader loader =3D XmlBeans.<i>typeLoader=
ForClassLoader</i>(SchemaDocument.</span><b><span style=3D"font-size:10.0pt=
;font-family:&quot;Courier New&quot;;color:#7f0055">class</span></b><span s=
tyle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">.getClassLoad=
er());</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&=
quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 XmlObject instance =3D loader.parse(</span><b><spa=
n style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f00=
55">new</span></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;"> File(</span><span style=3D"font-size:10.0pt;font-family:&quot;=
Courier New&quot;;color:#2a00ff">&quot;xsd/testschema.xsd&quot;</span><span=
 style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">),</span><b=
><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:=
#7f0055">null</span></b><span style=3D"font-size:10.0pt;font-family:&quot;C=
ourier New&quot;">, </span><b><span style=3D"font-size:10.0pt;font-family:&=
quot;Courier New&quot;;color:#7f0055">new</span></b><span style=3D"font-siz=
e:10.0pt;font-family:&quot;Courier New&quot;"> XmlOptions());</span><span s=
tyle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u=
></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 System.</span><i><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#0000c0">out</span></i><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">.println(instance=
.schemaType());</span><span style=3D"font-size:10.0pt;font-family:&quot;Cou=
rier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 }</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 {</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 XmlObject[] schemaObj =3D </span><b><span style=3D=
"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">new</s=
pan></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
"> XmlObject[]=A0=A0 { XmlObject.Factory.<i>parse</i>(</span><b><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">new=
</span></b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&qu=
ot;"> File(</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;;color:#2a00ff">&quot;xsd/testschema.xsd&quot;</span><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">))};</span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></=
u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 SchemaTypeSystem schemaTypeObj =3D XmlBeans.<i>com=
pileXmlBeans</i>(</span><b><span style=3D"font-size:10.0pt;font-family:&quo=
t;Courier New&quot;;color:#7f0055">null</span></b><span style=3D"font-size:=
10.0pt;font-family:&quot;Courier New&quot;">, </span><b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">null</span>=
</b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">, =
schemaObj, </span><b><span style=3D"font-size:10.0pt;font-family:&quot;Cour=
ier New&quot;;color:#7f0055">null</span></b><span style=3D"font-size:10.0pt=
;font-family:&quot;Courier New&quot;">, </span><b><span style=3D"font-size:=
10.0pt;font-family:&quot;Courier New&quot;;color:#7f0055">null</span></b><s=
pan style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">, </span=
><b><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;col=
or:#7f0055">null</span></b><span style=3D"font-size:10.0pt;font-family:&quo=
t;Courier New&quot;">, </span><b><span style=3D"font-size:10.0pt;font-famil=
y:&quot;Courier New&quot;;color:#7f0055">null</span></b><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;">);</span><span style=3D"f=
ont-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u></span><=
/p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 XmlObject instance =3D schemaTypeObj.newInstance(s=
chemaTypeObj.documentTypes()[0], </span><b><span style=3D"font-size:10.0pt;=
font-family:&quot;Courier New&quot;;color:#7f0055">null</span></b><span sty=
le=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">);</span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></=
u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 System.</span><i><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#0000c0">out</span></i><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;">.println(instance=
.schemaType());</span><span style=3D"font-size:10.0pt;font-family:&quot;Cou=
rier New&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 }</span><span style=3D"font-size:10.0pt;font-family:&quot;Courier Ne=
w&quot;"><u></u><u></u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;"><u></u>=A0<u></u></span></p>=
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">=A0=A0=A0=A0=A0 }</span><spa=
n style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u>=
</u></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;">}</span><span style=3D"font-=
size:10.0pt;font-family:&quot;Courier New&quot;"><u></u><u></u></span></p><=
p class=3D"MsoNormal">
<span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-=
serif&quot;;color:#1f497d"><u></u>=A0<u></u></span></p><p class=3D"MsoNorma=
l"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sa=
ns-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span></p>
<p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot=
;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> badger m=
ailinglist [mailto:<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>] <br>
<b>Sent:</b> Monday, January 14, 2013 6:35 AM<br><b>To:</b> <a href=3D"mail=
to:[email protected]" target=3D"_blank">[email protected]</a>=
<br><b>Subject:</b> Re: Converting from using scomp to SchemaTypeLoader.par=
se(...)<u></u><u></u></span></p>
<div><div class=3D"h5"><p class=3D"MsoNormal"><u></u>=A0<u></u></p><p class=
=3D"MsoNormal" style=3D"margin-bottom:12.0pt">Ok, so I guess no one has eve=
r tried this.<br><br>Maybe there&#39;s a simpler question:<br><br>If I use =
the SchemaTypeLoader.parse method, I struggle to get information about the =
schema from that object. I want to iterate through the attributes and eleme=
nts declared in the XSD I&#39;m parsing, but all I seem to get is w3 xml sc=
hema stuff. Am I trying to do something that isn&#39;t supported, or am I j=
ust doing it wrong?<br>
<br>Any help much appreciated,<br><br>Cheers,<br><br>Badger.<u></u><u></u><=
/p><div><p class=3D"MsoNormal">On 8 January 2013 15:42, badger mailinglist =
&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">badg=
[email protected]</a>&gt; wrote:<u></u><u></u></p>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">Hi,<br><br>Currently,=
 I take some XSDs (see below for example), generate classes for them (with =
scomp -out generatedClasses.jar testschema.xsd), then use those classes in =
code with some like:<br>
final XmlObject instance =3D TestSchemaDocument.Factory.newInstance(xmlOpti=
ons);<br><br>This process now needs to be a bit more dynamic, so I&#39;m tr=
ying to use something more like the following:<br><br>final SchemaTypeLoade=
r loader =3D XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClas=
sLoader());<br>
XmlOptions xmlOptions =3D new XmlOptions();<br>final XmlObject fileParsedIn=
stance =3D loader.parse(new File(&quot;C:\\testschema.xsd&quot;), null, new=
 XmlOptions());<br><br><br>However, I would expect the XmlObject returned i=
n both cases to be the same. However, if I recursively iterate through the =
properties of these two objects, I get different results i.e. calling insta=
nce.schemaType().getProperties() gets different results in each of the case=
s.<br>
For the instance loaded from the class the getProperties() method returns o=
ne element with type &#39;TestSchema&#39;, which itself returns one element=
 with type &#39;TestType&#39; and so on as you recur.<br>For the instance l=
oaded directly from the xsd file the properties are all things like E=3Dres=
triction|D=3Drestriction@<a href=3D"http://www.w3.org/2001/XMLSchema" targe=
t=3D"_blank">http://www.w3.org/2001/XMLSchema</a>, which has a property T=
=3DlocalSimpleType@<a href=3D"http://www.w3.org/2001/XMLSchema" target=3D"_=
blank">http://www.w3.org/2001/XMLSchema</a>, which has a property &#39;rest=
riction&#39; and so on infinitely.<br>
<br>I&#39;ve assumed that these two methods of loading the schema would do =
the same thing, but it looks like I&#39;m wrong, can someone point me at th=
e method call I need to make to load from the file properly? I&#39;m using =
XmlBeans 2.5.0.<br>
<br>Thanks!<br><br><br>Example xsd I&#39;m testing this with:<br><br>&lt;?x=
ml version=3D&quot;1.0&quot; encoding=3D&quot;utf-8&quot;?&gt;<br>&lt;xs:sc=
hema attributeFormDefault=3D&quot;unqualified&quot; elementFormDefault=3D&q=
uot;qualified&quot; xmlns:xs=3D&quot;<a href=3D"http://www.w3.org/2001/XMLS=
chema" target=3D"_blank">http://www.w3.org/2001/XMLSchema</a>&quot;&gt;<br>
<br>=A0 &lt;xs:element name=3D&quot;TestSchema&quot; type=3D&quot;TestType&=
quot; /&gt;<br>=A0 <br>=A0 &lt;xs:complexType name=3D&quot;TestComplexType&=
quot;&gt;<br>=A0=A0=A0 &lt;xs:sequence&gt;<br>=A0=A0=A0=A0=A0 &lt;xs:elemen=
t type=3D&quot;xs:string&quot; name=3D&quot;thing&quot; /&gt;<br>
=A0=A0=A0 &lt;/xs:sequence&gt;<br>=A0 &lt;/xs:complexType&gt;<br>=A0 <br>=
=A0 &lt;xs:complexType name=3D&quot;TestType&quot;&gt;<br>=A0=A0=A0 &lt;xs:=
sequence&gt;<br>=A0=A0=A0=A0=A0 &lt;xs:element type=3D&quot;TestComplexType=
&quot; name=3D&quot;TestComplex&quot;<br>
=A0=A0=A0=A0=A0 maxOccurs=3D&quot;unbounded&quot; minOccurs=3D&quot;0&quot;=
 /&gt;<br>=A0=A0=A0 &lt;/xs:sequence&gt;<br>=A0 &lt;/xs:complexType&gt;<br>=
=A0 <br>&lt;/xs:schema&gt;<u></u><u></u></p></div><p class=3D"MsoNormal"><u=
></u>=A0<u></u></p></div>
</div></div></div></blockquote></div><br>

--e89a8fb20078a67d6f04d3541da5--