Dom element to string
I have a method, the argument being passed in is a dom element.
The method will convert the element(and child node) to string. The string is then passed into a buffer writer to write to a file.
What is the easiest/fastest way to convert the dom element to string?
Is there a better way to write the element to a file?
Any sample code available?
You could try something like this:
String elementToString(Element element)
throws Exception
StringWriter sw = new StringWriter();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
DOMSource source = new DOMSource(element);
StreamResult result = new StreamResult(sw);
transformer.transform(source, result);
return sw.toString();
}Regards
Similar Messages
-
It sounds very simple, however could not find any solution using JAXP.
What I need is that I have a DOM element, I want to convert the DOM element into String and store into the database. I used to do it using JDOM. It has a feature something like toString.
I know that serialization is another option, however, want to know how to do this way.xmlString.getBytes()No, that causes your problem. Read the documentation to see what the getBytes() method does. Here's what you should do instead:Document document = documentBuilder.parse(new InputSource(new StringReader(xmlString)));This doesn't convert from String to bytes using a bad encoding. But you also say:
xmlString contains Japanese characters and was originally from a xml file with UTF-8 encoing.In this case there's a good chance that in reading from the file to the String you have also failed to use UTF-8 to do the decoding. Why not just pass a File object to the parser and let it deal with the encoding issues? It knows what to do. -
I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
I will upload the 3 files that are being used for this.
When I rebuild my files I get the following error in CustomerCO.java:
Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
Line 78 reads as follows:
String Status = (String)am.invokeMethod("initSaveXml", wsXml);
Any suggestions?
PS: I am a newbie to java and framework :-(
Here are my files:
CustomerCO.java:
/*===========================================================================+
| Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
| All rights reserved. |
+===========================================================================+
| HISTORY |
+===========================================================================*/
package xxcu.oracle.apps.ar.customer.server.webui;
import java.io.Serializable;
import java.lang.Exception;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import org.w3c.dom.Element;
import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
* Controller for ...
public class CustomerCO extends OAControllerImpl implements Serializable
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
* 2009.07.09, Roy Feirud, lagt til for å utføre spørring
if (pageContext.getParameter("Search") != null)
OAApplicationModule am = pageContext.getApplicationModule(webBean);
//Setter søkekriteriene til LindorffWS
String Name = pageContext.getParameter("SearchName");
String Address = pageContext.getParameter("SearchAddress");
String Zip = pageContext.getParameter("SearchZipCode");
String City = pageContext.getParameter("SearchCity");
String Born = pageContext.getParameter("SearchBorn");
String Phone = pageContext.getParameter("SearchPhoneNo");
Serializable[] param = { Name, Address, Zip, City, Born, Phone };
//Bygger søkestrengen
String SearchString = (String)am.invokeMethod("initBuildString", param );
//Initialiserer LindorffWS
LindorffWS WsConnection = new LindorffWS();
try
//Kaller Web Sevice fra Lindorff
Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
String Status = (String)am.invokeMethod("initSaveXml", wsXml);
catch(Exception WsExp)
// WsConnection = new LindorffWS();
System.out.println("Kall til LindorffWS feilet!");
am.invokeMethod("initQueryCustomer");
CustomerAMImpl.java:
package xxcu.oracle.apps.ar.customer.server;
import java.io.Serializable;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.sql.Types;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAExceptionUtils;
import org.w3c.dom.Element;
// --- File generated by Oracle Business Components for Java.
public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
* This is the default constructor (do not remove)
public CustomerAMImpl()
* Sample main for debugging Business Components code using the tester.
public static void main(String[] args)
launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
* Container's getter for CustomerVO1
public CustomerVOImpl getCustomerVO1()
return (CustomerVOImpl)findViewObject("CustomerVO1");
* 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
public void initQueryCustomer()
CustomerVOImpl vo = getCustomerVO1();
if (vo!=null)
vo.initQuery();
* 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
public String initBuildString(String Name
,String Address
,String Zip
,String City
,String Born
,String Phone)
String ws_string = null;
CallableStatement cs = null;
try
String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
OADBTransaction txn = getOADBTransaction();
cs = txn.createCallableStatement(sql,1);
cs.setString(1,Name);
cs.setString(2,Address);
cs.setString(3,Zip);
cs.setString(4,City);
cs.setString(5,Born);
cs.setString(6,Phone);
cs.registerOutParameter(7,Types.VARCHAR);
cs.execute();
OAExceptionUtils.checkErrors (txn);
ws_string = cs.getString(7);
cs.close();
catch (SQLException sqle)
String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
String Errmsg = sqle.toString();
MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
return ws_string;
public String initSaveXml(Element WsXml)
String Status = "Error";
CallableStatement cs = null;
try
String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
OADBTransaction txn = getOADBTransaction();
cs = txn.createCallableStatement(sql,1);
cs.setObject(1,WsXml);
cs.registerOutParameter(2,Types.VARCHAR);
cs.execute();
OAExceptionUtils.checkErrors (txn);
Status = cs.getString(2);
cs.close();
catch (SQLException sqle)
String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
String Errmsg = sqle.toString();
MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
return Status;
LindorffWS.java:
package xxcu.oracle.apps.ar.customer.ws;
import oracle.soap.transport.http.OracleSOAPHTTPConnection;
//import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.encoding.SOAPMappingRegistry;
//import org.apache.soap.util.xml.QName;
import java.util.Vector;
import org.w3c.dom.Element;
import java.net.URL;
import org.apache.soap.Body;
import org.apache.soap.Envelope;
import org.apache.soap.messaging.Message;
import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
* Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
* Date Created: Fri Jul 10 10:37:21 CEST 2009
* WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
public class LindorffWS extends WrappedDocLiteralStub
public LindorffWS()
m_httpConnection = new OracleSOAPHTTPConnection();
public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
private OracleSOAPHTTPConnection m_httpConnection = null;
private SOAPMappingRegistry m_smr = null;
public Element XmlFulltextOperator(String xmlString) throws Exception
URL endpointURL = new URL(endpoint);
Envelope requestEnv = new Envelope();
Body requestBody = new Body();
Vector requestBodyEntries = new Vector();
String wrappingName = "XmlFulltextOperator";
String targetNamespace = "http://services.lindorffmatch.com/search";
Vector requestData = new Vector();
requestData.add(new Object[] {"xmlString", xmlString});
requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
requestBody.setBodyEntries(requestBodyEntries);
requestEnv.setBody(requestBody);
Message msg = new Message();
msg.setSOAPTransport(m_httpConnection);
msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
Envelope responseEnv = msg.receiveEnvelope();
Body responseBody = responseEnv.getBody();
Vector responseData = responseBody.getBodyEntries();
return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
_______________________________________________________________________________________________________________________________Hi,
Create an Interface to your application Module then from interface call your method,
refer http://www.oraclearea51.com/oracle-technical-articles/oa-framework/oa-framework-beginners-guide/213-how-to-call-am-methods-from-controller-without-using-invokemethod.html for creating Interface for AM and calling it in controller.
Regards,
Reetesh Sharma -
I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
I will upload the 3 files that are being used for this.
When I rebuild my files I get the following error in CustomerCO.java:
Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
Line 78 reads as follows:
String Status = (String)am.invokeMethod("initSaveXml", wsXml);
Any suggestions?
PS: I am a newbie to java and framework
Here are my files:
CustomerCO.java:
/*===========================================================================+
Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA
All rights reserved.
===========================================================================
HISTORY
+===========================================================================*/
package xxcu.oracle.apps.ar.customer.server.webui;
import java.io.Serializable;
import java.lang.Exception;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import org.w3c.dom.Element;
import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
* Controller for ...
public class CustomerCO extends OAControllerImpl implements Serializable
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
* 2009.07.09, Roy Feirud, lagt til for å utføre spørring
if (pageContext.getParameter("Search") != null)
OAApplicationModule am = pageContext.getApplicationModule(webBean);
//Setter søkekriteriene til LindorffWS
String Name = pageContext.getParameter("SearchName");
String Address = pageContext.getParameter("SearchAddress");
String Zip = pageContext.getParameter("SearchZipCode");
String City = pageContext.getParameter("SearchCity");
String Born = pageContext.getParameter("SearchBorn");
String Phone = pageContext.getParameter("SearchPhoneNo");
Serializable[] param = { Name, Address, Zip, City, Born, Phone };
//Bygger søkestrengen
String SearchString = (String)am.invokeMethod("initBuildString", param );
//Initialiserer LindorffWS
LindorffWS WsConnection = new LindorffWS();
try
//Kaller Web Sevice fra Lindorff
Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
String Status = (String)am.invokeMethod("initSaveXml", wsXml);
catch(Exception WsExp)
// WsConnection = new LindorffWS();
System.out.println("Kall til LindorffWS feilet!");
am.invokeMethod("initQueryCustomer");
CustomerAMImpl.java:
package xxcu.oracle.apps.ar.customer.server;
import java.io.Serializable;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.sql.Types;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OAExceptionUtils;
import org.w3c.dom.Element;
// --- File generated by Oracle Business Components for Java.
public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
* This is the default constructor (do not remove)
public CustomerAMImpl()
* Sample main for debugging Business Components code using the tester.
public static void main(String[] args)
launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
* Container's getter for CustomerVO1
public CustomerVOImpl getCustomerVO1()
return (CustomerVOImpl)findViewObject("CustomerVO1");
* 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
public void initQueryCustomer()
CustomerVOImpl vo = getCustomerVO1();
if (vo!=null)
vo.initQuery();
* 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
public String initBuildString(String Name
,String Address
,String Zip
,String City
,String Born
,String Phone)
String ws_string = null;
CallableStatement cs = null;
try
String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
OADBTransaction txn = getOADBTransaction();
cs = txn.createCallableStatement(sql,1);
cs.setString(1,Name);
cs.setString(2,Address);
cs.setString(3,Zip);
cs.setString(4,City);
cs.setString(5,Born);
cs.setString(6,Phone);
cs.registerOutParameter(7,Types.VARCHAR);
cs.execute();
OAExceptionUtils.checkErrors (txn);
ws_string = cs.getString(7);
cs.close();
catch (SQLException sqle)
String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
String Errmsg = sqle.toString();
MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
return ws_string;
public String initSaveXml(Element WsXml)
String Status = "Error";
CallableStatement cs = null;
try
String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
OADBTransaction txn = getOADBTransaction();
cs = txn.createCallableStatement(sql,1);
cs.setObject(1,WsXml);
cs.registerOutParameter(2,Types.VARCHAR);
cs.execute();
OAExceptionUtils.checkErrors (txn);
Status = cs.getString(2);
cs.close();
catch (SQLException sqle)
String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
String Errmsg = sqle.toString();
MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
return Status;
LindorffWS.java:
package xxcu.oracle.apps.ar.customer.ws;
import oracle.soap.transport.http.OracleSOAPHTTPConnection;
//import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.encoding.SOAPMappingRegistry;
//import org.apache.soap.util.xml.QName;
import java.util.Vector;
import org.w3c.dom.Element;
import java.net.URL;
import org.apache.soap.Body;
import org.apache.soap.Envelope;
import org.apache.soap.messaging.Message;
import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
* Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
* Date Created: Fri Jul 10 10:37:21 CEST 2009
* WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
public class LindorffWS extends WrappedDocLiteralStub
public LindorffWS()
m_httpConnection = new OracleSOAPHTTPConnection();
public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
private OracleSOAPHTTPConnection m_httpConnection = null;
private SOAPMappingRegistry m_smr = null;
public Element XmlFulltextOperator(String xmlString) throws Exception
URL endpointURL = new URL(endpoint);
Envelope requestEnv = new Envelope();
Body requestBody = new Body();
Vector requestBodyEntries = new Vector();
String wrappingName = "XmlFulltextOperator";
String targetNamespace = "http://services.lindorffmatch.com/search";
Vector requestData = new Vector();
requestData.add(new Object[] {"xmlString", xmlString});
requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
requestBody.setBodyEntries(requestBodyEntries);
requestEnv.setBody(requestBody);
Message msg = new Message();
msg.setSOAPTransport(m_httpConnection);
msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
Envelope responseEnv = msg.receiveEnvelope();
Body responseBody = responseEnv.getBody();
Vector responseData = responseBody.getBodyEntries();
return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
_______________________________________________________________________________________________________________________________Hi,
wrong forum. If this is a problem related to the use of OA framework, please use the OA framework forum here on OTN
Frank -
How to typecast string to xml DOM element in java
hai
i need a string to be converted to xml DOM element in java, can any help me
i have done in this way
NodeList children = lParentRule.getElementsByTagName("parentruledetails").item(0).getChildNodes();
for
(int i = 0; i < children.getLength(); i++) {Node nod = children.item(i);
if
(nod.getNodeName().contains("parentcustomdetails")){Element parentcustom = (Element)nod.getNodeName(); // i get typecast error at this line}
i need to convert the string to element
can any one help me
Thanks in AdvanceHello. You can't cast a string to an element, you need to create that element.
Maybe this can help up: http://www.genedavis.com/library/xml/java_dom_xml_creation.jsp -
Invoking BPEL process from Java servlet with org.w3c.dom.Element as payload
Hello,
I'm trying to initiate a BPEL process from my servlet running under Tomcat. When I create the NormalizedMessage passing the XML as a String everything works fine. But if I use an org.w3c.domElement the BPEL server doesn't react at all (even on DEBUG log level there are no outputs).
This works:
NormalizedMessage message = new NormalizedMessage();
message.addPart("payload", "<foo></foo>");
This doesn't work:
org.w3c.dom.Element elem;
oracle.xml.parser.v2.XMLDocument xmlDocument;
NormalizedMessage message = new NormalizedMessage();
Element elem = xmlDocument.createElement("foo");
message.addPart("payload", elem);
Is there a known problem with payloads using Element or did I get something completely wrong? Thanks in advance,
Hans.Hello,
I'm trying to initiate a BPEL process from my servlet running under Tomcat. When I create the NormalizedMessage passing the XML as a String everything works fine. But if I use an org.w3c.domElement the BPEL server doesn't react at all (even on DEBUG log level there are no outputs).
This works:
NormalizedMessage message = new NormalizedMessage();
message.addPart("payload", "<foo></foo>");
This doesn't work:
org.w3c.dom.Element elem;
oracle.xml.parser.v2.XMLDocument xmlDocument;
NormalizedMessage message = new NormalizedMessage();
Element elem = xmlDocument.createElement("foo");
message.addPart("payload", elem);
Is there a known problem with payloads using Element or did I get something completely wrong? Thanks in advance,
Hans. -
XML Element to string conversion returning null
Hi,
When i try to convert XML Element to string using toString() API, it returns something like [device: null] where device is element tag.
Code is as follows -
Document xmlDoc;
DOMParser parser = (DOMParser)Class.forName("org.apache.xerces.parsers.DOMParser").newInstance();
parser.setFeature( "http://apache.org/xml/features/dom/defer-node-expansion", true );
parser.parse(new InputSource(new StringReader(tableStr)));
xmlDoc = parser.getDocument();
Element root = xmlDoc.getDocumentElement();
NodeList nodeList = root.getElementsByTagName("device");
Element deviceNode = (Element)nodeList.item(nodeList.getLength()-1);
System.out.println(deviceNode.toString()); //prints [device: null] ????
System.out.println(deviceNode.getAttribute("ipAddress")); //prints correct ip address
Any idea why i am getting [device: null] when trying to convert Element to String though attribute value is retrieved.
Thanks,
DeepakHello ,
I want to get the root node (<ZTOP60_XML_TAG_STRUCTURE>
) of the following xml file .
<?xml version="1.0" encoding="utf-8"?>
<ZTOP60_XML_TAG_STRUCTURE>
<MSGTYPE>NAPOBACK</MSGTYPE>
<SNDPRN>657393485</SNDPRN>
<RECEIVER/>
<RCVPRN>GSOHUBDM1</RCVPRN>
<PONUM/>
<VENDCODE>0020040266</VENDCODE>
<VENDUNS>002601768</VENDUNS>
<PARTNERFUNC_WE>WE</PARTNERFUNC_WE>
<PARTNERNUM_WE>C240</PARTNERNUM_WE>
<LINE_ITEMS>
<item>
<ITEMNUM>00687</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>7.000</GRQTY>
<NETVAL>339.65</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FE-26865-01</MATNUM>
<MATDESC>PTR, T632, LEXMARK 5-BIN MAILBOX</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00178</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>303.000</GRQTY>
<NETVAL>18.62</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FE-ZZYRG-01</MATNUM>
<MATDESC>FDD,FDI-PC,1.44MB,3.5 ,HH</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00157</ITEMNUM>
<POQTY>999999998.000</POQTY>
<BOQTY>24.000</BOQTY>
<GRQTY>303.000</GRQTY>
<NETVAL>26.25</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FE-25094-01</MATNUM>
<MATDESC>MOUSE,PC,3BUT,,INTELLIMOUSE,PS2</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00881</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>62.000</GRQTY>
<NETVAL>368.80</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FD-66515-01</MATNUM>
<MATDESC>ITU MODULE ASM</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00223</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>377.000</GRQTY>
<NETVAL>459.28</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FD-65336-01</MATNUM>
<MATDESC>MAIN SYSTEM BOARD T23 (2647)</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00081</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>19.000</BOQTY>
<GRQTY>810.000</GRQTY>
<NETVAL>217.21</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FD-64199-01</MATNUM>
<MATDESC>QST- CADET 100</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00271</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>136.000</GRQTY>
<NETVAL>813.76</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>FD-60065-01</MATNUM>
<MATDESC>SMART UPS 3000VA RM</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00791</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>3.000</GRQTY>
<NETVAL>201.73</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>3X-PBXGG-AA</MATNUM>
<MATDESC>ATI 7500 PCI GRAPHICS</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00173</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>32.000</GRQTY>
<NETVAL>7.50</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>12-56178-01</MATNUM>
<MATDESC>CARD GUIDE,SNAP-IN,LOW PROFILE,2.5 INCHE</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00309</ITEMNUM>
<POQTY>999999998.000</POQTY>
<BOQTY>15.000</BOQTY>
<GRQTY>71.000</GRQTY>
<NETVAL>51.23</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>30-51476-01</MATNUM>
<MATDESC>VHDI-CABLE WIDE 12 FT. DT-AB001-TQ</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
<item>
<ITEMNUM>00194</ITEMNUM>
<POQTY>999999999.000</POQTY>
<BOQTY>1.000</BOQTY>
<GRQTY>147.000</GRQTY>
<NETVAL>345.48</NETVAL>
<PLANT>C240</PLANT>
<MATNUM>29-33689-01</MATNUM>
<MATDESC>PTR,IMP9,B/W,PAR/SER,110/240,R</MATDESC>
<PONUMBER>6500022388</PONUMBER>
<EKGRP>U17</EKGRP>
<DISPO>N07</DISPO>
</item>
</LINE_ITEMS>
</ZTOP60_XML_TAG_STRUCTURE>
I wrote the following lines of code ..
FTI .. >> String strMsg =((javax.jms.TextMessage)msg).getText();
StrMsg is a string that represents an xml file .
DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = docfactory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(strMsg)));
Element root = doc.getDocumentElement();
System.out.println("The root is " + root);
String strFileName = root+".xml" ;
System.out.println("The file name is " + strFileName);
File f = new File (strFileName);
FileOutputStream fos = new FileOutputStream( f );
for ( int j =0 ; j < strMsg.length(); j++)
char c = strMsg.charAt(j);
fos.write((int)c);
I am getting the following error ...
The root is [ZTOP60_XML_TAG_STRUCTURE: null]
The file name is [ZTOP60_XML_TAG_STRUCTURE: null].xml
Whey the file name or root is with special character [ ] and null ..
I want just ZTOP60_XML_TAG_STRUCTURE.xml .
Can anyone help me .
thanks
mahesh -
Org.w3c.dom.Element to javax.xml.soap.SOAPElement
I have a org.w3c.dom.Element that I want to insert into an existing SOAPBody using
public SOAPElement addChildElement(SOAPElement element). How can I turn the org.w3c.dom.Element
into a javax.xml.soap.SOAPElement so that I can do that?
Steve WatsonHi Steve,
Here's a code segment that may be of some value.
Bruce
public SOAPElement populateSOAPElement(SOAPEnvelope envelope,
SOAPElement element, Element sndElement) throws SOAPException{
int i, j;
NamedNodeMap map;
Node node;
NodeList list;
SOAPElement subElement;
//populate attributes
map = sndElement.getAttributes();
for (j = 0; j < map.getLength(); j ++)
node = map.item(j);
element.addAttribute(envelope.createName(node.getNodeName()),
sndElement.getAttribute(node.getNodeName()));
//populate the element value and subElements
list = sndElement.getChildNodes();
for (j = 0; j < list.getLength(); j ++)
short type = list.item(j).getNodeType();
String typeString = "";
if (list.item(j).getNodeType() == 3)
element.addTextNode(list.item(j).getNodeValue());
if(list.item(j).getNodeType() == 1)
subElement =
element.addChildElement(((Element)list.item(j)).getTagName());
subElement = populateSOAPElement(envelope, subElement,
(Element)list.item(j));
return element;
Steve wrote:
>
I have a org.w3c.dom.Element that I want to insert into an existing SOAPBody using
public SOAPElement addChildElement(SOAPElement element). How can I turn the org.w3c.dom.Element
into a javax.xml.soap.SOAPElement so that I can do that?
Steve Watson -
Dom elements in different encodings
Hi
I'm creating a DOM element in memory, which should hold strings in all sorts of languages (English, Spanish, Russian, Chinese etc.). This elements are returned to the client via web-services with no problems.
I now need to support devices that do not support UTF-8. I can get from the client the charset it needs, but I need to create the DOM element in the requested charset - how can I do that?
As I understand - all my Strings are held in memory as Unicode Strings, what I don't know how to do is to encode the XML in the correct charset.
Thankshi,
I guess it was not transported properly.
I would suggest to create a transport request and add the following line (this will tak everything related to the program):
R3TR PROG program_name
You have import this request ino the target system and it should work fine.
hope this helps
ec -
Hello all,
I recently developed a app that utilizes a xml file for a database.
I generated a war file and sent it to a co worker for deployment.
He gets the following error when he tries to access a jsp
javax.servlet.ServletException: org.w3c.dom.Element.getTextContent()Ljava/lang/String;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.services_jsp._jspService(services_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoSuchMethodError: org.w3c.dom.Element.getTextContent()Ljava/lang/String;
GSMPackage.GSMManager.getNodeList(GSMManager.java:184)
GSMPackage.GSMManager.getExistingServices(GSMManager.java:283)
org.apache.jsp.services_jsp._jspService(services_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)I had him check his java version using java -version he has 1.5.
This method that errors is a 1.5 source error from what I have read.
Is there something else I can look at?
Thanks.Thanks.
I thought that the method in question was the getTextContext() method. ?
org.w3c.dom.Element.getTextContent()Ljava/lang/String
This is the method that contains the line in question(line 184 is last line):
public ArrayList getNodeList()
ArrayList arraylist = new ArrayList();
try
String serviceHostPort = null;
Document document = this.getDocument();
if(file.exists())
NodeList serviceName = document.getElementsByTagName("ServiceName");
NodeList serviceHost = document.getElementsByTagName("ServiceHost");
NodeList servicePort = document.getElementsByTagName("ServicePort");
if(serviceName.getLength() > 0)
for(int i=0;i<serviceName.getLength();i++)
Element serviceNameElement = (Element) serviceName.item(i); //CREATE THE SERVICE NAME ELEMENT
String serviceNameString = serviceNameElement.getTextContent(); //CREATE THE SERVICE NAME CONTENT THIS IS THE LINE IN QUESTION Thanks! -
Org.w3c.dom.Element Serialization
I see in the serialization list that org.w3c.dom.Document get's serialized to XML, but is there a reason why org.w3c.dom.Element only get's serialized to an object? I would think that it should also be serialized to an XML Object, is there a way to do this without having to implement custom serialization for the type?
I found another way to do this using the BlazeDS BeanProxy. Essentially when marshalling the object to Blaze I convert the Element to a String (could be a Dom if I chose, but String was sufficient) and on the way back I build it back out.
http://bugs.adobe.com/jira/browse/BLZ-305 is the place I got the details from. -
Wrapping XML into a org.w3c.dom.Element
Many XML tools like JAXB or Axis are able to marshal objects representing XML via a java.io.Writer.
We often use the StringWriter implementation that allows us to have the XML in a String format.
Currently, I access a web service via Axis. I can successfully serialize my axis beans to XML Strings, but now I need to "wrap" my axis beans into a dom Elements.
How can I do this ?
Is there a kind of Writer that will allow me to create a dom Element instead of a String when marshalling?
Thanks in advance.Yeah!
I have resolved it .
It take me one day time!
my error is 1: Element which I used is no namespace.
2: no import enough jar files
just so so .
sorry! I am poor in English -
Validate org.w3c.dom.Element against xsd
I need to validate a org.w3c.dom.Element against an xsd.
DOMParser dp = new DOMParser();
URL xmlurl = new URL("file:\\test.xml");
XSDBuilder builder = new XSDBuilder();
URL xsdurl = new URL("file:\\test.xsd");
XMLSchema schemadoc = (XMLSchema)builder.build(xsdurl);
dp.setXMLSchema(schemadoc);
dp.setValidationMode(XMLParser.SCHEMA_LAX_VALIDATION);
dp.setPreserveWhitespace(true);
dp.setErrorStream (System.out);
System.out.println("Parsing "+xmlurl);
dp.parse(xmlurl);
This works when my input is an xml file. I cannot get it work against an element. If I convert the element as a string or inputsource it gives the error
"XML-20220: (Fatal Error) Invalid InputSource.
java.net.MalformedURLException: no protocol:"
Any idea how it can be done? I am using jdeveloper 10.1.2
Thanks
MMThanks for the reply. I get the following error.
Exception in thread main
oracle.xml.parser.v2.XMLDOMException: cannot add a node belonging to a different document
at oracle.xml.parser.v2.XMLNSNode.checkNodePermissions(XMLNSNode.java:854)
at oracle.xml.parser.v2.XMLNSNode.appendChild(XMLNSNode.java:257)
at oracle.xml.parser.v2.XMLDocument.appendChild(XMLDocument.java:1010)
at test.parser.ParseTest.parse1(ParseTest.java:136)
at test.parser.ParseTest.main(ParseTest.java:63)
Process exited with exit code 1.
This is my code
public void parse1(Element elem) {
try{
//Element docElement;
//Node elemNode=(Node)docElement;
DOMParser dp1 = new DOMParser();
XMLDocument xmlDocument=new XMLDocument();
xmlDocument.appendChild(elem);
ByteArrayOutputStream docOutputStream = new ByteArrayOutputStream();
xmlDocument.print(docOutputStream);
ByteArrayInputStream docInputStream = new ByteArrayInputStream(docOutputStream.toByteArray());
InputSource inputSource = new InputSource(docInputStream);
dp1.parse(inputSource);
catch (IOException e){e.printStackTrace();}
catch (XMLParseException e){e.printStackTrace();}
catch (SAXException e){e.printStackTrace();}
Thanks
MM -
Is there a way to inhibit the DOM element explorer input capability? I have an api that is pulling in a non encrypted macro and passing it in as a param to my form. I have the shell that redirects the link quickly so that the user can not change the url
via the address bar, then I test the calling request header to make sure it's originating from our server. This was the work around but someone has used the DOM element explorer and changed the query string parameter before the call and has gotten
a different clients info. Is there a way to mask the explorer and href? Or disable Dev tools? Or make it output only?disable Dev tools?
GPEdit.msc Turn on Filtering. Filter word: Developer. Find, in Administrative Templates:
Turn off Developer Tools
Robert Aldwinckle -
More interoperability issues : DOM Element return type
Hi,
Tested JDev9.0.3 a bit further. I have a BC4J Application Module exposed method which returns an XMLElement object (the XML dump for a specific query result on a BC4J View Object) once it gets called. I've generated a Web Service Class on the Application Model.
I've tried to test test this Web Service class locally in JDev 9.0.3 using a local main routine... no problem. However when I deploy the webservice to my OC4J environment and try to access the service using the generated stub/skeleton I get yet another exception:
java.lang.NoSuchMethodError: void oracle.xml.parser.v2.XMLNode.setNodeFlag(int)
void oracle.xml.parser.v2.XMLEntity.<init>(java.lang.String, boolean, int, boolean)
XMLEntity.java:156
void oracle.xml.parser.v2.DTD.<clinit>()
DTD.java:772
void oracle.xml.parser.v2.NonValidatingParser.<init>()
NonValidatingParser.java:135
void oracle.xml.parser.v2.XMLParser.<init>()
XMLParser.java:113
void oracle.xml.parser.v2.DOMParser.<init>()
DOMParser.java:79
void oracle.xml.jaxp.JXDocumentBuilder.<init>()
JXDocumentBuilder.java:71
javax.xml.parsers.DocumentBuilder oracle.xml.jaxp.JXDocumentBuilderFactory.newDocumentBuilder()
JXDocumentBuilderFactory.java:71
javax.xml.parsers.DocumentBuilder org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder()
XMLParserUtils.java:138
org.apache.soap.rpc.Response org.apache.soap.rpc.Call.invoke(java.net.URL, java.lang.String)
Call.java:263
org.w3c.dom.Element com.cumquatit.ws.demo.weather.DBModelWSStub.getWeatherReport(java.lang.String)
DBModelWSStub.java:60
void com.cumquatit.ws.demo.weather.DBModelWSStub.main(java.lang.String[])
DBModelWSStub.java:33
Exception in thread main
Process exited with exit code 1.
Any ideas, anyone?To follow up on my previous post. I've inspected the data going back-and-forth using the TCP Packet Monitor. Strangely (or not) enough this shows me the response document seems to be okay. I don't understand why the error message a shown in my previous post occurs.
HTTP/1.1 100 Continue
Server: Oracle9iAS (9.0.2.0.0) Containers for J2EE
Date: Tue, 24 Sep 2002 14:09:41 GMT
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2002 14:09:42 GMT
Server: Oracle9iAS (9.0.2.0.0) Containers for J2EE
Content-Length: 2498
Set-Cookie: JSESSIONID=6d1dbfb3ceb94564a92ae27b36aa6f86; Path=/
Cache-Control: private
Connection: Close
Content-Type: text/xml; charset=utf-8
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getWeatherReportResponse xmlns:ns1="com.cumquatit.ws.demo.model.DBModelWS" SOAP-ENV:encodingStyle="http://xml.apache.org/xml-soap/literalxml">
<return>
<WheaterReports>
<WheaterReportsRow>
<Id>2</Id>
<DateTime>2000-12-26 13:22:20.0</DateTime>
<City>1</City>
<CurrentConditions>
<CurrentConditionsT>
<CurrentConditionsT_WeatherCode>10</CurrentConditionsT_WeatherCode>
<CurrentConditionsT_Temperature>28</CurrentConditionsT_Temperature>
<CurrentConditionsT_Wind>
<WindT>
<WindT_Speed>40</WindT_Speed>
<WindT_Direction>SE</WindT_Direction>
</WindT>
</CurrentConditionsT_Wind>
</CurrentConditionsT>
</CurrentConditions>
<MorningForecast>
<ShortTermForecastT>
<ShortTermForecastT_WeatherCode>10</ShortTermForecastT_WeatherCode>
<ShortTermForecastT_Temperature>30</ShortTermForecastT_Temperature>
<ShortTermForecastT_Pop>20</ShortTermForecastT_Pop>
</ShortTermForecastT>
</MorningForecast>
<AfternoonForecast>
<ShortTermForecastT>
<ShortTermForecastT_WeatherCode>10</ShortTermForecastT_WeatherCode>
<ShortTermForecastT_Temperature>30</ShortTermForecastT_Temperature>
<ShortTermForecastT_Pop>20</ShortTermForecastT_Pop>
</ShortTermForecastT>
</AfternoonForecast>
<NightForecast>
<ShortTermForecastT>
<ShortTermForecastT_WeatherCode>10</ShortTermForecastT_WeatherCode>
<ShortTermForecastT_Temperature>30</ShortTermForecastT_Temperature>
<ShortTermForecastT_Pop>20</ShortTermForecastT_Pop>
</ShortTermForecastT>
</NightForecast>
<LongTermForecasts>
<Array>
<Array_Element>
<LongTermForecastT>
<LongTermForecastT_FcDate>2000-12-27</LongTermForecastT_FcDate>
<LongTermForecastT_WeatherCode>20</LongTermForecastT_WeatherCode>
<LongTermForecastT_High>40</LongTermForecastT_High>
<LongTermForecastT_Low>50</LongTermForecastT_Low>
<LongTermForecastT_Pop>60</LongTermForecastT_Pop>
</LongTermForecastT>
</Array_Element>
<Array_Element>
<LongTermForecastT>
<LongTermForecastT_FcDate>2000-12-28</LongTermForecastT_FcDate>
<LongTermForecastT_WeatherCode>20</LongTermForecastT_WeatherCode>
<LongTermForecastT_High>40</LongTermForecastT_High>
<LongTermForecastT_Low>60</LongTermForecastT_Low>
<LongTermForecastT_Pop>70</LongTermForecastT_Pop>
</LongTermForecastT>
</Array_Element>
</Array>
</LongTermForecasts>
</WheaterReportsRow>
</WheaterReports>
</return>
</ns1:getWeatherReportResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Maybe you are looking for
-
Graphical mess-mapping help needed: select single segment from many
Hi All, I am sending a standard PO IDOC from R/3 and converting it into a file before sending to 3rd party. The IDOC used is ORDERS. In this IDOC segment E1EDK14 gets repeated in R/3 and I want to use the value of 009th occurance (E1EDK14 009) to ma
-
Can I use face time using wifi from europe to the US?
If I turn off cellular and data roaming for Europe, will I still be able to use facetime via wifi to contact someone with facetime and wifi in the US?
-
Abap Query - Delete duplicates
I I'm doing an abap query in SQ02 with LIKP and LIPS tables. As output I just want lines with different entries in LIPS of material. How can I delete the duplicates? With instruction delete ADJACENT DUPLICATES FROM XXXX COMPARING vbeln matnr, how can
-
Error message ORA-01092:Oracle instance terminated(urgent please)
hi, while creating a new database manually I got the message ORA-01092. though control files and temporary tablespace was created but rest activity remained terminated. what can be the solution?
-
THIS IS SECOND TIME I AM EXPERIENCING THE PROBLEM, AND I HAVE ALREADY PAID ANOTHER MONTH PAYMENT BECAUSE I WAS UNABLE TO DISABLE MY MONTH-MONTH MEMBERSHIP ACCOUNT WHICH I BELIEVE IS NOT PROFESSIONAL.. I AM UNABLE TO DISCONTINUE MY MONTH-MONTH MEMBERS