String to xml object java

Hello,
can anyone suggest me how to convert string to xml object in java?
I have a string (Data) ant now I have to pass it as parameter as xml object, which structure should be:
<MGWData>Data</MGWData>
Where I surf I always see only solutions for converting string to xml document, but never to xml object.
maybe the problem is I don't completely understand what xml object is in first place :/
Any answer would help.
Thanks.

894871 wrote:
here is the method to call:
+/**+
* Sets the p_DATAXMLTYPEIN value for this SVARCHAR2INSERT_RECEIVESInput.
*+
* @param p_DATAXMLTYPEIN
*public void setP_DATAXMLTYPEIN(com.oracle.xmlns.orawsv.SISTEMA_MOKA.MGW_PUBLIC_FUNCTIONS.SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN p_DATAXMLTYPEIN) {*
this.p_DATAXMLTYPEIN = p_DATAXMLTYPEIN;
one of the classes contains:
*public class SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN  implements java.io.Serializable, org.apache.axis.encoding.AnyContentType {*
*private org.apache.axis.message.MessageElement [] _any;*
this method and some classes where generated using eclipse and wsdl file by creating web service client.
wsdl says for that part: *<xsd:element name="P_DATA-XMLTYPE-IN">*
So I suppose it should involve smth org.apache.axis.message.MessageElement. But when I create any type of parameter, it gives me error:
+ ....cannot be cast to com.oracle.xmlns.orawsv.SISTEMA_MOKA.MGW_PUBLIC_FUNCTIONS.SVARCHAR2INSERT_RECEIVESInputP_DATAXMLTYPEIN+
I am new in web service stuff so thank you for response.Can you explain in plain English what you are trying to do? Or provide a [url http://sscce.org/]SSCE.

Similar Messages

  • Conversion of string into XML object

    Hi
    I am having some problems with conversion of string (containing XML data) into Flex XML object and binding it later to UI elements to output/maintain this data.
    Binding of XML structure to UI elements works perfectly fine if I will do following:
    1)      Hardcode XML object within Flex file
    2)      Read xml file from repository (xml file inside the Flex project)
    3)      Use HTTP request to retrieve XML data
    Unfortunately none of the above scenarios suits my solution.
    I am developing a prototype application for processing Flex forms inside SAP system. I have decided to make data bindings using XML structure stored in Data Base. When rendering form inside web browser based application I am retrieving corresponding XML schema (empty for new forms and populated for saved forms) and pass it to Flex form as a string type import parameter. Data is being passed correctly (I can display it on TextArea control for instance) but after conversion to XML and binding to DataGrid I am not getting any results.
    I am converting string (containing XML) to XML object in following way:
    Private var xml_obj:XML = new XML(string_xml );
    I am catching any potential errors but conversion is going well. After conversion I am not getting any results after binding it to DataGrid control and I am not able to access any of the nodes using AS code either. At the same time variable xml_obj is not empty (not null).
    Any help would be much appreciated.
    Regards
    Michael

    David
    First of all sorry for not stating it clearly but I am using Flex 3 for this development (at the moment it is the only choice when embedding Flex objects inside SAP applications).
    You must have missed the bit where I am describing how this XML data finds its way inside Flex. I am passing it to Flex as String type parameter during rendering (directly from DB where it is stored).
    Now, following code works perfect (XML is embedded inside Flex project):
                    <mx:XML id="form_data" source="../assets/example_xml_data.xml"/>
                    <mx:Script>
                                    <![CDATA[
                                                    import mx.collections.XMLListCollection;
                                                    import mx.controls.Alert;
                                                    [Bindable]
                                                    public var XML_list:XMLListCollection;
                                                    private function setParameters():void
                                                                   XML_list = new XMLListCollection(form_data.*);             
                                    ]]>
                    </mx:Script>
                    <mx:DataGrid id="myDataGrid" dataProvider="{XML_list}">
                                    <mx:columns>
                                                    <mx:DataGridColumn dataField="COMMON" headerText="Popular name"/>
                                                    <mx:DataGridColumn dataField="BOTANICAL" headerText="Botanical name"/>
                                                    <mx:DataGridColumn dataField="ZONE" headerText="Zone"/>
                                                    <mx:DataGridColumn dataField="LIGHT" headerText="Light"/>                                                                                                                                               
                                                    <mx:DataGridColumn dataField="PRICE" headerText="Price"/>                                               
                                                    <mx:DataGridColumn dataField="AVAILABILITY" headerText="Availability"/>                                    
                                    </mx:columns>               
                    </mx:DataGrid>
    But following code does not work (XML passed to Flex form as String input parameter):
    import sap.FlashIsland;
    import mx.controls.Alert;
    import mx.collections.XMLListCollection;
    [Bindable]
    public var xml_data:String;
    private var form_data:XML;
    [Bindable]
    private var XML_list:XMLListCollection;
    private function initApp():void
                    FlashIsland.register(this);
    private function setParameters():void
                    try
                                    form_data=new XML(xml_data);
                    catch (error:Error)
                                    Alert.show(error.toString());
                      XML_list = new XMLListCollection(form_data.*);           
    XML string does find its way inside Flex form. I can display content of variable xml_data in TextArea and all looks fine. Conversion to XML (variable form_data) goes well (no error)
    Please helpJ
    Regards
    Michael

  • Calling Bpel Process From a Jsp(Need a string output instead of XML object)

    Hi
    I am calling a BPEL process(Synchrononus) from a JSP page, Where Bpel process calls a java web service.The output from Bpel process is returned as an XML object. I need the output in a string format.Please let me know the steps to get the string output.
    I also executed invokeCreditRatingService.jsp(from samples shipped with SOA Suite) that calls CreditRatingService bpel, but i was getting the following output where the rating value is printed as an XML object.
    Output:-
    BPELProcess CreditRatingService executed!
    Credit Rating is oracle.xml.parser.v2.XMLElement@9511c8
    Please let me know, what changes i need to make to get the string output.I followed all the steps given in "orabpel-Tutorial7-InvokingBPELProcesses.PDF" to execute credit rating jsp.
    We are using SOA Suite 10.1.3.1.0 version.Do I need to make any changes to the code, to make it work with this version.
    Thanks
    Vandana.

    The call payload.get("payload") returns, as you have observed, an XMLElement. You can simply convert the XMLElement into an XML string by using a DOMSerializer implementation. The following code is very useful for this purpose:
    http://javafaq.nu/java-example-code-432.html
    Best,
    Manfred

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • Mapping XML object to java object gives ClassCastException

    Hi All,
    I am trying to map a specific XML object to a specific java object using web
    services and received the following exception:
    java.lang.ClassCastException: weblogic.soap.xml.XMLObject
    at $Proxy0.getMonster(Unknown Source)
    at serviceClient.TestServiceClient.main(TestServiceClient.java:46)
    Exception in thread "main"
    I tried to map a simple type:
    <types>
    <schema targetNamespace='java:biomaterials'
    xmlns='http://www.w3.org/1999/XMLSchema'>
    <element name="Monster">
    <complexType>
    <all>
    <element name="name"
    type="string"/>
    <element name="age"
    type="int"/>
    </all>
    </complexType>
    </element>
    </schema>
    </types>
    To the following java bean:
    package biomaterials;
    public class
    ster{
    private String name;
    private Integer age;
    public Monster(String name, int age) {
    this.name=name;
    this.age=new Integer(age);
    public String getName() {
    return name;
    public void setName(String s) {
    this.name=s;
    public Integer getAge() {
    return age;
    public void setAge(int n) {
    this.age=new Integer(n);
    Here is my client code:
    package serviceClient;
    import java.util.Properties;
    import weblogic.soap.codec.CodecFactory;
    import weblogic.soap.codec.SoapEncodingCodec;
    import weblog
    ic.soap.codec.LiteralCodec;
    import weblogic.soap.WebServiceProxy;
    import weblogic.soap.SoapMethod;
    import weblogic.soap.SoapType;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.ejb.*;
    import biomaterials.ServiceSession;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Element;
    import biomaterials.Monster;
    public class TestServiceClient
    public static void main( String[] arg ) throws Exception
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.soap.http.SoapInitialContextFactory");
    h.put("weblogic.soap.wsdl.interface",
    ServiceSession.class.getName() );
    Context context = new InitialContext(h);
    ServiceSession serv =
    (ServiceSession)context.lookup("http://localhost:7001/biocat/biomaterials.Se
    rviceSession/biomaterials.ServiceSession.wsdl");
    //try
    //int result = serv.getTheNum();
    //String result=serv.getBIXBiologicals();
    //int result=serv.setBIXInfo("TARNUMBER");
    Monster result=serv.getMonster();
    System.out.print("The value is "+result);
    } /* end of main */
    } /* end of class */
    Here is the method in my stateless session bean:
    public Monster getMonster()
    return new Monster("Sully",3);
    And here is my whole wsdl file:
    <% response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); %>
    <definitions
    targetNamespace="java:biomaterials"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="java:biomaterials"
    >
    <types>
    <schema targetNamespace='java:biomaterials'
    xmlns='http://www.w3.org/1999/XMLSchema'>
    <element name="Monster">
    <complexType>
    <all>
    <element name="name" type="string"/>
    <element name="age" type="int"/>
    </all>
    </complexType>
    </element>
    </schema>
    </types>
    <message name="getBIXBiologicalsRequest"></message>
    <message name="getBIXBiologicalsResponse">
    <part name="return" type="xsd:string" />
    </message>
    <message name="setBIXInfoRequest">
    <part name="arg0" type="xsd:string" />
    <part name="arg1" type="xsd:string" />
    <part name="arg2" type="xsd:integer" />
    </message>
    <message name="setBIXInfoResponse"></message>
    <message name="getMonsterRequest"></message>
    <message name="getMonsterResponse">
    <part name="body" element="tns:Monster"/>
    </message>
    <portType name="ServiceSessionPortType">
    <operation name="getBIXBiologicals">
    <input message="tns:getBIXBiologicalsRequest"/>
    <output message="tns:getBIXBiologicalsResponse"/>
    I am using weblogic 6.1 SP1 on WIN NT.
    Please help me out in this issue.
    Thanks in advance.
    Sapan

    HI !
    i dont think that the servicepack is an issue in this case.
    anyway i ahve tried it on 6.1SP4 and still getting similar results.
    any pointers will be highly appreciated.
    Thanks,
    sapan
    "manoj cheenath" <[email protected]> wrote in message
    news:[email protected]...
    I just skimmed through your email. You said you
    are using WLS 6.1 SP1. Can you try this using
    the latest SP. There are many bug fixes done
    after SP1.
    Web service support in 6.1 is very limited. But, It
    looks like 6.1 can handle the case you are trying out.
    regards,
    -manoj
    "Sapan Agarwal" <[email protected]> wrote in message
    news:[email protected]...
    Hi All,
    I am trying to map a specific XML object to a specific java object usingweb
    services and received the following exception:
    java.lang.ClassCastException: weblogic.soap.xml.XMLObject
    at $Proxy0.getMonster(Unknown Source)
    at
    serviceClient.TestServiceClient.main(TestServiceClient.java:46)
    >>
    Exception in thread "main"
    I tried to map a simple type:
    <types>
    <schema targetNamespace='java:biomaterials'
    xmlns='http://www.w3.org/1999/XMLSchema'>
    <element name="Monster">
    <complexType>
    <all>
    <element name="name"
    type="string"/>
    <element name="age"
    type="int"/>
    </all>
    </complexType>
    </element>
    </schema>
    </types>
    To the following java bean:
    package biomaterials;
    public class
    ster{
    private String name;
    private Integer age;
    public Monster(String name, int age) {
    this.name=name;
    this.age=new Integer(age);
    public String getName() {
    return name;
    public void setName(String s) {
    this.name=s;
    public Integer getAge() {
    return age;
    public void setAge(int n) {
    this.age=new Integer(n);
    Here is my client code:
    package serviceClient;
    import java.util.Properties;
    import weblogic.soap.codec.CodecFactory;
    import weblogic.soap.codec.SoapEncodingCodec;
    import weblog
    ic.soap.codec.LiteralCodec;
    import weblogic.soap.WebServiceProxy;
    import weblogic.soap.SoapMethod;
    import weblogic.soap.SoapType;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.ejb.*;
    import biomaterials.ServiceSession;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Element;
    import biomaterials.Monster;
    public class TestServiceClient
    public static void main( String[] arg ) throws Exception
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.soap.http.SoapInitialContextFactory");
    h.put("weblogic.soap.wsdl.interface",
    ServiceSession.class.getName() );
    Context context = new InitialContext(h);
    ServiceSession serv =
    (ServiceSession)context.lookup("http://localhost:7001/biocat/biomaterials.Se
    rviceSession/biomaterials.ServiceSession.wsdl");
    file://try
    file://int result = serv.getTheNum();
    file://String result=serv.getBIXBiologicals();
    file://int result=serv.setBIXInfo("TARNUMBER");
    Monster result=serv.getMonster();
    System.out.print("The value is "+result);
    } /* end of main */
    } /* end of class */
    Here is the method in my stateless session bean:
    public Monster getMonster()
    return new Monster("Sully",3);
    And here is my whole wsdl file:
    <% response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); %>
    <definitions
    targetNamespace="java:biomaterials"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="java:biomaterials"
    >
    <types>
    <schema targetNamespace='java:biomaterials'
    xmlns='http://www.w3.org/1999/XMLSchema'>
    <element name="Monster">
    <complexType>
    <all>
    <element name="name" type="string"/>
    <element name="age" type="int"/>
    </all>
    </complexType>
    </element>
    </schema>
    </types>
    <message name="getBIXBiologicalsRequest"></message>
    <message name="getBIXBiologicalsResponse">
    <part name="return" type="xsd:string" />
    </message>
    <message name="setBIXInfoRequest">
    <part name="arg0" type="xsd:string" />
    <part name="arg1" type="xsd:string" />
    <part name="arg2" type="xsd:integer" />
    </message>
    <message name="setBIXInfoResponse"></message>
    <message name="getMonsterRequest"></message>
    <message name="getMonsterResponse">
    <part name="body" element="tns:Monster"/>
    </message>
    <portType name="ServiceSessionPortType">
    <operation name="getBIXBiologicals">
    <input message="tns:getBIXBiologicalsRequest"/>
    <outputmessage="tns:getBIXBiologicalsResponse"/>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    I am using weblogic 6.1 SP1 on WIN NT.
    Please help me out in this issue.
    Thanks in advance.
    Sapan

  • Unable to read big files into string object & java.lang.OutOfMemory Problem

    Hi All,
    I have an application that uses applet and servlet communication. On the client side I am reading an large xml file of 12MB size (using JFileChooser) and converting the file to an string object using below code. But I am getting java.lang.OutOfMemory on the client side . But the same below code works fine for small xml files which are less than 4MB sizes:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF8"), 1024*12);
    String s, s2 = new String();
    while((s = in.readLine())!= null)
    s2 += s + "\n";
    I even tried the below code but still java.lang.OutOfMemory is coming:
    while (true)
    int i = in.read();
    if (i == -1)
    break;
    sb.append(i);
    Please let me know what am I doing wrong here ...

    Hi,
    I could avoid the java.lang.OutOfMemory error using below code. But using below code I could read small files of sizes less than 4MB
    but with large files of 12 MB the below code just simply hangs and I am unable to print the string object namely 's'.
    My purpose is to construct an String or StringBuffer object out the user uploaded xml file at the client side and pass that object to server for processing. So how can I construct such object avoid memory problem and increasing the performance of such operations.
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
    byte[] b = new byte[in.available()];
    in.read(b, 0, b.length);
    String s = new String(b, 0, b.length);
    in.close();
    Thanks & Regards,
    Sony.

  • JAVA Object to XML to JAVA to XML

    I have to achieve below in java:-
    -Create input XMLs from Java class (that resides in a jar).
    -Take input from user then store that data to Java object and submit for processing.
    -After processing print response java object again in XML.
    What is the best API to achieve this. Will be helpful if any example is available.

    Thanks for the Reply =)
    I have a Java Object that have some fileds like arraylist<Class> I want to take care of these fields as well.
    If that arrayList<Class> have another fields that can be normal fileds or arraylist of another class, need to take care of all fields during XML generation
    Example:-
    Root Class have below fields
    private int ArCt;
    private ArrayList<ClassChild1> Ar;
    Setters
    Getters
    ClassChild1.class
    private int PlnCd;
    private int cArCt;
    private ArrayList cAr<ClassChild2> cAr;
    ClassChild2.class
    private String PlNm
    XML Needed - Example from above object
    <root>
    <ArCt>1</ArCt>
    <Ar>
    <ClassChild1>
    <PlnCd>S</PlnCd>
    <cArCt>2</<cArCt>
    <cAr>
    <ClassChild2>
    <PlNm>Plan1</PlNm>
    </ClassChild2>
    <ClassChild2>
    <PlNm>Plan2</PlNm>
    </ClassChild2>
    </cAr>
    </ClassChild1>
    </Ar>
    </root>
    Edited by: nitingautam on May 15, 2011 11:01 PM

  • JAXB and inheritance. Converting xml to java object

    I have a schema "FreeStyle.xsd" i used JAXB to generate POJO's . I get around 15 classes. I have a config.xml which is compliant to this schema . Now i want to write a java program which takes the config.xml and converts it into a java object . Please anybody help me with this . Thanks in advance
    Freestyle.xsd
    <?xml version="1.0" encoding="windows-1252"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="FreeStyleProject" type="hudson.model.FreeStyleProject"/>
    <xsd:complexType name="hudson.model.FreeStyleProject">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.Project">
        <xsd:sequence/>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Project">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.BaseBuildableProject">
        <xsd:sequence/>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.BaseBuildableProject">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.AbstractProject">
        <xsd:sequence/>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.AbstractProject">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.Job">
        <xsd:sequence>
         <xsd:element name="concurrentBuild" type="xsd:boolean"/>
         <xsd:element name="downstreamProject" type="hudson.model.AbstractProject"
                      minOccurs="0" maxOccurs="unbounded"/>
         <xsd:element name="scm" type="hudson.scm.SCM" minOccurs="0"/>
         <xsd:element name="upstreamProject" type="hudson.model.AbstractProject"
                      minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.scm.SCM">
      <xsd:sequence>
       <xsd:element name="browser" type="hudson.scm.RepositoryBrowser"
                    minOccurs="0"/>
       <xsd:element name="type" type="xsd:string" minOccurs="0"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="hudson.scm.RepositoryBrowser">
      <xsd:sequence/>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Job">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.AbstractItem">
        <xsd:sequence>
         <xsd:element name="buildable" type="xsd:boolean"/>
         <xsd:element name="build" type="hudson.model.Run" minOccurs="0"
                      maxOccurs="unbounded"/>
         <xsd:element name="cascadingChildrenName" type="xsd:string" minOccurs="0"
                      maxOccurs="unbounded"/>
         <xsd:element name="color" type="hudson.model.BallColor" minOccurs="0"/>
         <xsd:element name="firstBuild" type="hudson.model.Run" minOccurs="0"/>
         <xsd:element name="healthReport" type="hudson.model.HealthReport"
                      minOccurs="0" maxOccurs="unbounded"/>
         <xsd:element name="inQueue" type="xsd:boolean"/>
         <xsd:element name="keepDependencies" type="xsd:boolean"/>
         <xsd:element name="lastBuild" type="hudson.model.Run" minOccurs="0"/>
         <xsd:element name="lastCompletedBuild" type="hudson.model.Run"
                      minOccurs="0"/>
         <xsd:element name="lastFailedBuild" type="hudson.model.Run" minOccurs="0"/>
         <xsd:element name="lastStableBuild" type="hudson.model.Run" minOccurs="0"/>
         <xsd:element name="lastSuccessfulBuild" type="hudson.model.Run"
                      minOccurs="0"/>
         <xsd:element name="lastUnstableBuild" type="hudson.model.Run"
                      minOccurs="0"/>
         <xsd:element name="lastUnsuccessfulBuild" type="hudson.model.Run"
                      minOccurs="0"/>
         <xsd:element name="nextBuildNumber" type="xsd:int"/>
         <xsd:element name="property" type="hudson.model.JobProperty" minOccurs="0"
                      maxOccurs="unbounded"/>
         <xsd:element name="queueItem" type="hudson.model.Queue-Item"
                      minOccurs="0"/>
        </xsd:sequence>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Queue-Item">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.Actionable">
        <xsd:sequence>
         <xsd:element name="blocked" type="xsd:boolean"/>
         <xsd:element name="buildable" type="xsd:boolean"/>
         <xsd:element name="id" type="xsd:int">
          <xsd:annotation>
           <xsd:documentation>VM-wide unique ID that tracks the {@link Task} as it
                              moves through different stages in the queue (each
                              represented by different subtypes of {@link Item}.</xsd:documentation>
          </xsd:annotation>
         </xsd:element>
         <xsd:element name="inQueueSince" type="xsd:long"/>
         <xsd:element name="params" type="xsd:string" minOccurs="0"/>
         <xsd:element name="stuck" type="xsd:boolean"/>
         <xsd:element name="task" type="xsd:anyType" minOccurs="0">
          <xsd:annotation>
           <xsd:documentation>Project to be built.</xsd:documentation>
          </xsd:annotation>
         </xsd:element>
         <xsd:element name="why" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Actionable">
      <xsd:sequence>
       <xsd:element name="action" type="xsd:anyType" minOccurs="0"
                    maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.JobProperty">
      <xsd:sequence/>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.HealthReport">
      <xsd:sequence>
       <xsd:element name="description" type="xsd:string" minOccurs="0"/>
       <xsd:element name="iconUrl" type="xsd:string" minOccurs="0"/>
       <xsd:element name="score" type="xsd:int"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Run">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.Actionable">
        <xsd:sequence>
         <xsd:element name="artifact" type="hudson.model.Run-Artifact" minOccurs="0"
                      maxOccurs="unbounded"/>
         <xsd:element name="building" type="xsd:boolean"/>
         <xsd:element name="description" type="xsd:string" minOccurs="0"/>
         <xsd:element name="duration" type="xsd:long"/>
         <xsd:element name="fullDisplayName" type="xsd:string" minOccurs="0"/>
         <xsd:element name="id" type="xsd:string" minOccurs="0"/>
         <xsd:element name="keepLog" type="xsd:boolean"/>
         <xsd:element name="number" type="xsd:int"/>
         <xsd:element name="result" type="xsd:anyType" minOccurs="0"/>
         <xsd:element name="timestamp" type="xsd:long" minOccurs="0"/>
         <xsd:element name="url" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.Run-Artifact">
      <xsd:sequence>
       <xsd:element name="displayPath" type="xsd:string" minOccurs="0"/>
       <xsd:element name="fileName" type="xsd:string" minOccurs="0"/>
       <xsd:element name="relativePath" type="xsd:string" minOccurs="0">
        <xsd:annotation>
         <xsd:documentation>Relative path name from {@link Run#getArtifactsDir()}</xsd:documentation>
        </xsd:annotation>
       </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="hudson.model.AbstractItem">
      <xsd:complexContent>
       <xsd:extension base="hudson.model.Actionable">
        <xsd:sequence>
         <xsd:element name="description" type="xsd:string" minOccurs="0"/>
         <xsd:element name="displayName" type="xsd:string" minOccurs="0"/>
         <xsd:element name="name" type="xsd:string" minOccurs="0"/>
         <xsd:element name="url" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
       </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
    <xsd:simpleType name="hudson.model.BallColor">
      <xsd:restriction base="xsd:string">
       <xsd:enumeration value="red"/>
       <xsd:enumeration value="red_anime"/>
       <xsd:enumeration value="yellow"/>
       <xsd:enumeration value="yellow_anime"/>
       <xsd:enumeration value="green"/>
       <xsd:enumeration value="green_anime"/>
       <xsd:enumeration value="blue"/>
       <xsd:enumeration value="blue_anime"/>
       <xsd:enumeration value="grey"/>
       <xsd:enumeration value="grey_anime"/>
       <xsd:enumeration value="disabled"/>
       <xsd:enumeration value="disabled_anime"/>
       <xsd:enumeration value="aborted"/>
       <xsd:enumeration value="aborted_anime"/>
      </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>
    Config.xml
    <?xml version='1.0' encoding='UTF-8'?>
    <project>
      <actions/>
      <description>Sample job ..</description>
      <project-properties class="java.util.concurrent.ConcurrentHashMap">
        <entry>
          <string>hudson-plugins-disk_usage-DiskUsageProperty</string>
          <base-property>
            <originalValue class="hudson.plugins.disk_usage.DiskUsageProperty"/>
            <propertyOverridden>false</propertyOverridden>
          </base-property>
        </entry>
        <entry>
          <string>jdk</string>
          <string-property>
            <originalValue class="string">(Inherit From Job)</originalValue>
            <propertyOverridden>false</propertyOverridden>
          </string-property>
        </entry>
        <entry>
          <string>scm</string>
          <scm-property>
            <originalValue class="hudson.scm.NullSCM"/>
            <propertyOverridden>false</propertyOverridden>
          </scm-property>
        </entry>
      </project-properties>
      <keepDependencies>false</keepDependencies>
      <creationTime>1402648240275</creationTime>
      <properties/>
      <cascadingChildrenNames class="java.util.concurrent.CopyOnWriteArraySet"/>
      <cascading-job-properties class="java.util.concurrent.CopyOnWriteArraySet">
        <string>hudson-plugins-batch_task-BatchTaskProperty</string>
        <string>hudson-plugins-disk_usage-DiskUsageProperty</string>
        <string>hudson-plugins-jira-JiraProjectProperty</string>
        <string>org-hudsonci-plugins-snapshotmonitor-WatchedDependenciesProperty</string>
        <string>hudson-plugins-promoted_builds-JobPropertyImpl</string>
      </cascading-job-properties>
      <scm class="hudson.scm.NullSCM"/>
      <canRoam>false</canRoam>
      <disabled>false</disabled>
      <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
      <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
      <concurrentBuild>false</concurrentBuild>
      <cleanWorkspaceRequired>false</cleanWorkspaceRequired>
    </project>
    the file generated by JAXB are
    com\model\HudsonModelAbstractItem.java
    com\model\HudsonModelAbstractProject.java
    com\model\HudsonModelActionable.java
    com\model\HudsonModelBallColor.java
    com\model\HudsonModelBaseBuildableProject.java
    com\model\HudsonModelFreeStyleProject.java
    com\model\HudsonModelHealthReport.java
    com\model\HudsonModelJob.java
    com\model\HudsonModelJobProperty.java
    com\model\HudsonModelProject.java
    com\model\HudsonModelQueueItem.java
    com\model\HudsonModelRun.java
    com\model\HudsonModelRunArtifact.java
    com\model\HudsonScmRepositoryBrowser.java
    com\model\HudsonScmSCM.java
    com\model\ObjectFactory.java
    Any help will be appreciated .
    Thanks in advance

    Unmarshal the config.xml to Java object.
    Basic JAXB Examples - The Java EE 5 Tutorial

  • Convert MBox into XML into Java Objects

    Hello all,
    this is a general question, i dont know weather there is such libs or not.
    However, please tell me what you know.
    i want to program a java application for searching purpose in Mbox.
    i thought its possible and easier to try to convert the emails from the MBox into XML files, and from these create java objects when i need or even convert the XML into html for viewing.
    Any suggestions are welcome.
    Also antoher solutions are greate.
    thanks in advance!
    Sako.

    I don't know what this MBox you speak of is - I assume it's not the thing I use to hook upa guitar to GarageBand. Maybe you mean it as a generic term for mailbox? The easiest solution (to my mind) would be to use a Java API provided by whatever MBox is. If there is no such thing, then if you get XML-formatted version of the messages I suppose writing code to parse the XML into Java Objects would be a good option if you wanted to do further manipulation of them, but if all you want to do is display them as HTML in a browser then just use XSLT to transform them.
    Good Luck
    Lee

  • Converting XML to Java Objects...possible?

    Hi, Am a newbie to JAXB. As far as I read, JAXB has facility to convert "XSD" (not XML) to Java "classes" (not objects). This can be done using xjc compiler. Can XML files (i.e. ones with data) be converted to Java objects (retaining the data from XML files)? If yes, please throw some light on how it can be done. If no, then is there some java technology to do such a thing?
    Thanks.

    http://xmlbeans.apache.org/

  • XML to Java Objects

    Hi,
    In our existing project we are using JDK / JRE 1.3.
    We need to add a module wherein we need to pick up an XML object (from MQ) and convert it into a Java Object.
    I was initially planning to use JAXP, but it appears that it needs Java 1.4 (or above). Is it ? So what is the other option available ?
    Is JDOM a worthwhile alternative ? Would it be supported on Java 1.3?or any other suitable alternative.
    Kindly advice as need to finalize on this as soon as possible.
    Thanks,
    MD

    You may have to roll your own - last time I was working with 1.3 there wasn't anything out there for it, but that was a couple of years ago.
    If the schema is fixed, you can pull parse, otherwise use SAX, a LinkedList as a stack and a map of element name -> content handler to populate the objects. If it's not a performance bottleneck*, you can get a long way just using reflection rather than having to write specific handling code for each attribute.
    Pete
    *most of what I do is aerospace simulation, so our messages might say 'run 100,000 simulations that cover all of the flight envelope', which then spawns a 15,000 cpu hour process, so it's at the opposite extreme to something like a SMS service hub, where there's almost no processing and it's all parsing, so optimising the XML for performance for us is irrelevent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • XML to java object AND Performance

    Hi,
    I read some article about marshalling a XML file to Java Object (like Castor, XML Beans projects...)
    To resume: I would like to marshal a XML doc (from XML to Java object. Later I would like to put these objects on a SGBD...). Unfortenaly I suppose that approach is to expensive on term of performance? Supposing that my xml doc contain 100 data's occurances, XML bean woulkd create 100 objects corresponding. My problem is that I don't want that the all 100 objects live in the same time on memory. For example, my code will read sequential, the xml occurances (like a Sax parser), create 10 datas objects (standby), put these in the data base, and destroy these objects before...iteratively create the next 10 objects...
    It is possible ? Can anybody help me?
    Thank

    On the article: Java Architecture for XML Binding (JAXB)
    (http://java.sun.com/developer/technicalArticles/WebServices/jaxb/)
    I found maybe a response?
    "...in other words, you can do a SAX parse of a document and then pass the events to JAXB for unmarshalling. "
    But somebody could help me to write the code to do that?

  • How to convert Java string into XML one?

    With SAX I can parse an xml file, but I should create xml file by hands.
    Ok, it's simple, but how to encode java string into XML constant
    like "Hello & goodby" into "Hello & goodby" ?
    Is there a standard method for such special xml characters?

    If you are creating your XML "by hand" then just make sure your hands know that you have to do that. It isn't difficult to write a Java method to do it, if "by hand" means "in Java code". Otherwise your XML is not well-formed. And as far as I know there is no package that takes ill-formed XML and fixes it up.

  • String to XML conversion without fatal error?

    Can one of you tell me how to convert the folowing string to XML without fatal error?
    String s1 = "<?xml version="1.0" encoding="UTF-6.0"?> <Main> <sub> 12345 </sub> </Main>".

    First, you can't have double quotes (") in a string like that, you need to do (\") instead. If you wrote the below line and saved the file as a file_name.xml It should work fine.
    import java.io.*;
    public class yourclass{
         public static void writeXML(){
              try{
                   File xmlOut = new File("file_name.xml");
                   BufferedWriter xmlWriter = new BufferedWriter(new FileWriter(xmlOut));
                   String s1 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?> <Main> <sub> 12345 </sub> </Main>";
                   // you can concatenate the strings using a + 
                   // the \n will create a new line in the file
                   String s2 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?>" + "\n" +  "<Main> <sub> 12345 </sub> </Main>";
                   xmlWriter.write(s1);
                   xmlWriter.close();
              }catch(Exception ex){
                   ex.printStackTrace();
    }There are a few other ways to do this, the one above is sloppy. One is XStream to convert xml to Java objects and back again. http://xstream.codehaus.org/tutorial.html

  • How to convert xml String to xml file?

    Hi,
    I got a method that do the following:
    public static String convertXmlToString(String xmlFileName) throws Exception
            File file = new File(xmlFileName);
            FileInputStream insr = new FileInputStream(file);
            byte[] fileBuffer = new byte[(int)file.length()];
            insr.read(fileBuffer);
            insr.close();
            return new String(fileBuffer);
         }The return String is the contents of an existing xml file and one example is shown below:
    <object type="server.WOXReference" id="0"><field name="actualPathObj"><object type="java.lang.String" id="1">C:\restClient\actualXMLObjects\812856084.xml</object></field><field name="object"><object type="server.WOXConstructor" id="2"><field name="className"><object type="java.lang.String" id="3">rec.SimpleRecognizer</object></field><field name="types"><array type="java.lang.String" length="3" id="4"><object type="java.lang.String" id="5">double[].class</object><object type="java.lang.String" id="6">double.class</object><object idref="6" /></array></field><field name="args"><array type="java.lang.Object" length="3" id="7"><array type="double" length="5" id="8">22.33 33.22 33.33 22.0 11.0</array><object type="java.lang.Double" id="9">2.2</object><object type="java.lang.Double" id="10">3.3</object></array></field><field name="retType"><object type="java.lang.String" id="11">act</object></field></object></field></object>
    and I want to change the above string to xml file like below:
    <object type="server.WOXReference" id="0"><field name="actualPathObj"><object type="java.lang.String" id="1">C:\restClient\actualXMLObjects\812856084.xml</object></field><field name="object"><object type="server.WOXConstructor" id="2"><field name="className"><object type="java.lang.String" id="3">rec.SimpleRecognizer</object></field><field name="types"><array type="java.lang.String" length="3" id="4"><object type="java.lang.String" id="5">double[].class</object><object type="java.lang.String" id="6">double.class</object><object idref="6" /></array></field><field name="args"><array type="java.lang.Object" length="3" id="7"><array type="double" length="5" id="8">22.33 33.22 33.33 22.0 11.0</array><object type="java.lang.Double" id="9">2.2</object><object type="java.lang.Double" id="10">3.3</object></array></field><field name="retType"><object type="java.lang.String" id="11">act</object></field></object></field></object>How to I change the above xml String back to xml file again? The appropriate tags must be taken care of like > must be > and < must be <.
    Please advice and can give me some sample code.
    Thanks.

    By writing some code that runs through the file and adds a new line for a new element using these methods here...
    http://java.sun.com/j2se/1.4.2/docs/api/org/xml/sax/ContentHandler.html
    i.e.
    startDocument()
    startElement(String namespaceURI, String localName, String qName, Attributes atts)
    endDocument()

Maybe you are looking for

  • My iPhone 6 is locked in vertical mode. How do fix this?

    I Have a brand new iPhone with current update. I am not able to turn my phone horizontal and have the picture rotate with the phone. I understand this is a setting lock but how do I fix it with this version. I had a 4s model and it had the same issue

  • Where is the file? ( ussing jfreechart )

    Hi, I have a servlet that generates a chart and I need to save this lika a .jpg The servlet runs but I don�t know where the .jpg file is. I�m working into a remote server (Debian with tomcat) My code is: import java.io.*; import java.net.*; import ja

  • IBooks not opening on Mac running Yosemite

    Hi everyone, Would love some help, I went to open iBooks today on my late 2011 MacBook Pro running Yosemite but it will not open, the app bounces once on my dock and does nothing. I reinstalled Yosemite as others have said has work and that has done

  • Multi page help flex 2 and CF

    hey guys I am creating this apps and so far, I have a search page that display data once user fills out a form (form and result) are all in one state/page. Now what I would like to do is when user clicks on one of the search result I would like to go

  • Drill through in system 9

    Hi, Any one could you please tell me what will be the usuage of Drill through, what it is? Thanks, sudhakar.