Formatting XML file to avoid mapping parser error
Hi,
We have requirement in our project to process input xml file which is of the below format:
<message>
<data>
<xml version=1.0 code=utf/>
<test>
<data>book</data>
</test>
</data></message>
Since <xml> tag is at the middle it is throwing a exception error in mapping.
Actual requirment is that we need
<test>
<data>book</data>
</test>
The xml of the above format is generated by some external system which PI need to pick it.
I think is not possible in XSLT mapping as it is not starting with xml tag .
So please let me know pointer ot resolve the issue.
Thanks in advance.
Hi Yeshwanth,
If this input XML. Then it is valid XML.
<message>
<data>
<xml version="1.0" code="utf" />
<test>
<data>book</data>
</test>
</data>
</message>
Please paste the error message, input and expected output XML.
Regards,
Raghu_Vamsee
Edited by: Raghu Vamsee on Aug 25, 2011 12:10 PM
Similar Messages
-
This is what i got in the log file when i tried to import a relatively large file 1.7 GB xml file
Import Finished
Errors: 1
Warnings: 0
<<<<< ERRORS >>>>>
Error parsing ERwin 7.x File:<File path>
Please help.The error information in the External log file is
ERROR ERwinHandler - ERwinHandler - Unable to parse ERwin 7.x file: <file path>
java.lang.OutOfMemoryError: Java heap space
at oracle.dbtools.crest.model.ModelIDObject.<init>(ModelIDObject.java:46)
at oracle.dbtools.crest.model.design.DesignObject.<init>(DesignObject.java:111)
at oracle.dbtools.crest.model.design.ContainedObject.<init>(ContainedObject.java:82)
at oracle.dbtools.crest.model.design.ContainedObjectWithDomain.<init>(ContainedObjectWithDomain.java:76)
at oracle.dbtools.crest.model.design.relational.FKElement.<init>(FKElement.java:14)
at oracle.dbtools.crest.model.design.relational.Column.<init>(Column.java:148)
at oracle.dbtools.crest.model.design.relational.Table.createColumn(Table.java:432)
at oracle.dbtools.crest.imports.erwin.ERSAXParserv7x.parseColumns(ERSAXParserv7x.java:1681)
at oracle.dbtools.crest.imports.erwin.ERSAXParserv7x.parseEntity(ERSAXParserv7x.java:1364)
at oracle.dbtools.crest.imports.erwin.ERSAXParserv7x.endEntitiesAndAttributes(ERSAXParserv7x.java:994)
at oracle.dbtools.crest.imports.erwin.ERSAXParserv7x.endElement(ERSAXParserv7x.java:428)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1666)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:458)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:404)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:245)
at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:298)
at oracle.dbtools.crest.imports.erwin.ERwinHandler.parseFile(ERwinHandler.java:252)
at oracle.dbtools.crest.imports.erwin.ERwinHandler.access$500(ERwinHandler.java:51)
at oracle.dbtools.crest.imports.erwin.ERwinHandler$Runner.run(ERwinHandler.java:126)
at java.lang.Thread.run(Thread.java:745)
2015-02-11 14:38:12,680 [main] INFO ApplicationView - Oracle SQL Developer Data Modeler 4.1.0.866
2015-02-11 16:13:44,218 [Thread-33] ERROR ERwinHandler - ERwinHandler - Unable to parse ERwin 7.x file: <file_Path>
java.lang.OutOfMemoryError: Java heap space -
XSLT mapping code to replace ns1: tag as plm: in XML file in PI mapping
Hi
I am sending XML file to HTTP server as below format
<?xml version="1.0" encoding="UTF-8" ?>
- <ns1:Responses xmlns:ns1="http://">
- <ns1:Response Application="SAP">
<ns1:field1>12345</ns1:field1>
<ns1:field2>abc</ns1:field2>
- <ns1:Items>
<ns1:doc></ns1:doc>
</ns1:Items>
</ns1:Response>
</ns1:Responses>
i hve to replace <ns1: as <plm:, i could able to delete <ns1: tag uisng XSLT mapping(in sdn), but i dont know how to add tag with <plm:
Hi XSLT experts/if any has come across this requirment, please send XSLT code to add tag in XML.
Regards,
RajeshNo need for XSLT, just use the XMLAnonymizerBean module in your receiver communication channel.
http://help.sap.com/saphelp_nw70/helpdata/EN/45/d169186a29570ae10000000a114a6b/frameset.htm
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
If your receiver CC cannot process modules (ABAP receiver, for example), in your XSLT just define the target namespace with the desired prefix.
Regards,
Henrique. -
Can i run a servlet without a web.xml file for servlet mapping?
Hello everyone.
The code i want to run compiles and everythink looks ok.
It produces the .class file.
I run Tomcat 4.1 and i build my Web site with Dreamweaver.
I have a form in a page and i want to send the data upon form completion to a database i already have build with MySql.
The database is up and running and the server is set-up ok.
I have changed the port in Tomcat to run on port 80.
The directory i have my site is
Tomcat41\webapps\ROOT\se
and the directory where i keep the servlet class is
Tomcat41\webapps\ROOT\se\WEB-INF\servlet
I have a web.xml file to map the servlet and placed it in
Tomcat41\webapps\ROOT\se\WEB-INF
In the Form action i write action:"/servlets/Classes/GroupRegistration"
and I RECEIVE AN 404 ERROR FROM APACHE.
Somethink is wrong .
The following is the code from the GroupRegistration.java file
and follws the web.xml file.
Please Help.
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GroupRegistration extends HttpServlet
Connection con;
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException
handleForm(req, res);
public void init() throws ServletException {
try{
/* Loading the driver for the database */
Class.forName("com.mysql.jdbc.Driver");
Connection Con = DriverManager.getConnection("jdbc:mysql://localhost/se?user=luser&password=");
catch (ClassNotFoundException e) {
throw new UnavailableException("Couldn't load JdbcOdbcDriver");
catch (SQLException e) {
throw new UnavailableException("Couldn't get db connection");
private void handleForm(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
//ServletOutputStream out = res.OutputStream();
//res.setContentType("text/html");
//Extract the form Data Here
String group = req.getParameter("GroupNo");
String Name1 = req.getParameter("Name1");
String LoginID1 = req.getParameter("LoginID1");
String Name2 = req.getParameter("Name2");
String LoginID2 = req.getParameter("LoginID2");
String Name3 = req.getParameter("Name3");
String LoginID3 = req.getParameter("LoginID3");
String Name4 = req.getParameter("Name4");
String LoginID4 = req.getParameter("LoginID4");
String URL = req.getParameter("URL");
String Title2 = req.getParameter("Title2");
String date = req.getParameter("date");
String INSERT = "INSERT INTO registration (groupno, name1, loginid1, name2, loginid2, name3, loginid3, name4, loginid4, url, topic, date) VALUES (" + group + "," + Name1 + "," + LoginID2 + "," + Name2 + "," + LoginID2 + "," + Name3 + "," + LoginID3 + "," + Name4 + "," + LoginID4 + "," + URL + "," + Title2 + "," + date + ")";
PreparedStatement pstmt = null;
try{
pstmt = con.prepareStatement(INSERT);
pstmt.executeUpdate();
catch (SQLException e) {
throw new ServletException(e);
finally {
try {
if (pstmt != null)pstmt.close();
catch (SQLException ignored){
The web.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com.xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>GroupRegistration</servlet-name>
<servlet-class>GroupRegistration</servlet-class>
</servlet>
<servlet-maping>
<servlet-name>GroupRegistration</servlet-name>
<url-pattern>/myGroupRegistration</url-patern>
</servlet-mapping>
</web-app>
I apreciate your time.
Thanks for any help.and the directory where i keep the servlet class is
Tomcat41\webapps\ROOT\se\WEB-INF\servletOthers have pointed out that "servlet" should be "classes", but there is another mistake that hasn't been spotted. If you want your servlet to appear in the root context, you should use:
Tomcat41\webapps\ROOT\WEB-INF\classes
If you want your servlet to appear under the /se context, then you should use:
Tomcat41\webapps\se\WEB-INF\classes
and also, in the latter case, your form action should be /se/myGroupRegistration. -
Read any XML File Elements using SAX Parser in J2se
Hi All
I can able to parsed one structured XML file using SAX
Sample code :
// ===========================================================
// SAX DocumentHandler methods
// ===========================================================
public void startDocument() throws SAXException {
logger.info("Start of document");
public void endDocument() throws SAXException {
logger.info("End of document");
public void startElement(String namespaceURI, String localName, // local
// name
String qualName, // qualified name
Attributes attrs) throws SAXException {
elemName = new String(localName); // element name
if (elemName.equals(""))
elemName = new String(qualName); // namespaceAware = false
tagPosition = TAG_START;
// Set the string for accumulating the text in a tag to empty
elemChars = "";
// If the element name is "row", create a new row instance
// If the element is "indexxid", "ModelPrice", or "ModelSpread",
// the value will be read in the method "characters" and stored.
if (elemName.equals("row")) {
row = new IndexRow();
numRows++;
// logger.info("Number of numRow:"+numRows);
} // end method startElement
public void endElement(String namespaceURI, String simpleName, // simple
// name
String qualName // qualified name
) throws SAXException {
elemName = new String(simpleName);
if (elemName.equals(""))
elemName = new String(qualName); // namespaceAware = false
tagPosition = TAG_END;
String indexId = new String();
Double dblVal = new Double(0);
// If element name is "row", put the current row in the map for row
// instances
if (elemName.equals("row")) {
if (numRows <= 5) { logger.info("Row is: " + row.toString()); }
//ABX
//indexRows.put(row.getIndexxId(), row);
if (family.equals("ABX.HE")){
indexRows.put(row.getIndexREDId(), row);
else {
//CDX ITRXX
indexRows.put(row.getIndexxId(), row);
} else if (elemName.equals("IndexID")) {
row.setIndexxId(elemChars);
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setCompositeSpread(dblVal);
indexId = row.getIndexxId();
} else if (elemName.equals("REDCode")) {
row.setRedCode(elemChars);
else if (elemName.equals("Name")) {
row.setRowName(elemChars);
} else if (elemName.equals("Series")) {
row.setSeries(elemChars);
} else if (elemName.equals("Version")) {
row.setVersion(elemChars);
} else if (elemName.equals("Term")) {
row.setTerm(elemChars);
} else if (elemName.equals("Maturity")) {
row.setMaturity(elemChars);
} else if (elemName.equals("OnTheRun")) {
row.setOnTheRun(elemChars);
} else if (elemName.equals("Date")) {
row.setRowDate(elemChars);
} else if (elemName.equals("Depth")) {
row.setDepth(elemChars);
else if (elemName.equals("Heat")) {
// logger.info("Chars for element " + elemName + " are '" +
// elemChars + "'");
// Leave double value at default of zero if there are no chars
if (elemChars.trim().length() != 0) {
dblVal = new Double(elemChars);
row.setHeat(dblVal);
indexId = row.getIndexxId();
// ABX.HE
else if (elemName.equals("IndexREDId")){
row.setIndexREDId(elemChars);
else if (elemName.equals("Coupon")){
row.setCoupon(elemChars);
if (elemName.equals("Ontherun")) {
row.setOnTheRun(elemChars);
} // end method endElement
public void characters(char buf[], int offset, int len) throws SAXException {
// If at end of element, there will be no characters
if (tagPosition == TAG_END) {
return;
// The characteres method may be called more than once
// for an element if the internal buffer fills up.
// Append the characters until the end of the element.
String strVal = new String(buf, offset, len);
elemChars = elemChars + strVal;
} // end method characters
} // end class MarkItIndexLoader
but the problem is i want to read (parse) any XML file means any Elemets would be change any time using SAX .In the above example
else if (elemName.equals("Heat")) {
else if (elemName.equals("IndexREDId")){
} else if (elemName.equals("Maturity")) {
like above I am doing hard code Elements names and reading the values so i don't want hard coding the elements names I want to read any element name and value dynamically.
If i give any one below XML file i want to read the Elements and displaying to console without changing any code i want to read the XML document.
EX:
Student.XML: <root>..</StName>..</StAge>...</root>
Employee.XML: <root>..</EmpName>..</EmpAge>...</root>
CdCatalog.XML: <root>..</Cdtitle>...</CdNumber>...</root>
I need one java program can ready any type of XML file elements and send to the Database table.
Please any one done like this task please suggest some reference links or books or sample snippet which can help me to develop program in my requirement.
Thanks in advance
Regards
satishYou should ask in the Java forum.
Regards
Stefan -
Checking Well-Formed XML files with ABAP Mapping
Hi guys,
Anybody knows which is the best way to check (well-formed) incoming XML files trough XI?
Im using ABAP Mapping and before I check the value of the XML fields I want to check if the XML is well-formed. For this reason I need to know which is the class or classes that I need to use to checking the format of XML using an XSD file?
That is also possible using a DTD file instead of XSD?
Which is better XSD or DTD?
Thanks in advance,
Ricardo.Hi Ricardo,
try out these links.
/people/r.eijpe/blog/2005/11/04/using-abap-xslt-extensions-for-xi-mapping
/people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
/people/sap.user72/blog/2003/09/18/xsl-and-abap
Thanks and Regards
Vishal Kumar -
Maximum XML file size that can parsed with c++ XML parser
Hi!
what is the maximum file size that can be parsed using the xml parser(version 1) for c++ on linux .
i'm getting an error(error no 231) when i try to parse an XML file of 3MB on Red Hat Linux 6.1
Regards
anjanamoving to xml db forum
-
Error in my build.xml file (help with spotting syntax error requested)
Hi
I have written an XML file called build.xml for one of my applications. My XML editor complains that there is an error at the last line of the XML file, but I simply find it unable to correct the errror.
It says:
Fatal error:Build.xml[76:3-9]: End-Tag without start-tag
The XML file itself:
<project basedir="." default="deploy" name="concepts">
<property name="src.dir" value="src"></property>
<property name="build.dir" value="${basedir}/build"></property>
<property name="build.lib" value="${build.dir}/lib"></property>
<property name="dist.dir" value="dist"></property>
<property name="classes.dir" value="${build.dir}/classes"></property>
<property name="build.etc" value="${src.dir}/etc"></property>
<property name="build.resources" value="${src.dir}/resources"></property>
<property name="lib.dir" value="lib"></property>
<property name="web-inf.dir" value="WEB-INF"></property>
<property name="war.name" value="concepts"></property>
<property file="../common.properties"></property>
<target name="init">
<mkdir dir="${build.dir}"></mkdir>
<mkdir dir="${classes.dir}"></mkdir>
<mkdir dir="${dist.dir}"></mkdir>
</target>
<target name="deploy" depends="clover-yes, clover-no">
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${libs}" debug="off" optimize="on" deprecation="on" compiler="${compiler}">
<include name="org/apache/commons/fileupload/**/*.java" />
<include name="com/portalbook/portlets/**/*.java" />
<include name="com/portalbook/portlets/content/**/*.java" />
</javac>
<target depends="init" name="compile">
<javac debug="true" deprecation="true" destdir="${classes.dir}" optimize="false">
<src>
<pathelement location="${src.dir}"></pathelement>
</src>
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar">
</include>
</fileset>
</classpath>
</javac>
</target>
<target depends="compile" name="war">
<war destfile="${dist.dir}/${war.name}.war" webxml="WEB-INF/web.xml">
<classes dir="${classes.dir}"></classes>
<lib dir="${lib.dir}"></lib>
<webinf dir="${web-inf.dir}"></webinf>
</war>
</target>
<!-- create the portal-concepts-lib.jar -->
<jar jarfile="${build.lib}/concepts-lib.jar">
<fileset dir="${classes.dir}"></fileset>
</jar>
<jar jarfile="${build.lib}/concepts.war" manifest="${build.etc}/concepts-war.mf">
<fileset dir="${build.resources}/concepts-war"></fileset>
</jar>
<!-- concepts.ear -->
<copy todir="${build.resources}/concepts-ear">
<fileset dir="${build.lib}" includes="concepts.war,concepts-lib.jar"></fileset>
</copy>
<jar jarfile="${build.lib}/concepts.ear">
<fileset dir="${build.resources}/concepts-ear" includes="concepts.war,concepts-lib.jar">
</fileset>
</jar>
<target depends="deploy" name="explode">
<taskdef classname="org.jboss.nukes.common.ant.Explode" classpath="${libs}" name="explode"></taskdef>
<explode file="${build.lib}/concepts.ear" name="concepts.ear" todir="${build.lib}/exploded"></explode>
</target>
<target depends="war" name="all"></target>
<target name="clean">
<delete dir="${build.dir}">
</delete>
<delete dir="${dist.dir}">
</delete>
</target>
</project>
I am a little inexperienced in XML files. So I am unable to spot the error.
I would greatly appreciate it, if some kind soul were to help me out.
thanks a lotThe tag
<target name="deploy" depends="clover-yes, clover-no">...is never closed.
close that tag:
<target name="deploy" depends="clover-yes, clover-no">
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpath="${libs}" debug="off" optimize="on" deprecation="on" compiler="${compiler}">
<include name="org/apache/commons/fileupload/**/*.java" />
<include name="com/portalbook/portlets/**/*.java" />
<include name="com/portalbook/portlets/content/**/*.java" />
</javac>
</target>Second error is that the depends in there (clover-yes, clover-no) are not existing as targets in your xml. -
Download created XML File in batch mode // Parse XML file into single lines
Hello!
I upload a CSV file and based on that CSV file I create an XML "object". First I uploaded and downloaded it via gui frontendclass, but as it has to be run in a batch in the night I need to upload and download the data via OPEN DATASET.
The import and transformation of the CSV file works fine, also the transfer into an itab with the same structure as a CSV line is ok. I also create the XML file, which could be downloaded easily with gui-download but it is not permittet.
Import of data: I scan the folder and get the filenames into a itab, I loop over that itab and read the single files like this:
OPEN DATASET ls_convert_batch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
CLEAR tab.
IF sy-subrc = 0.
DO.
READ DATASET ls_convert_batch INTO line.
IF sy-subrc <> 0.
EXIT.
ELSE.
CLEAR tmptab.
SPLIT line AT ';' INTO tmptab-product
tmptab-contract
tmptab-extagent.
APPEND tmptab TO tab.
ENDIF.
ENDDO.
ENDIF.
The XML file has a strucutre like
<file>
- <file formant_no="1.1" format_date="02.10.2003">
<status>V</status>
<number>001001025</numbner>
<name>Schmeisser,Christof</name>
- <details>
- <detail>
<contract>00000003494</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003840</invoice_no>
<due_date>20100601</due_date>
<amount>140,00</amount>
</detail>
- <detail>
<contract>00000003495</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003841</invoice_no>
<due_date>20100601</due_date>
<amount>130,00</amount>
</detail>
- </details>
<elements>2</elements>
<amount_overall>270</amount_overall>
</file>
At the moment I download it like this:
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = filename
filetype = 'BIN'
* CONFIRM_OVERWRITE = '0'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
lv_create_counter = lv_create_counter + 1.
ENDIF.
But I need to download it via OPEN TRANSFER CLOSE Dataset as it has to run in batch mode.
Anyone has an idea? I am really desperate here. One idea would be to parse the single lines into a string and then create the XML file line by line as text and save it with ending XML, should work. But I don't know how!
Thank you very much in advance,
kind regards from Tallinn, Estonia,
Christof!
Edited by: Christof Schmeisser on Nov 25, 2010 7:51 PM
I edited the heading, would be too general and missleading!Tipos Pools
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
TYPES: BEGIN OF xml_node_type,
node TYPE char50,
vlnode TYPE string,
END OF xml_node_type,
BEGIN OF xml_line_type,
data(256) TYPE x,
END OF xml_line_type.
Tabelas Internas
DATA: ti_xml_node TYPE TABLE OF xml_node_type.
Variáveis TYPE REF
*Type REF para utilizar no XML
DATA: ixml_type TYPE REF TO if_ixml,
streamfactory_type TYPE REF TO if_ixml_stream_factory,
ostream_type TYPE REF TO if_ixml_ostream,
istream_type TYPE REF TO if_ixml_istream,
parser_type TYPE REF TO if_ixml_parser,
renderer_type TYPE REF TO if_ixml_renderer,
document_type TYPE REF TO if_ixml_document,
encoding_type TYPE REF TO if_ixml_encoding,
node_type TYPE REF TO if_ixml_node,
element_dtrans_type TYPE REF TO if_ixml_element,
element_xml_in_type TYPE REF TO if_ixml_element,
element_roteiros_type TYPE REF TO if_ixml_element,
element_roteiro_type TYPE REF TO if_ixml_element,
element_vias_type TYPE REF TO if_ixml_element,
element_via_type TYPE REF TO if_ixml_element,
element_dummy_type TYPE REF TO if_ixml_element,
gw_xml_node TYPE TABLE OF xml_node_type,
gw_xml_node_ret TYPE TABLE OF xml_node_type,
gw_xml_node_err TYPE TABLE OF xml_node_type,
gw_xml_node_xml TYPE TABLE OF xml_node_type,
gw_xml_table TYPE TABLE OF xml_line_type,
gw_xml_table2 TYPE TABLE OF xml_line_type,
gs_xml_node TYPE xml_node_type, "WA para leitura do xml
gs_xml_node_ret TYPE xml_node_type, "WA para leitura do xml retorno
gs_xml_node_err TYPE xml_node_type, "WA para leitura do xml erro
gs_xml_node_xml TYPE xml_node_type, "WA para leitura do xml info sucesso
gs_xml_table2 TYPE xml_line_type. "WA para importar xml
Variáveis do Programa
DATA: l_value TYPE string,
l_rc TYPE i,
l_xml_size TYPE i,
cod_cartaorepom TYPE char20 VALUE '123456789',
v_caminho_exp TYPE string VALUE 'C:TEMP',
v_salvaarquivo TYPE string,
v_nomearquivo TYPE string,
w_nodetext TYPE string,
v_roteiros TYPE string,
v_roteiro TYPE string,
v_roteiro_codigo TYPE string,
v_percurso_codigo TYPE string,
v_percurso_descricao TYPE string,
v_cidade_origem TYPE string,
v_estado_origem TYPE string,
v_cidade_destino TYPE string,
v_estado_destino TYPE string,
v_transporte_tipo TYPE string,
v_cartao_taxa TYPE string,
v_cobra_taxa TYPE string.
Constants
CONSTANTS: cc_39 TYPE string VALUE '39', " Numero 39.
cc_dt_trans TYPE string VALUE 'data_transfer'," document_type(name)
cc_metodo_cod TYPE string VALUE 'metodo_codigo'," document_type(name)
cc_xml_in TYPE string VALUE 'xml_in'," document_type(name)
cc_ct_tx_ativ TYPE string VALUE 'cartao_taxa_ativacao'," document_type(name)
cc_cartao TYPE string VALUE 'cartao', " Parâmetro Perform.
cc_xml TYPE string VALUE '.XML'," extenção
cc_bin TYPE char10 VALUE 'BIN'." filetype
START-OF-SELECTION.
PERFORM yf_inicia_criacao_xml USING cc_39.
element_roteiro_type = document_type->create_simple_element(
name = cc_ct_tx_ativ
parent = element_xml_in_type ).
PERFORM yf_dummy_roteiro USING cod_cartaorepom cc_cartao.
PERFORM yf_finaliza_xml.
PERFORM yf_exporta_xml USING v_caminho_exp.
PERFORM yf_convert_xml_to_itab TABLES gw_xml_node_ret
USING v_salvaarquivo.
END-OF-SELECTION.
*& Form yf_inicia_criacao_xml
text
-->VALUE(P_0783) text
FORM yf_inicia_criacao_xml USING value(p_0783).
DATA: s_encoding_type TYPE string VALUE 'ISO-8859-1'.
Cria o ixml factory
ixml_type = cl_ixml=>create( ).
*Cria o objeto com modelo
document_type = ixml_type->create_document( ).
*Cria o cabeçalho encoding="iso-8859-1"
encoding_type = ixml_type->create_encoding( byte_order = 0
character_set = s_encoding_type ).
*Cria o root "DATA_TRANSFER"
element_dtrans_type = document_type->create_simple_element(
name = cc_dt_trans
parent = document_type ).
*Cria o node "METODO_CODIGO" e preenche com um valor passado no L_VALUE
l_value = p_0783.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = cc_metodo_cod
value = l_value
parent = element_dtrans_type ).
*Cria o node "XML_IN"
element_xml_in_type = document_type->create_simple_element(
name = cc_xml_in
parent = element_dtrans_type ).
ENDFORM. " yf_inicia_criacao_xml
*& Form yf_dummy_roteiro
text
-->VALUE(P_0996) text
-->VALUE(P_0997) text
FORM yf_dummy_roteiro USING value(p_0996)
value(p_0997).
l_value = p_0996.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = p_0997
value = l_value
parent = element_roteiro_type ).
ENDFORM. " yf_dummy_roteiro
*& Form yf_finaliza_xml
text
FORM yf_finaliza_xml.
*Cria o stream factory
streamfactory_type = ixml_type->create_stream_factory( ).
*Conecta a internal table de XML com o stream factory
ostream_type = streamfactory_type->create_ostream_itable( table = gw_xml_table ).
CALL METHOD ostream_type->set_encoding
EXPORTING
encoding = encoding_type.
*Rendering the document
renderer_type = ixml_type->create_renderer( ostream = ostream_type
document = document_type ).
l_rc = renderer_type->render( ).
*Salva o documento XML
l_xml_size = ostream_type->get_num_written_raw( ).
ENDFORM. " yf_finaliza_xml
*& Form yf_exporta_xml
text
-->VALUE(P_0783) text
FORM yf_exporta_xml USING value(p_0783).
CONCATENATE cod_cartaorepom
sy-datum
sy-uzeit
cc_xml
INTO v_nomearquivo.
CONCATENATE p_0783
v_nomearquivo
INTO v_salvaarquivo.
TRANSLATE v_nomearquivo TO UPPER CASE.
*Exporta o XML
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = v_salvaarquivo
filetype = cc_bin
CHANGING
data_tab = gw_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc = 0.
PERFORM yf_sapgui_progress_indicator USING cc_msg_xml_ok.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " yf_exporta_xml
*& Form yf_convert_xml_to_itab
text
-->P_GW_XML_NODE_RET text
-->P_FILENAME text
FORM yf_convert_xml_to_itab TABLES p_gw_xml_node_ret LIKE gw_xml_node
USING p_filename.
DATA l_count.
ixml_type = cl_ixml=>create( ).
Now Create Stream Factory
streamfactory_type = ixml_type->create_stream_factory( ).
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_filename
filetype = cc_bin
IMPORTING
filelength = l_xml_size
CHANGING
data_tab = gw_xml_table2
EXCEPTIONS
OTHERS = 19.
IF sy-subrc = 0.
istream_type = streamfactory_type->create_istream_itable( table = gw_xml_table2
size = l_xml_size ).
document_type = ixml_type->create_document( ).
parser_type = ixml_type->create_parser( stream_factory = streamfactory_type
istream = istream_type
document = document_type ).
IF parser_type->parse( ) NE 0.
IF parser_type->num_errors( ) NE 0.
l_count = parser_type->num_errors( ).
ENDIF.
ENDIF.
CALL METHOD istream_type->close( ).
CLEAR istream_type.
node_type = document_type.
PERFORM yf_get_data USING node_type.
p_gw_xml_node_ret[] = gw_xml_node[].
CLEAR gw_xml_node[].
ENDIF.
ENDFORM. " yf_convert_xml_to_itab
*& Form yf_get_data
text
-->VALUE(X_NODE) text
FORM yf_get_data USING value(x_node) TYPE REF TO if_ixml_node.
DATA: indent TYPE i.
DATA: ptext TYPE REF TO if_ixml_text.
DATA: string TYPE string.
DATA: temp_string(100).
CASE x_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
string = x_node->get_name( ).
w_nodetext = string.
CLEAR string.
string = x_node->get_value( ).
IF NOT w_nodetext IS INITIAL OR
NOT string IS INITIAL.
gs_xml_node-node = w_nodetext.
gs_xml_node-vlnode = string.
IF NOT gs_xml_node-vlnode IS INITIAL.
APPEND gs_xml_node TO gw_xml_node.
CLEAR gs_xml_node.
ENDIF.
ENDIF.
ENDCASE.
Get the next child
x_node = x_node->get_first_child( ).
Recurse
WHILE NOT x_node IS INITIAL.
PERFORM yf_get_data USING x_node.
x_node = x_node->get_next( ).
ENDWHILE.
ENDFORM. "yf_get_data -
Parsing an xml file using xerces DOM parser
Hi
I want to parse a simple xml file using DOM parser.
The file is
<Item>
<SubItem>
<title>SubItem0</title>
<attr1>0</attr1>
<attr2>0</attr2>
<attr3>0</attr3>
</SubItem>
<SubItem>
<title>SubItem1</title>
<attr1>1</attr1>
<attr2>0</attr2>
<attr3>0</attr3>
</SubItem>
<SubItem>
<title>SubItem2</title>
<attr1>1</attr1>
<attr2>1</attr2>
<attr3>0</attr3>
<SubItem>
<title>SubItem20</title>
<attr1>2</attr1>
<attr2>1</attr2>
<attr3>0</attr3>
</SubItem>
<SubItem>
<title>SubItem21</title>
<attr1>1</attr1>
<attr2>1</attr2>
<attr3>0</attr3>
</SubItem>
</SubItem>
</Item>
I just want to parse this file and want to store the values in desired datastructures,
I am trying using DOM parser, since it gives a tree structure, which is ok in this case.
public void init()
InputReader ir =new InputReader("Habsys");
Document doc =ir.read("Habitat");
System.out.println(doc);
traverse(doc);
private void traverse(Document idoc)
NodeList lchildren=idoc.getElementsByTagName("SubItem");
for(int i=0;i<lchildren.getLength();i++)
String lgstr=lchildren.item(i).getNodeName();
if(lgstr.equals("SubItem"))
traverse(lchildren.item(i));
private void traverse (Node node) {
int type = node.getNodeType();
if (type == Node.ELEMENT_NODE)
System.out.println ("Name :"+node.getNodeName());
if(!node.hasChildNodes())
System.out.println ("Value :"+node.getNodeValue());
NodeList children = node.getChildNodes();
if (children != null) {
for (int i=0; i< children.getLength(); i++)
traverse (children.item(i));
But I am not getting required results, a lot of values I am getting as null
Could anybody tell me how to retrieve the data from the xml file, I simply want to read data and store it in data structures. For eg, for tag Subitem with title as ' SubItem1' has attr1 as '1', attr2 as'0' and attr3 as '0'.
Thanks
GauravCheck This Sample Code....
public void amethod(){
DocumentBuilderFactory dbf = null;
DocumentBuilder docBuilder = null;
Document doc = null;
try{
dbf = DocumentBuilderFactory.newInstance();
db = dbf.newDocumentBuilder();
doc = db.parse(New File("path/to/your/file"));
Node root = doc.getDocumentElement();
System.out.println("Root Node = " + root.getNodeName());
readNode(root);
}catch(FactoryConfigurationError fce){ fce.printStackTrace();
}catch(ParserConfigurationException pce){ pce.printStackTrace();
}catch(IOException ioe){ ioe.printStackTrace();
}catch(SAXException saxe){ saxe.printStackTrace();
private void readNode(Node node) {
System.out.println("Current Node = " + node.getNodeName());
readAttributes(node);
readChildren(node);
private void readAttributes(Node node) {
if (!node.hasAttributes())
return;
System.out.println("Attributes:");
NamedNodeMap attrNodes = node.getAttributes();
for (int i=0; i<attrNodes.getLength(); i++) {
Attr attr = (Attr)attrNodes.item(i);
System.out.println(attr.getNodeName() + " => " + attr.getNodeValue());
private void readChildren(Node node) {
if (!node.hasChildNodes())
return;
System.out.println("Value/s:");
NodeList childNodes = node.getChildNodes();
for (int i=0; i<childNodes.getLength(); i++) {
Node child = (Node)childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
readNode(child);
continue;
if (child.getNodeType() == Node.TEXT_NODE) {
if (child.getNodeValue()!=null)
System.out.println(child.getNodeValue()); -
XML File in External Table - OS error permission denied.
Hi.
10g R2, Red Hat Linux
I'm using the article (see below, taken from http://www.dbazine.com/olc/olc-articles/scardina1 by Mark Scardina) to create an external table where I'd store my XML file.
So, I
1. Created a directory xmlfile_dir
2. Granted access to needed db user
3. Created the table
CREATE TABLE relayxml_xt (doc CLOB)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY xmlfile_dir
ACCESS PARAMETERS
FIELDS (lobfn CHAR TERMINATED BY ',')
COLUMN TRANSFORMS (doc FROM lobfile (lobfn))
LOCATION ('xml.dat')
REJECT LIMIT UNLIMITED;
4. mv relay.xml /xmlfile_dir/xml.dat
When I run SELECT * FROM relayxml_xt I get this:
Error starting at line 1 in command:
select * from relayxml_xt
Error report:
SQL Error: ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04063: unable to open log file RELAYXML_XT_28773.log
OS error Permission denied
ORA-06512: at "SYS.ORACLE_LOADER", line 19
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
What am I doing wrong?
Thanks,
Using External Tables
Introduced in Oracle9i, Oracle’s external table feature offers a solution to define a table in the database while leaving the data stored outside of the database. Prior to Oracle Database 10g, external tables can be used only as read-only tables. In other words, if you create an external table for XML files, these files can be queries and the table can be joined with other tables. However, no DML operations, such as INSERT, UPDATE, and DELETE, are allowed on the external tables.
Note: In Oracle Database 10g , by using the ORACLE_DATAPUMP driver instead of the default ORACLE_DRIVER, you can write to external tables. In Oracle Database 10g, you can define VARCHAR2 and CLOB columns in external tables to store XML documents. The following example shows how you can create an external table with a CLOB column to store the XML documents. First, you need to create a DIRECTORY to read the data files:
CREATE DIRECTORY data_file_dir AS 'D:\xmlbook\Examples\Chapter9\src\xml';
GRANT READ, WRITE ON DIRECTORY data_file_dir TO demo;
Then, you can use this DIRECTORY to define an external table:
CREATE TABLE customer_xt (doc CLOB)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY data_file_dir
ACCESS PARAMETERS
FIELDS (lobfn CHAR TERMINATED BY ',')
COLUMN TRANSFORMS (doc FROM lobfile (lobfn))
LOCATION ('xml.dat')
REJECT LIMIT UNLIMITED;
The xml.dat file follows:
customer1.xml
customer2.xml
If you describe the table, you can see the following definition:
SQL> DESC customer_xt;
Name Null? Type
DOC CLOB
Then, you can query the XML document as follows:
SELECT XMLType(doc).extract('/Customer/EMAIL')
FROM customer_xt;
Though the query requires run-time XMLType creation and XPath evaluation, this approach is useful when applications just need a few queries on the XML data and don’t want to upload the XML data into database. In Oracle Database 10g, you cannot create external tables that contain pre-defined XMLType column types.
Message was edited by:
vi2167Your don't have the proper operating system privileges. Be sure that you (=oracle OS user / the OS Linux user that is starting the database) are allowed have read privs on the path and/or file.
for example...
chown -Rf /xxxxxxx/xxxx/etc
ls -l file.xml
file.xml oracle:oinstall rw-rw-rw -
How to find the existence of a tag in XML file through XSLT Mapping?
Hello Friends,
Working on an SAP XI interface ,I have come across a situation where I need to map the values only when a particular tag exists in the inbound XML file.I need to use the XSLT mapping for the same.
Requesting your advice on as to how may I validate the existence of a tag through XSLT mapping?
Thanks.Hello Friends
After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
<xsl:choose>
<xsl:when test="(/mynode)">
your action if the mynode is found
</xsl:when>
<xsl:otherwise>
action if mynode is not found
</xsl:otherwise>
</xsl:choose>
Thanks.
Wishes
Richa -
Actually i am using an off-line form to load very large XML file and using firefox to load that form. But, its taking more time to load and some time the browser crashed. through DOM parsing this XML file to my form. Is there any option to increase DOM handler size in firefox
Thank you for your suggestion. I have a question,
though. If I use a relational database and try to
access it for EACH and EVERY click the user makes,
wouldn't that take much time to populate the page with
data?
Isn't XML store more efficient here? Please reply me.You have the choice of reading a small number of records (10 children per element?) from a database, or parsing multiple megabytes. Reading 10 records from a database should take maybe 100 milliseconds (1/10 of a second). I have written a web application that reads several hundred records and returns them with acceptable response time, and I am no expert. To parse an XML file of many megabytes... you have already tried this, so you know how long it takes, right? If you haven't tried it then you should. It's possible to waste a lot of time considering alternatives -- the term is "analysis paralysis". Speculating on how fast something might be doesn't get you very far. -
More than 100 mb xml file , giving out of memory error in BIP 10.1.3.4
We are running outofmemory error, java heap space error, if we run a report which has more than 100mb xml, with two or more grouping in RTF template.
How to configure it to work with better performance for bigger XML files ?
Any particular setup , pointers are welcome.
Thanks.Long time no see vet. Your problem sucks. I would go to sun site review there articles on JVM tunning. To solve this problem you will need to change the command line arguments to JVM to increase the heap space.
java -Xms<initial heap size> -Xmx<maximum heap size>
Defaults are usually: java -Xms32m -Xmx128m
-Xm*s* - initial java heap size
-Xm*x* - maximum java heap size
-Xm*n* - the size of the heap for the young generation
This is a good article: http://java.sun.com/developer/technicalArticles/Programming/turbo/
Also, if this solves your problem please check it off so I can get some points. I've been out of the game for awhile.
Ike Wiggins
http://bipublisher.blogspot.com -
Data in XML format (XML files) to BW?
Hi,
My customer is interested in loading data to BW (from 3rd party system) in XML format. Are there any advantages of doing this (compared to traditional ascii files)? How about disadvantages (BW version is 3.5) ?. How to get started with this one, I noticed there is a possibility to create a XML data source. Is this able to take XML files into BW or what?.
Any help highly appreciated!Hi Jimmy,
Have a look:
http://help.sap.com/saphelp_nw04/helpdata/en/9b/821140d72dc442e10000000a1550b0/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/55/014e3c97f6bb3ee10000000a114084/content.htm
Hope it Helps
Srini
Maybe you are looking for
-
Looking for a lost loop (from old Access Virus freebie pack?)
Slightly bizarre question, but someone here might have the answer. In the last 6 months, I've changed countries and continents, upgraded to a new Mac and new version of GarageBand -- and somewhere in this shuffle I've lost some of the freely download
-
Vista & OSX wifi performance on MacBook Pro
MacBook Pro 2.4Ghz, 4Gb ram, OSX 10.5.2, Airport Extreme 802.11n, Airport Express 802.11n extending network Noticing dreadful wifi performance while running OSX (trace below) compared to performance when runing Vista (Bootcamp) on the same laptop. In
-
NullPointerException by Servlets Calls
if I call a Servlet "http://www.myhost.ch:8080/testing/Hello", I receive the follwoing Errormessage: Error: 500 Location: /testing/Hello Internal Servlet Error:java.lang.NullPointerException at java.lang.ClassLoader.resolveClass(ClassLoader.java) Hel
-
Image.getScaledInstance doesn't scale
Hi All! I've got a problem with image scaling of JPG file. In the constructor body of my class that inherites from JPanal I wrote following code: Image image,image1; image = (new ImageIcon(this.getClass().getResource("/Pics/about.jpg"))).getImage();
-
Hi All, I need help on sql loader shell scripting basically since my input file is csv file will load into some target table say xx_90 along defining with control and data file. what where the data that goes into the bad file a segment of scripting t