Unmarshal SOAP response, as raw XML String with JAXB

Hi,
I have a soap response, as raw xml (a java.lang.String), and I want to unmarshal it's content into the classes generated by wsimport.
This must be a simple task but I couldn't find a way to do it.
Can someone tell me how I can achieve this ?
Edited by: Raphael_Lemaire on May 25, 2010 8:30 AM

Raphael_Lemaire wrote:
Yes it works this way.
I kind of hoped that i could use a jax-ws api to shorten the code.well, how exactly do you get that string full of xml? (as a side note, you need to be careful turning xml into strings, the data can easily broken if you don't translate the bytes into characters correctly). if you use the jaxws api to make soap calls, then you don't really need to deal with the xml at all.
Edited by: jtahlborn on May 26, 2010 7:38 AM

Similar Messages

  • Parsing XML string with XPath

    Hi,-
    I am trying to parse an XML string with xpath as follows but I am getting null for getresult.
    I am getting java.xml.xpath.xpathexpressionexception at line where
    getresult = xpathexpression.evaluate(isource); is executed.
    What should I do after
    xpathexpression = xPath.compile("a/b");in the below snippet?
    Thanks
    String xmlstring ="..."; // a valid XML string;
    Xpath xpath = XPathFactory.newInstance().newPath();
    xpathexpression = xPath.compile("a/b");
    // I guess the following line is not correct
    InputSource isource = new inputSource(new ByteArrayInputStream(xmlstring.getBytes())); right
    getresult = xpathexpression.evaluate(isource);My xml string is like:
    <a>
      <b>
         <result> valid some more tags here
         </result>
      </b>
      <c> 10
      </c>
    </a>Edited by: geoman on Dec 8, 2008 2:30 PM

    I've never used the version of evaluate that takes an InputSource. The difficulty with using it is that it does not save the DOM object. Each expression you evaluate will have to create the DOM object, use it once and then throw it away. I've yet to write a program that only needs one answer from an XML document. Usually, I use XPath to locate somewhere in a document and then read "nearby" content, add new content nearby, delete content, or move content. I'd suggest you may want to parse the XML stream and save the DOM Document.
    Second, all of the XPath expressions search from a "context node". I have not had good luck searching from the Document object, so I always get the root element first. I think the expression should work if you use the root as the context node. You will need one of the versions of evaluate that uses an Object as the parameter.

  • Escape XML Strings with JDK class

    Hi,
    can anyone tell me how to escape XML-Strings with classes of the JDK?
    When searching I only was pointed to StringEscapeUtils from apache.commons.lang, but we would prefer to use the JDK instead of integrating an external lib.
    Our aim is to escape an XML attribute, so a CDATA is not applicable for us in this case.
    Thanks
    Jan

    I implemented it by myself:
    public static String escapeXmlAttribute(String attributeValue) {
            StringBuffer result = new StringBuffer();
            for (int c = 0; c < attributeValue.length(); ++c) {
                if (attributeValue.charAt(c) == '"') {
                    result.append("&#34;");
                } else if (attributeValue.charAt(c) == '&') {
                    result.append("&#38;");
                } else if (attributeValue.charAt(c) == '<') {
                    result.append("<");
                } else if (attributeValue.charAt(c) == '>') {
                    result.append(">");
                } else {
                    result.append(attributeValue.charAt(c));
            return result.toString();
        }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help: SOAP Response Fault when big string is returned

    Hello all, I'm quite newbie on Flex and SOAP, so sorry if I'm making an obvious question
    I  have an application in Flex that consumes a webservice, and everything  runs smoothly until I try to return a big string, which I find to be  odd. In my tests, when the string is over 490 characters, I get the  following message:
    SOAP Response cannot be decoded. Raw response: faultCode="DecodingError" faultDetail="null"
    I  made a PHP client, just for testing, to consume the same webservice,  that calls the same operation. But in this other client, I get no errors  and the string is returned complete, with no problems.
    Sorry for my english, and any help will be very appreciated! Thanks!
    Here is my script:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;           
                [Bindable]private var testValue:String;
                protected function floappService_variableTestResultHandler(event:ResultEvent):void
                    this.testValue = event.result as String;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <s:WebService id="ws"
                          wsdl="mywebservice?wsdl"
                <s:operation name="variableTest"
                             result="floappService_variableTestResultHandler(event)"
                             fault="mx.controls.Alert.show(event.fault.faultString)"/>
            </s:WebService>
        </fx:Declarations>
        <mx:VBox width="100%" height="100%">
            <mx:Form width="100%" height="100%">
                <mx:FormItem>
                    <mx:HBox>
                        <s:Button label="Variable Test" click="ws.variableTest()"/>
                        <mx:Text text="{testValue}"/>
                    </mx:HBox>
                </mx:FormItem>
            </mx:Form>
        </mx:VBox>
    </s:Application>

    Here is the raw response in the case that I get no faults (string with 490 'A's)
    HTTP/1.1 200 OK
    Date: Tue, 21 Sep 2010 17:36:46 GMT
    Server: Apache/2.2.14 (Ubuntu)
    X-Powered-By: PHP/5.3.2-1ubuntu4.2
    X-SOAP-Server: NuSOAP/0.7.3 (1.114)
    Content-Length: 1027
    Vary: Accept-Encoding
    Connection: close
    Content-Type: text/xml; charset=ISO-8859-1
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://fusionforge.inteligis.paqtc.org.br">
    <SOAP-ENV:Body>
    <ns1:variableTestResponse xmlns:ns1="http://fusionforge.inteligis.paqtc.org.br">
    <myReturn xsi:type="xsd:string">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</myReturn>
    </ns1:variableTestResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    And here is the case when I get the fault (string with 491 - or more - 'A's):
    HTTP/1.1 200 OK
    Date: Tue, 21 Sep 2010 17:40:40 GMT
    Server: Apache/2.2.14 (Ubuntu)
    X-Powered-By: PHP/5.3.2-1ubuntu4.2
    X-SOAP-Server: NuSOAP/0.7.3 (1.114)
    Content-Length: 1028
    Vary: Accept-Encoding
    Connection: close
    Content-Type: text/xml; charset=ISO-8859-1
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://fusionforge.inteligis.paqtc.org.br">
    <SOAP-ENV:Body>
    <ns1:variableTestResponse xmlns:ns1="http://fusionforge.inteligis.paqtc.org.br">
    <myReturn xsi:type="xsd:string">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</myReturn>
    </ns1:variableTestResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    I checked both XMLs "well-formedness" on W3 XML Validator (
    http://www.w3schools.com/XML/xml_validator.asp), and got no errors.
    The  only difference between both responses is the Content-Length, so I'm  guessing that it has something to do with it (don't have any idea of  what/why)

  • Getting null value while parsing "XML String" with  encoding WINDOWS-1252.

    Hi,
    when I am converting the Follwoing "xml string " to Document, I am getting the "null" as a document value.
        String strXML =  "<?xml version="1.0" encoding="WINDOWS-1252"?>
                              <category name="SearchByAttributes" value="Search By Attributes">
                                <item name="ORDER_LINE_ID" description="Application Search Attributes" >
                                   <attribute name="Sequence" value="0001"/>
                                 </item>
                                </category>"      
    My "xml string" has the encoding vaule: WINDOWS-1252.
    I am using the following code to convert the "xml string" to Document. I am getting the Document values as a "null" while converting the above "string xml"
            String strXML = //my above string xml.
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setIgnoringElementContentWhitespace(true);
            docBuilder = docBuilderFactory.newDocumentBuilder();
            doc = docBuilder.parse(new InputSource(new StringReader(strXML)));              
            System.out.println("doc value.."+doc)//I am getting null value for "doc".
    Can anyone help me to resolve the issue.

    Thagelapally wrote:
    I am coverting the below "XML string" to Document, once it is converted I am reading that Document,which have an "attribue" Element in.
      String strXML = "<?xml version="1.0" encoding="WINDOWS-1252"?>
    <category name="SearchByAttributes" value="Search By Attributes">
    <item name="ORDER_LINE_ID" description="Application Search Attributes" >
    <attribute name="Sequence" value="0001"/>
    </item>
    </category>" I am using the above code to read the Document. When run the code in "OC4J Server" and using Jdeveloper as an editor,I am able to perfectly read the "attribute" element in the document with out any problem.Println statement printing as I expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."attribute"(as expected)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."oracle.xml.parser.v2.XMLAttrList@afe"But when run the same code(reading the same Document) in Tomcat and Eclipse,println satatement not printing as i expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."#text"(I am expecting output value "attribute" but it is printing "#text" which i don't know)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."null"(I am expecting output value object reference but it is printing "null"
    (without the rest of the code, i'm guessing that) most likely you are grabbing the first child node of the item element. however, you are not accounting for some text nodes that are most likely in that list, like the whitespace between the item element and the attribute element. please go read some tutorials on xml, there are thousands of them out there, and they will answer all you initial questions much more efficiently than posting each step to the forums.

  • Getting a complete portion of an XML String (With tag names)

    Im working on an application that processes a huge amount of xml strings. Im using xpath since it makes it much easier to select and navigate through the tags. The only thing I can't do is get a complete portion of an XML string, for example, if i have
    <article>
    <articlebody>
    </articlebody>
    <references>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    </references>
    </article>
    I need to get the complete <reference> portion to parse later, so i need the following string:
    <references>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    <reference id="1"> ... </reference>
    </references>
    How can i do this using xpath? is it even possible? if not how else can i do it? (don't want to use regular expressions and string manipulation)
    Thanks for you help

    Im not sure if this really qualifies as using DOM, but this is all i do to get the data i want from the files (when i only want to get the text value of an element:
    InputSource inputSource = new InputSource(new StringReader(metadata));
    return xpath.evluate(expression, inputSource, returnType);where metadata is a String containing meta data, and return type is usually string or number.
    Im using Java 5 and
    Could you please explain a little more how to do this?
    Thank you

  • Exception while unmarshalling UTF-8 encoded XML String, using JAXB.

    hi folks. First of all, thank you for contributing to my queries as of now.
    Problem statement.
    - This happens when i try to unmarshall a webservice response, which is nothing but a simple UTF-8 encoded XML string in an soap envelope.
    - 0xae is the register character: &reg;.
    - My next step was to ensure that my code works without this character. So I removed all occurances from my XML. It worked just fine...
    - So what do you guys suggest me to get rid of this problem?
    - Any suggestion will be treated as valuable resource.
    - Is there some kind of encoding setting with jaxb ?
    An invalid XML character (Unicode: 0xae) was found in the element content of the document.
    org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.
         at weblogic.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1273)
         at weblogic.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:603)
         at weblogic.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1319)
         at weblogic.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:396)
         at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:1119)
         at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
         at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:133)
         at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:139)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:129)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:166)
         at com.hp.wwopsit.econfigure.helper.JaxbUtils.xmlStringToJaxbObject(JaxbUtils.java:66)
         at com.hp.wwopsit.econfigure.core.transformation.IPCAdapterMapper.x2oLoadConfig(IPCAdapterMapper.java:376)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.loadConfiguration(IPCAdapter.java:144)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.main(IPCAdapter.java:291)
    --------------- linked to ------------------
    javax.xml.bind.UnmarshalException
    - with linked exception:
    [org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.]
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:284)
         at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:143)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:129)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:166)
         at com.hp.wwopsit.econfigure.helper.JaxbUtils.xmlStringToJaxbObject(JaxbUtils.java:66)
         at com.hp.wwopsit.econfigure.core.transformation.IPCAdapterMapper.x2oLoadConfig(IPCAdapterMapper.java:376)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.loadConfiguration(IPCAdapter.java:144)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.main(IPCAdapter.java:291)
    ***Jaxb Exception while converting xml file to object. Possible cause, Invalid schema or unrecognized elements in input XML. Actuall exception message:javax.xml.bind.UnmarshalException
    - with linked exception:
    [org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.]
    End..
    Output completed (44 sec consumed) - Normal Termination

    This is how the XML looks like ..
    <?xml version="1.0" encoding="UTF-8" ?>
    - <configresponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <csticShortText>processor</csticShortText>
    - <csticValues>
    - <csticValue id="024" selected="false">
    <desc>Pentium� 4 1.7GHz/400MHz</desc>
    </configresponse>

  • Unmarshalling a DOM node to an XML file with JAXB

    I'm trying to unmarshall a DOM node to an XML file using JAXB. However I keep receiving a NullPointerException. This only seems to occur when I create the DOM Node from scratch. The stack trace looks like the following:
    java.lang.NullPointerException
            at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.startElement
    (SAXUnmarshallerHandlerImpl.java:87)
            at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:109)
            at com.sun.xml.bind.unmarshaller.DOMScanner.parse(DOMScanner.java:64)
            at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(Unmarshaller
    Impl.java:149)
            at Main.main(Main.java:103)(If I unmarshal an XML file into a DOM node, I can successfully marshall the DOM node out to a new XML file using JAXB without error.)
    Any insight into what I am doing wrong would be greatly appreciated!
    Sample code and XSD follow...
    Sample Code:
    import itemlistsample.*;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.JAXBException;
    import javax.xml.bind.Marshaller;
    import javax.xml.bind.Unmarshaller;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.Text;
    public class Main
      public static void main(String[] args)
          try
              JAXBContext jc = JAXBContext.newInstance( "itemlistsample" );
              Unmarshaller u = jc.createUnmarshaller();
              * Set up DOM Node Document Object.
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);                   
              DocumentBuilder db = dbf.newDocumentBuilder(); 
              Document doc = db.newDocument();
              System.out.println();
              System.out.println();
              System.out.println("Create a DOM Node and unmarshall to an XML file");
              * Generate elements within DOM document
              Element itemListElt = (Element)doc.createElement("item_list");
              Element itemInfo = (Element)doc.createElement("item_info");
              Element name = (Element)doc.createElement("name");
              Element price = (Element)doc.createElement("price");
              * 3-Ring Binder @ 4.99
              name.appendChild(doc.createTextNode("3-Ring Binder"));
              itemInfo.appendChild(name);
              price.appendChild(doc.createTextNode("4.99"));
              itemInfo.appendChild(price);
              itemListElt.appendChild(itemInfo);
              * Large Paper Clips @ 1.23
              itemInfo = (Element)doc.createElement("item_info");
              name = (Element)doc.createElement("name");
              price = (Element)doc.createElement("price");
              name.appendChild(doc.createTextNode("Large Paper Clips"));
              itemInfo.appendChild(name);
              price.appendChild(doc.createTextNode("1.23"));
              itemInfo.appendChild(price);
              itemListElt.appendChild(itemInfo);
              doc.appendChild(itemListElt);
              * Display DOM document as a sanity check
              itemListElt = doc.getDocumentElement();
              System.out.println(itemListElt.getTagName());
              NodeList nl = itemListElt.getElementsByTagName("item_info");
              traverse("  ", nl.item(0));
              * Use JAXB to unmarshal the DOM document into
              * an instance of the generated JAXB class for
              * the root element.  Stack trace occurs here!
              ItemListType il = (ItemListType)u.unmarshal(doc);
              * Marshal to an XML file
              Marshaller m = jc.createMarshaller();
              m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
              m.marshal( il, new FileOutputStream("item_new.xml") );
          catch (Exception e)
         e.printStackTrace();
      public static void traverse(String indent, Node n)
        if (n != null)
          if (n.getNodeName() != null)
            System.out.println(indent + n.getNodeName());
            traverse(indent + "  ", n.getFirstChild());
          if (n.getNodeValue() != null)
            System.out.println(indent + n.getNodeValue());
          traverse(indent, n.getNextSibling());
    }Sample XSD:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="item_list" type="ItemListType"/>
         <xsd:complexType name="ItemListType">
              <xsd:sequence>
                   <xsd:element name="item_info" type="ItemInfoType" maxOccurs="unbounded"/>
              </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="ItemInfoType">
              <xsd:sequence>
                   <xsd:element name="name" type="xsd:string"/>
                   <xsd:element name="price" type="xsd:double"/>
              </xsd:sequence>
         </xsd:complexType>
    </xsd:schema>

    Modified schema
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="item_list">     
    <xsd:complexType>          
    <xsd:sequence>               
    <xsd:element ref="item_info" maxOccurs="unbounded"/>     
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="item_info">
         <xsd:complexType>          
    <xsd:sequence>               
    <xsd:element name="name" type="xsd:string"/>     
         <xsd:element name="price" type="xsd:double"/>     
         </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>

  • How to extract a clob xml string with multiple row of table tag. in 10g

    i have a xml value like:
    <table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
    <table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
    i want to insert each of <c> value in a table with respective columns according c1,c2,c3,c4
    pls suggest me what to do
    I use extract(xml, '/table) tab but it just read first one line & return error for other

    Can you plz explain to me thisIt is because you did not provide us with a valid xml structure so I used 11g's xmlparse function to create a xmltype even with the xml not being valid (no root tag).
    With a valid xml structure I could use the xmltype constructor instead and go on the same way as before:
    SQL> select *
      from xmltable (
             'table'
             passing xmltype ('
                            <root>
                            <table><c1>0</c1><c2>Mr</c2><c3>abc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mrs</c2><c3>abcd</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>sabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mrs</c2><c3>sdabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>dabc</c3><c4>Sharma</c4></table>
                            <table><c1>0</c1><c2>Mr</c2><c3>adbc</c3><c4>Sharma</c4></table>
                            </root>').extract ('root/table')
             columns c1 number path 'c1', c2 varchar2 (4) path 'c2', c3 varchar2 (6) path 'c3', c4 varchar2 (6) path 'c4')
            C1 C2     C3        C4      
             0 Mr     abc       Sharma  
             0 Mrs    abcd      Sharma  
             0 Mr     sabc      Sharma  
             0 Mrs    sdabc     Sharma  
             0 Mr     dabc      Sharma  
             0 Mr     adbc      Sharma  
    6 rows selected.

  • How to handle XML string with Single Quotes as a parameter to SP dynamically?

    Hi,
    I would like to know if there is a way to handle the Single Quotes in XML value when it is passed to Stored Procedure?
    I should be able to handle it without adding another Single Quote to it.
    Thanks,
    Chandra Shekar

    Hi Chandra,
    Your requirement is not precise. Based on my understanding and guessing, are you metioning something like the below sample?
    /*If the xml is generated you have no need to escape the singe quote(')*/
    DECLARE @xmlTbl TABLE (ID INT,name VARCHAR(99));
    INSERT INTO @xmlTbl VALUES(1,'Eric''s')
    INSERT INTO @xmlTbl VALUES(2,'Zhang''s')
    DECLARE @xmlDoc1 XML
    SELECT @xmlDoc1
    FROM @xmlTbl FOR XML PATH('PERSON'),ROOT('PERSONS')
    EXEC yourProcedure @xmlDoc1
    /*If your copy and paste the xml, you have to escape the single quote(') with 2s('')*/
    DECLARE @xmlDoc2 XML
    SET @xmlDoc2 = '<PERSONS>
    <PERSON>
    <ID>1</ID>
    <name>Eric''s</name>
    </PERSON>
    <PERSON>
    <ID>2</ID>
    <name>Zhang''s</name>
    </PERSON>
    </PERSONS>'
    EXEC yourProcedure @xmlDoc2
    If that is not regarding your requirement, please elaborate with more details.
    Eric Zhang
    TechNet Community Support

  • Unmarshaling XML file with JAXB from JAR doesn't work?

    Hi
    I'm pretty new to JAXB... I'm unmarshaling an XML file, and everything works fine in my JUnit test, using XML files. However, the caller of my unmarshalling is a Web Start application using signed JARs.
    When I try to access the XML file, I log the URL and get an exception:
    INFO[slf5s.PRIORITY] javawsApplicationMain[slf5s.THREAD] ch.ige.main.client.menu.MenuBuilder[slf5s.CATEGORY] Creating menu from URL jar:file:C:/Program%20Files/JRE/1.4.2/cache/http/...Main.jar!/res/JippsAdminMenuBaum.xml[slf5s.MESSAGE]
    ERROR[slf5s.PRIORITY] javawsApplicationMain[slf5s.THREAD] ch.ige.main.client.MenuPane[slf5s.CATEGORY] exception caught[slf5s.MESSAGE]
    java.io.IOException: Couldn't unmarshal configuration from java.util.jar.JarVerifier$VerifierStream@15f1f9c: null
         at ch.ige.main.client.menu.MenuBuilder.unmarshalConfiguration(MenuBuilder.java:110)
         at ch.ige.main.client.menu.MenuBuilder.<init>(MenuBuilder.java:86)
         at ch.ige.main.client.MenuPane.createMenuBuilder(MenuPane.java:485)
         at ch.ige.main.client.MenuPane.createTreeLevel(MenuPane.java:460)
         at ch.ige.main.client.MenuPane.jbInit(MenuPane.java:316)
         at ch.ige.main.client.MenuPane.<init>(MenuPane.java:122)
         at ch.ige.jippsadmin.MepJipps.<init>(MepJipps.java:32)
         at ch.ige.jippsadmin.JippsMain.run(JippsMain.java:64)
         at ch.ige.auth.ClientAuthenticator.executePrivilegedCode(ClientAuthenticator.java:166)
         at ch.ige.authz.client.AuthMain.executePrivilegedCode(AuthMain.java:128)
         at ch.ige.authz.client.AuthMain.run(AuthMain.java:213)
         at ch.ige.jippsadmin.JippsMain.main(JippsMain.java:77)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)Btw, does anyone know where to find the runtime JARs that are required for JAXB (from JWSDP 1.5)?
    Thanks & best regards,
    Eric

    Well... once again this was a ClassLoader problem... solved!

  • Error while generating an XML Document from XML Schema with JAXB

    Hi,
    I am following this OTN tutorial to generate the XML document from Java classes got from the XSD document.
    http://www.oracle.com/technology/pub/notes/technote_jaxb.html
    I am able to generate all the Java classes but getting error on compiling the XMLConstructor.java class which is use for generating the XML document :
    I am using JDK 1.5 and
    Oracle 10g XML Developer's Kit (XDK) Production for Java. xdk_nt_10_1_0_2_0_production
    (though these are warnings I am not able to run it.)
    Error
    C:\Prototype\classes\jaxbderived\catalog>javac -Xlint XMLConstructor.java
    warning: [path] bad path element "%CLASSPATH%": no such file or directory
    XMLConstructor.java:42: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
    journalList.add(journal);
    ^
    XMLConstructor.java:46: warning: [unchecked] unchecked call to add(E) as a membe
    r of the raw type java.util.List
    articleList.add(article);
    Thanks
    Sanjeev ([email protected])

    Use JDK 1.4.

  • Remove XML element with JAXB

    Hi all,
    does anyone knows if it's possible to remove an xml element after that element has been set ? Using only jaxb if possible and not using other technology, for example DOM.
    I explain:
    umarshall car -->setOwner("me"); setSpeed("80"); -->marshall car
    will result into:
    <car>
    <owner>me</owner>
    <speed>80</speed>
    </car>
    I would like something that for example
    unmarshall car -->remove(speed); ....-->marshall car
    would result into:
    <car>
    <owner>me</owner>
    </car>
    could someone point out a way to do that ?
    thanks in advance...

    Okay, after peering over your code and trying a few things out I see one immediate problem and one possible improvement.
    The problem lies in this:
    1. if condition is true, remove item
    2. check recursively
    The problem is .. if an item is removed, the following recursive check will always fail. However, the entire loop is wrapped into a try..catch, so InDesign will not alert you that it failed. Instead, it will continue with what's after the loop, exactly because the try..catch is around the entire loop!
    Change the loop code to this
    if((elm.xmlElements[i].markupTag.name == "http") && (elm.xmlElements[i].parent.markupTag.name == "extlink"))
        var Store_CitAttri = elm.xmlElements[i].xmlAttributes.item("c_style").value;
        if(Store_CitAttri == "URL")
          elm.xmlElements[i].remove();
           foundtext = foundtext + 1;
           continue;
    Query_Remove(elm.xmlElements[i]);
    so the recursive checking is skipped. You can also remove the entire try..catch block, as this may hide additional errors ...
    The improvement is: as I started reading this thread from the top again, shouldn't you be removing the "extlink" items, rather than just the "http" ones inside?
    If so, remove the parent of the found item (which is always the "extlink"):
          elm.xmlElements[i].parent.remove();
    -- and, as this will break the loop (because you just removed the set of elements it was working in!), replace 'continue' with 'return'.
    Hope this helps

  • How to marshal XML fragments with JAXB

    Hello,
    I have Object unashamed from XML. I would like to insert part of this object in another XML document. I�m using Cocoon Transformer for this. In startElement then I detect element which I would like replace I would like to write something like this:
    Marshaller m = jc.createMarshaller();
    m.marshal(myElem, contentHandler);
    However this method try to marshal it as whole document with: <?xml version="1.0" encoding="UTF-8" ?> This probably case problems for next Transformer.
    I have this problem in Cocoon and with SAX, but there should be some general solution to marshal JAXB objects as XML fragments, not whole documents. However I can�t found it.
    Thanks for any help
    Arek Stryjski

    In JAXB mailing list I got this answer:
    It currently doesn't have any explicit support for fragment marshalling,
    but like you said, you can easily write an XMLFilter that blocks
    start|endDocument. In your case, you just need to:
    Marshaller m = jc.createMarshaller();
    m.marshal(myElem, new FragmentFilter(contentHandler));
    where FragmentFilter is:
    class FragmentFilter extends XMLFilterImpl {
    FragmentFilter( ContentHandler handler ) {
    setContentHandler(handler);
    public void startDocument() {}
    public void endDocument() {}
    Perhaps this could be another example.
    regards,
    Kohsuke KAWAGUCHI

  • XML-Deserialize with JAXB

    Hello!
    I'm new to JAXB so maybe my question is a newbie question.
    Why can I deserialize the following XML:
    <ns3:vida xmlns:ns3="http://cpsnet.de/dms/schnittstellen/volvo/vida_dms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    </ns3:vida> but I can't deserialize this one:
    <vida xmlns="http://cpsnet.de/dms/schnittstellen/volvo/vida_dms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    </vida>As far as I understand XML right now, they are both the same. Aren't they?
    The Unmarshaller returns the Object for the first XML - but returns null on the second one...

    Well... once again this was a ClassLoader problem... solved!

Maybe you are looking for

  • X2-01 : Blank entry in my call log!!!

    I updated my X2-01 to v08.63 yesterday.It had no other problems.But now there is a blank entry in the call log and i cant delete it.I've tried the backup and restore solution for blank msg bug,but it didnot work. Somebody please help me.....

  • Cannot get 5.1 Surround Sound with optic fiber cable (Mini Toslink)

    I have a Macbook Pro (Early 2011 Model) and after spending lot of time I figured out that the best way to get 5.1 surround sound output is to connect the MBP to the AV Receiver with the optic fiber cable (Via Mini Toslink Adapter). So after reading a

  • Apple id not working with ipod

    I'm getting really frustrated. My Apple ID is NOT working for my ipod touch. Yet no problems on my iphone and ipad. Always getting the error "Could not sign in. Please check your network connection and try again" My network is just fine. Anyone have

  • Function module to display process overview log from SM66 Transaction

    Hi, I want to display process overview log from SM66 Transaction in a report. Is there a function module which will help me in achieving that or is there any other method. Thanks in advance, Sandeep.

  • ITunes Store Australia / Movie of the Week

    Does anybody know how often does the Australian iTunes Store change their movie of the week selection? It seems more like a movie of the month or even more than that... The US store makes changes to their features every Tuesday, how about Oz? Can any