You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Arif Shaon <a....@reading.ac.uk> on 2006/06/30 12:46:13 UTC

Dynamically generating java classes from XSD file using XmlBeans

Hi,

I am fairly new to XMLBEans. I know one can generate java classes from xsd 
(XML SChema) file using scomp. But I was wondering if there is any way it 
would be done on the fly. For Example, the user would be able to specify 
the file path for the XSD file to the program, and the program would then 
load the file, compile it, generate the java classes and manipulate the 
classes as required.

Could this be done?
Any help would be greatly appreciated.

Best Regards

Arif



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


RE: Dynamically generating java classes from XSD file using XmlBeans

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Also XmlBeans.compileXmlBeans() is a good place to look at because,
unlike the script, is part of the "public" API which means
backards-compatbility and better documentation.

Radu 

-----Original Message-----
From: Arif Shaon [mailto:a.b.s.shaon@reading.ac.uk] 
Sent: Friday, June 30, 2006 5:09 PM
To: user@xmlbeans.apache.org
Subject: RE: Dynamically generating java classes from XSD file using
XmlBeans

Thank you very much both. Its really helpful. 

Cheers
Arif


On Jul 1 2006, Wing Yew Poon wrote:

>Arif,
>Nathan is right.
>If you look at the scomp script, it basically calls java on 
>org.apache.xmlbeans.impl.tool.SchemaCompiler with your arguments.
>Look at the xmlbeans source in the svn repository.
>SchemaCompiler.java is under the src/xmlcomp/ hierarchy.
>SchemaCompiler has a static nested class SchemaCompiler.Parameters.
>What you need to do is to create a SchemaCompiler.Parameters instance, 
>set its fields appropriately, and then call compile() with your 
>parameters.
>Good luck.
>- Wing Yew
>
>-----Original Message-----
>From: Nathan Sowatskey [mailto:nsowatsk@cisco.com]
>Sent: Friday, June 30, 2006 3:57 AM
>To: user@xmlbeans.apache.org
>Subject: Re: Dynamically generating java classes from XSD file using 
>XmlBeans
>
>Hi
>
>Imagine that the CLI tool you use is really just a shell script calling

>java on a java class file which has a main that takes the arguments of 
>the file that you want to compile, and then reads and compiles it.
>
>So, what you want to do is find the java class that is invoked by the 
>script, and replicate what its main() does.
>
>You can also invoke the java compiler as a call to it's main, and then 
>use reflection to invoke your new class.
>
>The rest is an exercise for the reader :-)
>
>Regards
>
>Nathan
>
>Nathan Sowatskey - Technical Leader, NMTG CTO Engineering -
>+34-638-083-675, +34-91-201-2139 - AIM NathanCisco - nsowatsk@cisco.com
>
>On 30 Jun 2006, at 12:46, Arif Shaon wrote:
>
>> Hi,
>>
>> I am fairly new to XMLBEans. I know one can generate java classes  
>> from xsd (XML SChema) file using scomp. But I was wondering if  
>> there is any way it would be done on the fly. For Example, the user  
>> would be able to specify the file path for the XSD file to the  
>> program, and the program would then load the file, compile it,  
>> generate the java classes and manipulate the classes as required.
>>
>> Could this be done?
>> Any help would be greatly appreciated.
>>
>> Best Regards
>>
>> Arif
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>_______________________________________________________________________
>Notice:  This email message, together with any attachments, may contain
>information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
>entities,  that may be confidential,  proprietary,  copyrighted  and/or
>legally privileged, and is intended solely for the use of the
individual
>or entity named in this message. If you are not the intended recipient,
>and have received this message in error, please immediately return this
>by email and then delete it.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

-- 
Arif Shaon
Long-term Metadata Management
Computer Science
University of Reading


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

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

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


RE: Dynamically generating java classes from XSD file using XmlBeans

Posted by Arif Shaon <a....@reading.ac.uk>.
Thank you very much both. Its really helpful. 

Cheers
Arif


On Jul 1 2006, Wing Yew Poon wrote:

