You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Asaf Lahav <as...@gmail.com> on 2008/12/09 09:53:32 UTC
How to generate XmlBeans jar using API instead of SCOMP?
Is it possible to generate an XmlBeans jar out of a schema using XmlBeans
API instead of using SCOMP?
Thanks in advance,
Asaf
RE: Testing the element's existence
Posted by "Qureshi,Shahzad [Ontario]" <Sh...@ec.gc.ca>.
it could be because you don't have any optional elements as Radu mentioned. I believe you have to have the minOccurs attribute something like this
<element name="test" type="string" minOccurs="0" />
ppl, please correct me if i am wrong.
Shahzad Qureshi
Systems Analyst/Programmer
Applications Directorate, CIOB
Environment Canada
shahzad.qureshi@ec.gc.ca
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Wednesday, December 10, 2008 6:43 PM
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
I don't have any method sizeOf/isSet generated for my elements ...
Here is an example of my xsd
<xs:element name="XML">
<xs:complexType>
<xs:sequence>
<xs:element ref="Example"/>
</xs:sequence>
<xs:attribute name="a" type="xs:string"/>
<xs:attribute name="b" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Example">
<xs:complexType>
<xs:sequence>
<xs:element ref="first"/>
<xs:element ref="second"/>
<xs:element ref="third" maxOccurs="2"/>
</xs:sequence>
<xs:attribute name="data" type="xs:string"/>
</xs:complexType>
</xs:element>
i don't have the generated method isSet for the element "Example", just have the getExample() method
________________________________
From: radu.preotiuc-pietro@oracle.com
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
Date: Tue, 9 Dec 2008 20:30:39 -0500
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Tuesday, December 09, 2008 12:24 PM
To: user@xmlbeans.apache.org
Subject: Testing the element's existence
Hi,
I'm new in the use of XMLBeans, and I have one question:
How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element...
Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website.
Regards
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
RE: Testing the element's existence
Posted by Wing Yew Poon <wi...@oracle.com>.
Ben,
when you defined your elements and attributes, you probably only declared the minimal required attributes.
E.g., when declaring an element, you could declare its minOccurs and maxOccurs, but you do not need to and they both default to 1 (which means NOT optional); when declaring an attribute, you could declare its use, but you do not need to and it defaults to optional (i.e., use="optional", as opposed to use="required").
Hope that clears up your confusion.
- Wing Yew
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Thursday, December 11, 2008 5:49 PM
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
I was just surprised that i had a function to test my attributes and not my elements, because for both i didn't define if there were optional or not.
Thanks for your help
________________________________
From: radu.preotiuc-pietro@oracle.com
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
Date: Thu, 11 Dec 2008 12:12:39 -0800
This is because your element in this example is not optional, the way I was defining "optional" in my previous post.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Wednesday, December 10, 2008 3:43 PM
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
I don't have any method sizeOf/isSet generated for my elements ...
Here is an example of my xsd
<xs:element name="XML">
<xs:complexType>
<xs:sequence>
<xs:element ref="Example"/>
</xs:sequence>
<xs:attribute name="a" type="xs:string"/>
<xs:attribute name="b" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Example">
<xs:complexType>
<xs:sequence>
<xs:element ref="first"/>
<xs:element ref="second"/>
<xs:element ref="third" maxOccurs="2"/>
</xs:sequence>
<xs:attribute name="data" type="xs:string"/>
</xs:complexType>
</xs:element>
i don't have the generated method isSet for the element "Example", just have the getExample() method
________________________________
From: radu.preotiuc-pietro@oracle.com
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
Date: Tue, 9 Dec 2008 20:30:39 -0500
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Tuesday, December 09, 2008 12:24 PM
To: user@xmlbeans.apache.org
Subject: Testing the element's existence
Hi,
I'm new in the use of XMLBeans, and I have one question:
How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element...
Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website.
Regards
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
RE: Testing the element's existence
Posted by Ben roche <cr...@hotmail.com>.
I was just surprised that i had a function to test my attributes and not my elements, because for both i didn't define if there were optional or not.
Thanks for your help
From: radu.preotiuc-pietro@oracle.comTo: user@xmlbeans.apache.orgSubject: RE: Testing the element's existenceDate: Thu, 11 Dec 2008 12:12:39 -0800
This is because your element in this example is not optional, the way I was defining "optional" in my previous post.
Radu
From: Ben roche [mailto:creackers@hotmail.com] Sent: Wednesday, December 10, 2008 3:43 PMTo: user@xmlbeans.apache.orgSubject: RE: Testing the element's existence
I don't have any method sizeOf/isSet generated for my elements ... Here is an example of my xsd <xs:element name="XML"> <xs:complexType> <xs:sequence> <xs:element ref="Example"/> </xs:sequence> <xs:attribute name="a" type="xs:string"/> <xs:attribute name="b" type="xs:string"/> </xs:complexType> </xs:element> <xs:element name="Example"> <xs:complexType> <xs:sequence> <xs:element ref="first"/> <xs:element ref="second"/> <xs:element ref="third" maxOccurs="2"/> </xs:sequence> <xs:attribute name="data" type="xs:string"/> </xs:complexType> </xs:element>i don't have the generated method isSet for the element "Example", just have the getExample() method
From: radu.preotiuc-pietro@oracle.comTo: user@xmlbeans.apache.orgSubject: RE: Testing the element's existenceDate: Tue, 9 Dec 2008 20:30:39 -0500
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
From: Ben roche [mailto:creackers@hotmail.com] Sent: Tuesday, December 09, 2008 12:24 PMTo: user@xmlbeans.apache.orgSubject: Testing the element's existence
Hi, I'm new in the use of XMLBeans, and I have one question:How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element... Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website. Regards
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo
_________________________________________________________________
Email envoyé avec Windows Live Hotmail. Dites adieux aux spam et virus, passez à Hotmail ! C'est gratuit !
http://www.windowslive.fr/hotmail/default.asp
RE: Testing the element's existence
Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
This is because your element in this example is not optional, the way I was defining "optional" in my previous post.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Wednesday, December 10, 2008 3:43 PM
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
I don't have any method sizeOf/isSet generated for my elements ...
Here is an example of my xsd
<xs:element name="XML">
<xs:complexType>
<xs:sequence>
<xs:element ref="Example"/>
</xs:sequence>
<xs:attribute name="a" type="xs:string"/>
<xs:attribute name="b" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Example">
<xs:complexType>
<xs:sequence>
<xs:element ref="first"/>
<xs:element ref="second"/>
<xs:element ref="third" maxOccurs="2"/>
</xs:sequence>
<xs:attribute name="data" type="xs:string"/>
</xs:complexType>
</xs:element>
i don't have the generated method isSet for the element "Example", just have the getExample() method
________________________________
From: radu.preotiuc-pietro@oracle.com
To: user@xmlbeans.apache.org
Subject: RE: Testing the element's existence
Date: Tue, 9 Dec 2008 20:30:39 -0500
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Tuesday, December 09, 2008 12:24 PM
To: user@xmlbeans.apache.org
Subject: Testing the element's existence
Hi,
I'm new in the use of XMLBeans, and I have one question:
How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element...
Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website.
Regards
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
RE: Testing the element's existence
Posted by Ben roche <cr...@hotmail.com>.
I don't have any method sizeOf/isSet generated for my elements ...
Here is an example of my xsd
<xs:element name="XML"> <xs:complexType> <xs:sequence> <xs:element ref="Example"/> </xs:sequence> <xs:attribute name="a" type="xs:string"/> <xs:attribute name="b" type="xs:string"/> </xs:complexType> </xs:element> <xs:element name="Example"> <xs:complexType> <xs:sequence> <xs:element ref="first"/> <xs:element ref="second"/> <xs:element ref="third" maxOccurs="2"/> </xs:sequence> <xs:attribute name="data" type="xs:string"/> </xs:complexType> </xs:element>i don't have the generated method isSet for the element "Example", just have the getExample() method
From: radu.preotiuc-pietro@oracle.comTo: user@xmlbeans.apache.orgSubject: RE: Testing the element's existenceDate: Tue, 9 Dec 2008 20:30:39 -0500
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
From: Ben roche [mailto:creackers@hotmail.com] Sent: Tuesday, December 09, 2008 12:24 PMTo: user@xmlbeans.apache.orgSubject: Testing the element's existence
Hi, I'm new in the use of XMLBeans, and I have one question:How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element... Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website. Regards
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo
_________________________________________________________________
Email envoyé avec Windows Live Hotmail. Dites adieux aux spam et virus, passez à Hotmail ! C'est gratuit !
http://www.windowslive.fr/hotmail/default.asp
RE: Testing the element's existence
Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
The answer is that the isSetXXX() methods are being generated for "optional" elements/attributes, where by "optional" we mean they can appear 0 or 1 times. For arrays (elements that can appear more than 1 time), you can call sizeOfXXX(), that would be the equivalent method.
Radu
________________________________
From: Ben roche [mailto:creackers@hotmail.com]
Sent: Tuesday, December 09, 2008 12:24 PM
To: user@xmlbeans.apache.org
Subject: Testing the element's existence
Hi,
I'm new in the use of XMLBeans, and I have one question:
How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element...
Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website.
Regards
________________________________
Qui vous permet d'enregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la réponse en vidéo la réponse en vidéo <http://www.microsoft.com/france/windows/bts/default.mspx>
Testing the element's existence
Posted by Ben roche <cr...@hotmail.com>.
Hi,
I'm new in the use of XMLBeans, and I have one question:
How can you test the existence of an element ? I see there is an isSetAttribute() for each attribute, but I don't the see an equivalent method for the element... Did you do a getElementArray() and test if the array is empty ? I just feel it strange that there is no testing method for element...
Thank you for you help, i know that my question is a little bit stupid but I didn't find any answers on the XMLBeans website.
Regards
_________________________________________________________________
Email envoyé avec Windows Live Hotmail. Dites adieux aux spam et virus, passez à Hotmail ! C'est gratuit !
http://www.windowslive.fr/hotmail/default.asp
Re: How to generate XmlBeans jar using API instead of SCOMP?
Posted by Jacob Danner <ja...@gmail.com>.
If you have access to the svn src you can see some examples of these
apis under the cases directory.
http://svn.apache.org/viewvc/xmlbeans/trunk/test/cases/xbean/compile/
-jacobd
On Thu, Dec 11, 2008 at 12:08 PM, Radu Preotiuc-Pietro
<ra...@oracle.com> wrote:
> That's what I was saying. The part that compiles the Java source files and
> loads everything (or packages everything in a jar) is not supported, it's
> something that you will have to do.
>
> In all, there are 3 main steps to get from XSD to xmlbeans.jar:
>
> 1. Compile the XSD to the internal XMLBeans representation
> 2. Generate the Java source files from the internal representation
> 3. compile the Java sources and package everything into a Jar.
>
> XmlBeans.compileXsd([...]) does step 1, XmlBeans.compileXsd([...]) does 1+2,
> so what's left for you to do is 3.
>
> Radu
>
> ________________________________
> From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
> Sent: Wednesday, December 10, 2008 4:33 AM
> To: user@xmlbeans.apache.org; radu.preotiuc-pietro@oracle.com
> Subject: RE: How to generate XmlBeans jar using API instead of SCOMP?
>
> Thanks Radu,
>
> The problem is that I can't find information on how to get from an XSD to a
> compiled xmlbeans jar (equivalent to the SCOMP artifacts).
>
> Is the compilation process fully supported through XmlBeans API? Or am I
> supposed to generate the source files and initiate the compilation?
>
>
>
>
>
> From: Radu Preotiuc-Pietro [mailto:radu.preotiuc-pietro@oracle.com]
> Sent: Wednesday, December 10, 2008 3:22 AM
> To: user@xmlbeans.apache.org
> Subject: RE: How to generate XmlBeans jar using API instead of SCOMP?
>
>
>
> Asaf,
>
>
>
> Take a look at
>
>
>
> XmlBeans.compileXsd([...]) and
>
> XmlBeans.compileXmlBeans([...]) to also generate the Java source files. If
> you do that, you will then need to compile and load the Java classes
> yourself (we don't offer support for that because it is dependent on your
> execution framework and not really XML-related).
>
>
>
> You'll find more details by consulting the JavaDoc for the two methods and
> doing a search on the mailing list, the topic has come up before.
>
>
>
> Radu
>
>
>
> ________________________________
>
> From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
> Sent: Tuesday, December 09, 2008 3:54 AM
> To: user@xmlbeans.apache.org
> Subject: How to generate XmlBeans jar using API instead of SCOMP?
>
> Is it possible to generate an XmlBeans jar out of a schema using XmlBeans
> API instead of using SCOMP?
>
>
>
> Thanks in advance,
>
> Asaf
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
RE: How to generate XmlBeans jar using API instead of SCOMP?
Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
That's what I was saying. The part that compiles the Java source files and loads everything (or packages everything in a jar) is not supported, it's something that you will have to do.
In all, there are 3 main steps to get from XSD to xmlbeans.jar:
1. Compile the XSD to the internal XMLBeans representation
2. Generate the Java source files from the internal representation
3. compile the Java sources and package everything into a Jar.
XmlBeans.compileXsd([...]) does step 1, XmlBeans.compileXsd([...]) does 1+2, so what's left for you to do is 3.
Radu
________________________________
From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
Sent: Wednesday, December 10, 2008 4:33 AM
To: user@xmlbeans.apache.org; radu.preotiuc-pietro@oracle.com
Subject: RE: How to generate XmlBeans jar using API instead of SCOMP?
Thanks Radu,
The problem is that I can't find information on how to get from an XSD to a compiled xmlbeans jar (equivalent to the SCOMP artifacts).
Is the compilation process fully supported through XmlBeans API? Or am I supposed to generate the source files and initiate the compilation?
From: Radu Preotiuc-Pietro [mailto:radu.preotiuc-pietro@oracle.com]
Sent: Wednesday, December 10, 2008 3:22 AM
To: user@xmlbeans.apache.org
Subject: RE: How to generate XmlBeans jar using API instead of SCOMP?
Asaf,
Take a look at
XmlBeans.compileXsd([...]) and
XmlBeans.compileXmlBeans([...]) to also generate the Java source files. If you do that, you will then need to compile and load the Java classes yourself (we don't offer support for that because it is dependent on your execution framework and not really XML-related).
You'll find more details by consulting the JavaDoc for the two methods and doing a search on the mailing list, the topic has come up before.
Radu
________________________________
From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
Sent: Tuesday, December 09, 2008 3:54 AM
To: user@xmlbeans.apache.org
Subject: How to generate XmlBeans jar using API instead of SCOMP?
Is it possible to generate an XmlBeans jar out of a schema using XmlBeans API instead of using SCOMP?
Thanks in advance,
Asaf
RE: How to generate XmlBeans jar using API instead of SCOMP?
Posted by Asaf Lahav <as...@gmail.com>.
Thanks Radu,
The problem is that I can't find information on how to get from an XSD to a
compiled xmlbeans jar (equivalent to the SCOMP artifacts).
Is the compilation process fully supported through XmlBeans API? Or am I
supposed to generate the source files and initiate the compilation?
From: Radu Preotiuc-Pietro [mailto:radu.preotiuc-pietro@oracle.com]
Sent: Wednesday, December 10, 2008 3:22 AM
To: user@xmlbeans.apache.org
Subject: RE: How to generate XmlBeans jar using API instead of SCOMP?
Asaf,
Take a look at
XmlBeans.compileXsd([...]) and
XmlBeans.compileXmlBeans([...]) to also generate the Java source files. If
you do that, you will then need to compile and load the Java classes
yourself (we don't offer support for that because it is dependent on your
execution framework and not really XML-related).
You'll find more details by consulting the JavaDoc for the two methods and
doing a search on the mailing list, the topic has come up before.
Radu
_____
From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
Sent: Tuesday, December 09, 2008 3:54 AM
To: user@xmlbeans.apache.org
Subject: How to generate XmlBeans jar using API instead of SCOMP?
Is it possible to generate an XmlBeans jar out of a schema using XmlBeans
API instead of using SCOMP?
Thanks in advance,
Asaf
RE: How to generate XmlBeans jar using API instead of SCOMP?
Posted by Radu Preotiuc-Pietro <ra...@oracle.com>.
Asaf,
Take a look at
XmlBeans.compileXsd([...]) and
XmlBeans.compileXmlBeans([...]) to also generate the Java source files. If you do that, you will then need to compile and load the Java classes yourself (we don't offer support for that because it is dependent on your execution framework and not really XML-related).
You'll find more details by consulting the JavaDoc for the two methods and doing a search on the mailing list, the topic has come up before.
Radu
________________________________
From: Asaf Lahav [mailto:asaf.lahav@gmail.com]
Sent: Tuesday, December 09, 2008 3:54 AM
To: user@xmlbeans.apache.org
Subject: How to generate XmlBeans jar using API instead of SCOMP?
Is it possible to generate an XmlBeans jar out of a schema using XmlBeans API instead of using SCOMP?
Thanks in advance,
Asaf