Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

XML Bean

Thread view: 
Shinya Koizumi - 01 Jun 2006 02:21 GMT
Can i serialize xml to object using XML Bean?
Each record stored in Oracle database as xml type and
I want to serialize this xml to java beans so that I can easily edit

this record. XML Bean is the tool to go for it?
jwagenleitner@gmail.com - 01 Jun 2006 04:24 GMT
> Can i serialize xml to object using XML Bean?
> Each record stored in Oracle database as xml type and
> I want to serialize this xml to java beans so that I can easily edit
>
> this record. XML Bean is the tool to go for it?

You can if you are referring to XMLBeans (http://xmlbeans.apache.org).
You'll need an XML Schema file in order to have XMLBeans generate the
required Java classes.  XMLBeans comes with a tool (inst2xsd) that will
enable you to turn an xml file into a schema if you don't have a schema
file already.

XMLBeans is my favorite java to xml binding tool.  I find it very clean
to work with the generate classes and methods.  With it you always deal
with the objects that are meaningful and this keeps your code clean and
easier to read and maintain in my opinion.  One of the things I dislike
about JAXB is that is makes you deal with objects outside those related
to your schema types.

John
sk - 01 Jun 2006 06:53 GMT
The thing is that our schema will be generated when I connect to the oracle.
I believe the class has to be generated at the development time, right?

Shinya
jwagenleitner@gmail.com - 01 Jun 2006 08:09 GMT
> The thing is that our schema will be generated when I connect to the oracle.
> I believe the class has to be generated at the development time, right?
>
> Shinya

Only way I know how to map xml to java objects is to know ahead of time
the schema or at least have an instance of the xml document in order to
create a schema.  While you may not have the schema you should at least
know the structure of the xml you are going to parse.  From an example
you can generate a schema and from that schema you can generate the
required java objects.  You do this at development time so that in your
program XMLBeans (or Castor or JAXB) has some objects to marshal the
xml data into.

John
sk - 02 Jun 2006 08:33 GMT
Our xml saved in the Oracle's xml type field is going to be like the
following:
the structure will be saved at the different table.

<meta12345>
   <meta789456>Scientific XML Data</meta789456>
   <meta789457>
       <meta789458>Scientific XML Data<meta789458>
       <meta789458>Scientific XML Data<meta789458>
   <meta789457/>
   <meta789459>Scientific XML Data<meta789459>
</meta12345>

The schema (xsd ) generated when connecting the database for the firstime
will be like this

   <xs:element name="meta123456">
       <xs:complextype>
           <xs:sequence>
               <xs:element name="meta789457" />
                   <xs:complextype>
                       <xs:element ref="meta789458"  minOccurs="1"
minOccurs="5">
                   </xs:complextype>
                   <xs:restriction base="xs:string"/>
               </xs:element>
               <xs:element ref="meta789459" />
           </xs:sequence>
       </xs:complextype>
   </xs:element>

           <xs:element name="meta789458">
               <xs:simpletype>
                   <xs:restriction base="xs:integer" >
               </xs:simpletype>
           </xs:element>



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.