>Arif,
>Nathan is right.
>If you look at the scomp script, it basically calls java on
>org.apache.xmlbeans.impl.tool.SchemaCompiler with your arguments.
>Look at the xmlbeans source in the svn repository.
>SchemaCompiler.java is under the src/xmlcomp/ hierarchy.
>SchemaCompiler has a static nested class SchemaCompiler.Parameters.
>What you need to do is to create a SchemaCompiler.Parameters instance,
>set its fields appropriately, and then call compile() with your
>parameters.
>Good luck.
>- Wing Yew
>
>-----Original Message-----
>From: Nathan Sowatskey [mailto:nsowatsk@cisco.com] 
>Sent: Friday, June 30, 2006 3:57 AM
>To: user@xmlbeans.apache.org
>Subject: Re: Dynamically generating java classes from XSD file using
>XmlBeans
>
>Hi
>
>Imagine that the CLI tool you use is really just a shell script  
>calling java on a java class file which has a main that takes the  
>arguments of the file that you want to compile, and then reads and  
>compiles it.
>
>So, what you want to do is find the java class that is invoked by the  
>script, and replicate what its main() does.
>
>You can also invoke the java compiler as a call to it's main, and  
>then use reflection to invoke your new class.
>
>The rest is an exercise for the reader :-)
>
>Regards
>
>Nathan
>
>Nathan Sowatskey - Technical Leader, NMTG CTO Engineering -  
>+34-638-083-675, +34-91-201-2139 - AIM NathanCisco - nsowatsk@cisco.com
>
>On 30 Jun 2006, at 12:46, Arif Shaon wrote:
>
>> Hi,
>>
>> I am fairly new to XMLBEans. I know one can generate java classes  
>> from xsd (XML SChema) file using scomp. But I was wondering if  
>> there is any way it would be done on the fly. For Example, the user  
>> would be able to specify the file path for the XSD file to the  
>> program, and the program would then load the file, compile it,  
>> generate the java classes and manipulate the classes as required.
>>
>> Could this be done?
>> Any help would be greatly appreciated.
>>
>> Best Regards
>>
>> Arif
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>_______________________________________________________________________
>Notice:  This email message, together with any attachments, may contain
>information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
>entities,  that may be confidential,  proprietary,  copyrighted  and/or
>legally privileged, and is intended solely for the use of the individual
>or entity named in this message. If you are not the intended recipient,
>and have received this message in error, please immediately return this
>by email and then delete it.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
>For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

-- 
Arif Shaon
Long-term Metadata Management
Computer Science
University of Reading


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


RE: Dynamically generating java classes from XSD file using XmlBeans

Posted by Wing Yew Poon <wp...@bea.com>.
Arif,
Nathan is right.
If you look at the scomp script, it basically calls java on
org.apache.xmlbeans.impl.tool.SchemaCompiler with your arguments.
Look at the xmlbeans source in the svn repository.
SchemaCompiler.java is under the src/xmlcomp/ hierarchy.
SchemaCompiler has a static nested class SchemaCompiler.Parameters.
What you need to do is to create a SchemaCompiler.Parameters instance,
set its fields appropriately, and then call compile() with your
parameters.
Good luck.
- Wing Yew

-----Original Message-----
From: Nathan Sowatskey [mailto:nsowatsk@cisco.com] 
Sent: Friday, June 30, 2006 3:57 AM
To: user@xmlbeans.apache.org
Subject: Re: Dynamically generating java classes from XSD file using
XmlBeans

Hi

Imagine that the CLI tool you use is really just a shell script  
calling java on a java class file which has a main that takes the  
arguments of the file that you want to compile, and then reads and  
compiles it.

So, what you want to do is find the java class that is invoked by the  
script, and replicate what its main() does.

You can also invoke the java compiler as a call to it's main, and  
then use reflection to invoke your new class.

The rest is an exercise for the reader :-)

Regards

Nathan

Nathan Sowatskey - Technical Leader, NMTG CTO Engineering -  
+34-638-083-675, +34-91-201-2139 - AIM NathanCisco - nsowatsk@cisco.com

On 30 Jun 2006, at 12:46, Arif Shaon wrote:

> Hi,
>
> I am fairly new to XMLBEans. I know one can generate java classes  
> from xsd (XML SChema) file using scomp. But I was wondering if  
> there is any way it would be done on the fly. For Example, the user  
> would be able to specify the file path for the XSD file to the  
> program, and the program would then load the file, compile it,  
> generate the java classes and manipulate the classes as required.
>
> Could this be done?
> Any help would be greatly appreciated.
>
> Best Regards
>
> Arif
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org

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

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

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


Re: Dynamically generating java classes from XSD file using XmlBeans

Posted by Nathan Sowatskey <ns...@cisco.com>.
Hi

Imagine that the CLI tool you use is really just a shell script  
calling java on a java class file which has a main that takes the  
arguments of the file that you want to compile, and then reads and  
compiles it.

So, what you want to do is find the java class that is invoked by the  
script, and replicate what its main() does.

You can also invoke the java compiler as a call to it's main, and  
then use reflection to invoke your new class.

The rest is an exercise for the reader :-)

Regards

Nathan

Nathan Sowatskey - Technical Leader, NMTG CTO Engineering -  
+34-638-083-675, +34-91-201-2139 - AIM NathanCisco - nsowatsk@cisco.com

On 30 Jun 2006, at 12:46, Arif Shaon wrote:

> Hi,
>
> I am fairly new to XMLBEans. I know one can generate java classes  
> from xsd (XML SChema) file using scomp. But I was wondering if  
> there is any way it would be done on the fly. For Example, the user  
> would be able to specify the file path for the XSD file to the  
> program, and the program would then load the file, compile it,  
> generate the java classes and manipulate the classes as required.
>
> Could this be done?
> Any help would be greatly appreciated.
>
> Best Regards
>
> Arif
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org

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