Why SAX parser unable to parse 2 lines tag

Hi all
I am going read through SAX parser a 2 lines coded matter in XML tag but its only able to read one line its not comming for the second line why...
I am forwarding one jsp to another jsp file i got an exception like this ... why
java.io.IOException attemting to clear the buffer is already flushed...
Plz help me with this.....
Thq and regards
Sarma.Y

prohan86 wrote:
Hi,
Thanks for the reply..
Can u explain me when to call it and how to call it multiple times??
Regards,
RohanYOU never call it. It is a callback method called by the SAX parser. You are just required to process the calls but your must handle the fact that it can be called many times for a given node.

Similar Messages

  • JAVA mapping using SAX parser adds extra tags

    Hi,
      We are using  java mapping using a SAX parser.It works well in standalone application ie it parses correctly and gets our desired xml structure and the xml is well formed too but when we import it in XI as a jar file it does not throw any errors but adds extra start tags, as a result the output xml is not well formed.XI is adding extra start tags.
    If any one else has faced a similar situation please help.
    Regards,
    Anirban.

    Hi Roberto,
    Thank you for the response.
    As I said, it doesnt throw any error. It is working perfectly in standalone application. But when we deploy it to XI Server, it is not forming the well formed XML. We too are puzzled by this situation.
    Okay, i will explain my scenario here.
    The following is my input XML to the java pgm..
    <Header>
    </Header>
    <Body>
    </Body>
    <SubBody1>
    </SubBody1>
    <SubBody2>
    </SubBody2>
    <SubBody3>
    </SubBody3>
    <SubBody4>
    </SubBody4>
    <Trail>
    </Trail>
    The desired output is
    <Header>
      <Body>
         <NameChanged1>
            <NameChanged2>
    <SubBody3>
    <SubBody4>
    </SubBody4>
    </SubBody3>
    </NameChanged2>
    </NameChanged1>
    <Trail>
    </Trail>
    Just look at the SubBody2 and SubBody1 node, its tag name has been changed in the output XML. Thats y i have decided to use java mapping instead of message mapping.
    I have developed the code for everything, i.e for changing the tag name and for forming the nested xml and it is working fine as a standalone application. But while deploying it to XI, the output is not well formed. I dont know the reason for it. Even I have checked the cardinality of the output Data types, that I have created. Its perfectly okay with all.
    Any Ideas???
    Regards,
    Anirban

  • Why am I unable to open on line pdf files using Adobe Reader version XI?

    When we go online to view pdf versions of statements at our bank's web site we are unable to view anything but a blank Adobe document. We are unable to download the file to our computer so there is no way for us to view the document. We have Mozilla version 29.0.1 and Adobe Reader XI. Is there anything we can do to correct the issue?

    Have you tried using the reader as a helper application? Will any other PDF reader work?

  • Why are all the events in the XML SAX parser not activated?

    Hi everyone,
    I have written a mini server that parses XML files into SQL queries.
    Below is a segment of my code;
              try          {                                                       
                   Class.forName( JDBC_DRIVER );
                   myConnection = DriverManager.getConnection( DATABASE_URL, "username", "password");                                                  
                   EventXMLParser myEXP = new EventXMLParser(directory, myConnection);
                   File[] xmlFiles = directory.listFiles();
                   for (File xmlFile : xmlFiles)               {     
                        myEXP.XMLtoDB(xmlFile);
                        outWriter.println("File:" + xmlFile.getName() + " DONE");
              } catch (SQLException e)     {
                   System.err.println("SQLException for establishing connection");
                   e.printStackTrace();
              } catch (ClassNotFoundException e)     {
                   System.err.println("CLASS NOT FOUND EXCEPTION HERE");
                   e.printStackTrace();
              } catch (Exception e)     {
                   System.err.println(e);
                   e.printStackTrace();
              finally {
                   outWriter.println("PARSING COMPLETED");
                   outWriter.close();
         }Where the constructor EventXMLParser constructs the following:
         public EventXMLParser(File path, Connection connection)     {
              super();
              try     {
                   this.XMLpath = path;
                   this.db_connection = connection;
                   this.xr = XMLReaderFactory.createXMLReader();
                   this.XMLSAXhandler  = new DefaultHandler(); //create a new own handler
                   this.xr.setContentHandler(XMLSAXhandler);
                   this.xr.setErrorHandler(XMLSAXhandler);
                   //System.out.println("DEBUG: db_connection is " + db_connection.toString());
              catch (Exception e)     {
                   System.out.println("Constructor Error!");
                   e.printStackTrace();
         }Below are all my helper methods within EventXMLParser.java
         public void XMLtoDB(String XMLpath) throws Exception  {
              try     {
                   //Input
                   System.out.println("XMLpath is : " + XMLpath);
                   /*FileReader r = new FileReader(XMLpath); debug
                   InputSource in = new InputSource(r);
                   xr.parse(in);
                   xr.parse(XMLpath);
                   /* Note that while parsing, the end of each event, </event>
                    * will trigger sendSQL to execute the query on the database
              catch (Exception e)     {
                   throw new Exception("Error with XMLtoDB!! Exception: " + e);
         public void sendSQL(Event event, Connection sql_connection) throws SQLException     {
                   //JDBC part
                   try     {
                        System.err.println("DEBUG sendSQL");
                        Statement sql_statement = sql_connection.createStatement();
                        ResultSet resultSet = sql_statement.executeQuery( event.toSQL() );
                   catch (SQLException e)     {
                        e.printStackTrace();
         /* Parsing XML
          * From here onwards it's all designed for the SAX Parsing with different event calling methods
         public void startDocument()     {
              System.err.println("Start Document");
         public void endDocument()     {
              System.err.println("End Document");
         public void startElement(String uri, String name, String qName, Attributes atts)     {
              CurrentElement= name;
              System.out.println("This is parsing");
         public void characters(char ch[], int start, int length)     {
              SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
              StringBuffer sb = new StringBuffer();
              for (int i = start; i < start + length; i++)     
                   sb.append(ch);
              String content = sb.toString();
              if (CurrentElement.equals("eid"))
                   temp.setEventID( (Integer.valueOf(content)).intValue() ) ;
              else if (CurrentElement.equals("sd"))
                   temp.setShort_description(content);
              else if (CurrentElement.equals("ld"))
                   temp.setLong_description(content);
              else if ( (CurrentElement.equals("dt")))
                   temp.setDate_Time( formatter.parse(content, new ParsePosition(0)) );
              else if (CurrentElement.equals("repeat"))
                   temp.setRepeat_pattern( (Integer.valueOf(content)).intValue() );
              else if (CurrentElement.equals("valid"))
                   temp.setValid_period(content);
              else if (CurrentElement.equals("status"))     {
                   temp.setStatus( (Integer.valueOf(content)).intValue() );
              else {}
         public void endElement(String uri, String name, String qName)     {
              System.err.println("DEBUG" + temp.toString()); /*debug*/
              if (name.equals("event"))     {
                   try     {
                        /*debug*/ temp.setUserID(1);
                        /*debug*/ System.err.println("DEBUG: " + temp.toString());
                        sendSQL(temp, db_connection);
                        //temp = new Event();
                   catch (SQLException e)     {
                        System.err.println(e);
                   }//end catch
              }//end try
    Where event is a public class Event     {
         //fields
         private int userID = 1; // = 1 only applies for testing
         private int eventID;
         private String short_description;
         private String long_description;
         private Date date_time = null;
         private int repeat_pattern;
         private String valid_period;
         private int status;     //1 for new, 0 for modification and -1 for delete
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
         //Constructors
         //every event requires the following: userID eventID and short_Description
         public Event(int uID, int eID, String shortDescrp)     {
              setUserID(uID);
              setEventID(eID);
              setShort_description(shortDescrp);
         public Event(int uid, int eid, String sd,
                                  String ld, Date d_t, int r_p, String v_p, int s)     {
              setUserID(uid);
              setEventID(eid);
              setShort_description(sd);
              setLong_description(ld);
              setDate_Time(d_t);
              setRepeat_pattern(r_p);
              setValid_period(v_p);
              setStatus(s);
         //set
         public void setUserID (int x)                         { this.userID = x ;}
         public void setEventID (int x)                         { this.eventID = x ;}
         public void setShort_description (String x)          { this.short_description = x ;}
         public void setLong_description (String x)          { this.long_description = x ;}
         public void setDate_Time(Date x)                    { this.date_time = x ;}
         public void setRepeat_pattern (int x)               { this.repeat_pattern = x ;}
         public void setValid_period (String x)               { this.valid_period = x ;}
         public void setStatus (int x)                         { this.status = x; }
         //get
         public int           getUserID()                              { return this.userID;}
         public int           getEventID()                         { return this.eventID;}
         public String      getShort_description()               { return this.short_description;}
         public String      getLong_description()               { return this.long_description;}
         public Date        getDate_Time()                         { return this.date_time;}
         public int         getRepeat_pattern()                    { return this.repeat_pattern;}
         public String      getValid_period()                    { return this.valid_period;}
         public int           getStatus()                              { return this.status; }
         //Event to SQL statements;
         public String toSQL()     {
              StringBuffer sb = new StringBuffer();
              ///if ( status == 1)     {
                   sb.append( "INSERT INTO events SET" );
                   sb.append( " userID = " + userID + ", ");
                   sb.append( "eventID = " + eventID + ", " );
                   sb.append( "short_description = " + "\'" + short_description + "\'" + ", "); //String
                   sb.append( "long_description = " + "\'" + long_description + "\'"  + ", "); //String
                   sb.append( "date_time = " + "\'" + formatter.format(date_time) + "\'" + ", ");
                   sb.append( "repeat_pattern = " + repeat_pattern + ", " );
                   sb.append( "valid_period = " + "\'" + valid_period + "\'" ); //String
                   sb.append( ";");
              //} else if ( status == 2)      {
              System.err.println(sb.toString());
              return sb.toString();
    }     My question is: I have taken my SQL query generated by toSQL() method in events and it worked.
    Here is the funny thing:
    Everything is correct syntax wise: No complaints what soever
    The mysql part works: Tested separately.
    So I tend to think that the problem lies within the SAX parser. I have written SAX2 parsers on this machine before and they have worked too. I tried inserting println statements all over startElement endElement etc etc only to find out that the SAX parser did not call any of the methods that I overided!! Why is that so?
    Can you guys spot where my SAX parser fails?

    I see.
    I try to correct this problem by removing super();
    so right now my code looks like this:
         static Event temp = new Event(0, 0, "null", "null", new Date(), 0, "null", 0);
         static String CurrentElement = null;
         static File XMLpath;
         static Connection db_connection;
         static XMLReader xr;
         static DefaultHandler XMLSAXhandler; 
         //Constructor,      Build the SAX Parser
         public EventXMLParser(File path, Connection connection)     {
              try     {
                   this.XMLpath = path;
                   this.db_connection = connection;
                   this.xr = XMLReaderFactory.createXMLReader();
                   this.XMLSAXhandler  = new DefaultHandler(); //create a new own handler
                   this.xr.setContentHandler(XMLSAXhandler);
                   this.xr.setErrorHandler(XMLSAXhandler);
                   //System.out.println("DEBUG: db_connection is " + db_connection.toString());
              catch (Exception e)     {
                   System.out.println("Constructor Error!");
                   e.printStackTrace();
         }This time, I created a new instance of default handler() which can be referenced by as the objects's XMLSAXhandler. However, that did not solve the problem, why does the problem still persist?
    Right now, there is only one instance of a default handler created. So why does all my parsing event functions still get ignored?

  • Why the SAX parser cannot support the special character like "¡"

    I do not understand why the SAX parser cannot support the special character like &iexcl; but it can replace the &quot; &amp; &lt; &gt;   to ", &, <, >, ,, but other characters will be replaced to empty charater.
    can somebody give me any suggestions or solutions. THX.
    Edited by: 844086 on 2011-3-14 上午2:27
    Edited by: 844086 on 2011-3-14 上午2:27

    I quote:
    Alternatively implement an EntityResolver that resolves the desired escapes.You are again an example that people only read/register the first thing written in a post.

  • SAX Parser: ArrayIndexOutOfBoundsException

    Attachments: "1|type=text/xml|desc=test xml file|16821|file=test.xml|"
    I am using your Java XML parser v2.0.0.2. With some XML files
    the SAX parser raises an ArrayIndexOutOfBoundsException:
    Exception in thread "main"
    java.lang.ArrayIndexOutOfBoundsException
    at oracle.xml.parser.v2.XMLCharReader.fillBuffer
    (XMLCharReader.java, Compiled Code)
    at oracle.xml.parser.v2.XMLReader.tryRead
    (XMLReader.java, Compiled Code)
    at oracle.xml.parser.v2.NonValidatingParser.parseElement
    (NonValidatingParser.java, Compiled Code)
    at
    oracle.xml.parser.v2.NonValidatingParser.parseRootElement
    (NonValidatingParser.java:227)
    at oracle.xml.parser.v2.NonValidatingParser.parseDocument
    (NonValidatingParser.java:192)
    at oracle.xml.parser.v2.XMLParser.parse
    (XMLParser.java:119)
    at RegisterXMLParser.DocParser.parseDocument
    (DocParser.java:51)
    at RegisterXMLParser.RegisterParser.main
    (RegisterParser.java, Compiled Code)
    For testing purposes I used the SaxSample java code to test when
    this exception was raised. I found out that the number of tags
    used, and the length of the tags had their influence on the
    moment of exception. Even when I added some comment lines after
    the XML processing instruction, the exception was raised earlier.
    I Used a test XML file with the following layout:
    <?xml version="1.0" encoding="Cp850"?>
    <!-- edited with XML Spy v2.5 NT - http://www.xmlspy.com -->
    <!--Gegenereerd door: Jeen Landstra-->
    <!--Versie programma: 1.0-->
    <!--Datum creatie: 10251999-->
    <!--Tijd creatie: 161709-->
    <HOOFD>
    <RECHT-1910>
    <RECHT>
    <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    ... repeated 359 times ...
    <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    </RECHT>
    </RECHT-1910>
    </HOOFD>
    Deleting only one
    row '<AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>' makes the parser
    work properly.
    I hope you can explain why this can't be parsed, and how i
    should fix this problem.
    thanks for your response!
    Rolf van Deursen
    null

    Rolf van Deursen (guest) wrote:
    : rolf van Deursen (guest) wrote:
    : : I am using your Java XML parser v2.0.0.2. With some XML
    files
    : : the SAX parser raises an ArrayIndexOutOfBoundsException:
    : : Exception in thread "main"
    : : java.lang.ArrayIndexOutOfBoundsException
    : : at oracle.xml.parser.v2.XMLCharReader.fillBuffer
    : : (XMLCharReader.java, Compiled Code)
    : : at oracle.xml.parser.v2.XMLReader.tryRead
    : : (XMLReader.java, Compiled Code)
    : : at
    : oracle.xml.parser.v2.NonValidatingParser.parseElement
    : : (NonValidatingParser.java, Compiled Code)
    : : at
    : : oracle.xml.parser.v2.NonValidatingParser.parseRootElement
    : : (NonValidatingParser.java:227)
    : : at
    : oracle.xml.parser.v2.NonValidatingParser.parseDocument
    : : (NonValidatingParser.java:192)
    : : at oracle.xml.parser.v2.XMLParser.parse
    : : (XMLParser.java:119)
    : : at RegisterXMLParser.DocParser.parseDocument
    : : (DocParser.java:51)
    : : at RegisterXMLParser.RegisterParser.main
    : : (RegisterParser.java, Compiled Code)
    : : For testing purposes I used the SaxSample java code to test
    : when
    : : this exception was raised. I found out that the number of
    tags
    : : used, and the length of the tags had their influence on the
    : : moment of exception. Even when I added some comment lines
    : after
    : : the XML processing instruction, the exception was raised
    : earlier.
    : : I Used a test XML file with the following layout:
    : : <?xml version="1.0" encoding="Cp850"?>
    : : <!-- edited with XML Spy v2.5 NT - http://www.xmlspy.com -->
    : : <!--Gegenereerd door: Jeen Landstra-->
    : : <!--Versie programma: 1.0-->
    : : <!--Datum creatie: 10251999-->
    : : <!--Tijd creatie: 161709-->
    : : <HOOFD>
    : : <RECHT-1910>
    : : <RECHT>
    : : <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    : : <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    : : ... repeated 359 times ...
    : : <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    : : <AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>
    : : </RECHT>
    : : </RECHT-1910>
    : : </HOOFD>
    : : Deleting only one
    : : row '<AANVRAGER_HOUDER>test</AANVRAGER_HOUDER>' makes the
    : parser
    : : work properly.
    : : I hope you can explain why this can't be parsed, and how i
    : : should fix this problem.
    : : thanks for your response!
    : : Rolf van Deursen
    : I downloaded the newest version (2.0.2.4) of the Java parser.
    : This one is working correctly!
    Great! That was going to be my answer.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Error in SAX Parsing

    Hi Team,
    I am facing an issue while implementing a java mapping through SAX parsing.I am explaining it in details:
    Source Structure   
    =================
    MT_OB_SAX_MAP
    >NUMBER1
    >NUMBER2
    Target Structure
    ==================
    MT_IB_SAX_MAP
    >ADD
    >MUL
    >SUB
    The code that has been written to achieve this is:
    //import java.io.FileInputStream;
    //import java.io.FileOutputStream;
    import com.sap.aii.mapping.api.StreamTransformation;
    import java.io.*;
    import java.util.Map;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    public class saxmapfinal1 extends DefaultHandler implements StreamTransformation
    private Map map;
    private OutputStream out;
    private boolean input1 = false;
    private boolean input2 = false;
    private int number1;
    private int number2;
    private int addvalue;
    private int mulvalue;
    private int subvalue;
    String lineEnd =  System.getProperty("line.separator");
    public void setParameter (Map param)
    map = param;
    public void execute (InputStream in, OutputStream out)
    throws com.sap.aii.mapping.api.StreamTransformationException
    DefaultHandler handler = this;
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
          SAXParser saxParser = factory.newSAXParser();
          this.out = out;
          saxParser.parse(in, handler);
    catch (Throwable t)
    t.printStackTrace();
    private void write (String s) throws SAXException{
    try{
    out.write(s.getBytes());
    out.flush();
    catch (IOException e){
    throw new SAXException("I/O error", e);
    public void startDocument () throws SAXException{
    write("<?xml version=1.0 encoding=UTF-8?>");
    write(lineEnd);
    write("<ns0:MT_IB_SAX_MAP xmlns:ns0=urn:bp:xi:hr:edm:test:100>");
    write(lineEnd);
    public void endDocument () throws SAXException
    write("</ns0:MT_IB_SAX_MAP>");
    try { out.flush();
    catch (IOException e) {
    throw new SAXException("I/O error", e);
    public void startElement (String namespaceURI, String sName, String qName,Attributes attrs)  
    throws SAXException {
    String eName = sName;
    if ("".equals(eName))
    eName = qName;
    if(eName.equals("NUMBER1"))
    input1 = true;
    if(eName.equals("NUMBER2"))
    input2 = true;             
    public void endElement (String namespaceURI, String sName, String qName) throws SAXException {
    String eName = sName;
    if ("".equals(eName))
    eName = qName;
    if(eName.equals("NUMBER1"))
    input1 = false;
    if(eName.equals("NUMBER2"))
    input2 = false;
    public void characters(char[] chars,int startIndex, int endIndex) throws SAXException
    String dataString =
    new String(chars, startIndex, endIndex).trim();
    if (input1) {
    try
    number1 = Integer.parseInt(dataString);
    } catch(NumberFormatException nfe)
    if (input2) {
    number2 = Integer.parseInt(dataString);
    if (input2 == true)
    addvalue = number1 + number2;
    mulvalue =  number1 * number2;
    subvalue = number1 - number2;
    write("<ADD>" + addvalue +"</ADD>");
    write(lineEnd);
    write("<MUL>" + mulvalue +"</MUL>");
    write(lineEnd);
    write("<SUB>" + subvalue +"</SUB>");
    write(lineEnd);
    But while executing this in XI I am facing an error as "XML not well formed" but I am not able to know why this error is comming.
    Can you please throw some light why this error is happening.?IWhat us the error in the code and what should be the correct code?
    Many thanks for the support that I got in past.
    Regards
    Atanu Mazumdar
    Edited by: ATANU1 on Apr 4, 2011 4:16 PM

    Just use characters() method for building string. Use endElement() to process that string.

  • Sax parser problem

    hi,
    i am assuming the problem is with sax parser but i cant be sure. I am parsing a xml file (about 1.4MB) with some data in it. the parser i have created reads the xml file correctly for the most part but when at some point the
    "public void characters(char buf[], int offset, int len) throws SAXException"
    function stops working correctly....i.e it doesnt fully read read the data between the "<start>" and "</start>" element. say it reads about 100 id's correctly---for 101 ID it does this. This is just an example. Since, the problem might be with how :
    "public void characters(char buf[], int offset, int len) throws SAXException"
    function is reading the data i was wondering if anybody else had encountered this problem or please let me know if i need to change something in the code: here's a part of the code :
    Bascially i have created three classes to enter data into three mysql tables and as i parse the data i fill up the columns by matching the column header with the tagName.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.*;
    import java.io.*;
    import java.util.ArrayList;
    import java.lang.Object;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    public class Echo03 extends DefaultHandler
    StringBuffer textBuffer;
    int issuedValue, prodValue;
    OrdHeader header = new OrdHeader();
    OrdDetail detail = new OrdDetail();
    Member memInfo = new Member();
    //new addition to store the dynamic value of the products
    TestOrdheader prod = new TestOrdheader();
    int counter;
    String tag, newTag;
    SetValue setVal = new SetValue();
    String test;
    public static void main(String argv[])
    if (argv.length != 1) {
    System.err.println("Usage: cmd filename");
    System.exit(1);
    // Use an instance of ourselves as the SAX event handler
    DefaultHandler handler = new Echo03();
    // Use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
    // Set up output stream
    out = new OutputStreamWriter(System.out, "UTF8");
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse( new File(argv[0]), handler);
    } catch (Throwable t) {
    t.printStackTrace();
    System.exit(0);
    static private Writer out;
    private String indentString = " "; // Amount to indent
    private int indentLevel = 0;
    //===========================================================
    // SAX DocumentHandler methods
    //===========================================================
    public void startDocument()
    throws SAXException
    nl();
    nl();
    emit("START DOCUMENT");
    nl();
    emit("<?xml version='1.0' encoding='UTF-8'?>");
    header.assign();
    public void endDocument()
    throws SAXException
    nl(); emit("END DOCUMENT");
    try {
    nl();
    out.flush();
    } catch (IOException e) {
    throw new SAXException("I/O error", e);
    public void startElement(String namespaceURI,
    String lName, // local name
    String qName, // qualified name
    Attributes attrs)
    throws SAXException
    indentLevel++;
    nl(); //emit("ELEMENT: ");
    String eName = lName; // element name
    if ("".equals(eName)) eName = qName; // namespaceAware = false
    if (qName.equals("Billing")){
    issuedValue = 1;
    }else if (qName.equals("Shipping")){
    issuedValue = 2;
    }else if (qName.equals("ShippingTotal")){
    issuedValue = 3;
    //check to see if "Product" is the name of the element thats coming next
    if (qName.equals("Product")){
    if (issuedValue != 3){
    prodValue = 1;
    prod.addCounter();
    }else{
    prodValue = 0;
    tag = eName;
    if (attrs != null) {
    for (int i = 0; i < attrs.getLength(); i++) {
    String aName = attrs.getLocalName(i); // Attr name
    if ("".equals(aName)) aName = attrs.getQName(i);
    nl();
    emit(" ATTR: ");
    emit(aName);
    emit("\t\"");
    emit(attrs.getValue(i));
    emit("\"");
    if (attrs.getLength() > 0) nl();
    public void endElement(String namespaceURI,
    String sName, // simple name
    String qName // qualified name
    throws SAXException
    nl();
    String eName = sName; // element name
    if ("".equals(eName)){
    eName = qName; // not namespaceAware
    if ("Order".equals(eName)){          
    //enter into database
         databaseEnter();
    textBuffer = null;
    indentLevel--;
    public void characters(char buf[], int offset, int len)
    throws SAXException
    nl();
    try {
    String s = new String(buf, offset, len);
    if (!s.trim().equals("")){
    settag(tag, s);
    s = null;
    }catch (NullPointerException E){
    System.out.println("Null pointer Exception:"+E);
    //===========================================================
    // Utility Methods ...
    //===========================================================
    // Wrap I/O exceptions in SAX exceptions, to
    // suit handler signature requirements
    private void emit(String s)
    throws SAXException
    try {
    out.write(s);
    out.flush();
    } catch (IOException e) {
    throw new SAXException("I/O error", e);
    // Start a new line
    // and indent the next line appropriately
    private void nl()
    throws SAXException
    String lineEnd = System.getProperty("line.separator");
    try {
    out.write(lineEnd);
    for (int i=0; i < indentLevel; i++) out.write(indentString);
    } catch (IOException e) {
    throw new SAXException("I/O error", e);
    ===================================================================
    ///User defined methods
    ===================================================================
    private String strsplit(String splitstr){
    String delimiter = new String("=");
    String[] value = splitstr.split(delimiter);
    value[1] = value[1].replace(':', ' ');
    return value[1];
    public void settag(String tag, String s){         
    String pp_transid = null, pp_respmsg = null,pp_authid = null, pp_avs = null, pp_avszip = null;
    if ((tag.equals("OrderDate")) || (tag.equals("OrderProcessingInfo"))){
    if (tag.equals("OrderDate")){
    StringTokenizer st = new StringTokenizer(s);
    String orddate = st.nextToken();
    String ordtime = st.nextToken();
    header.put("ordDate", orddate);
    header.put("ordTime", ordtime);
    }else if (tag.equals("OrderProcessingInfo")){
    StringTokenizer st1 = new StringTokenizer(s);
    int tokenCount = 1;
    while (tokenCount <= st1.countTokens()){
    switch(tokenCount){
    case 1:
    String extra = st1.nextToken();
    break;
    case 2:
    String Opp_transid = st1.nextToken();
    pp_transid = strsplit(Opp_transid);
    break;
    case 3:
    String Opp_respmsg = st1.nextToken();
    pp_respmsg = strsplit(Opp_respmsg);
    break;
    case 4:
    String Opp_authid = st1.nextToken();
    pp_authid = strsplit(Opp_authid);
    break;
    case 5:
    String Opp_avs = st1.nextToken();
    pp_avs = strsplit(Opp_avs);
    break;
    case 6:
    String Opp_avszip = st1.nextToken();
    pp_avszip = strsplit(Opp_avszip);
    break;
    tokenCount++;
    header.put("pp_transid", pp_transid);
    header.put("pp_respmsg", pp_respmsg);
    header.put("pp_authid", pp_authid);
    header.put("pp_avs", pp_avs);
    header.put("pp_avszip", pp_avszip);
    }else{
    newTag = new String(setVal.set_name(tag, issuedValue));
    header.put(newTag, s);
    //detail.put(newTag, s);
    prod.put(newTag, s);
    memInfo.put(newTag,s);
    //Check to see-- if we should add this product to the database or not
    boolean check = prod.checkValid(newTag, prodValue);
    if (check){
    prod.addValues(s);
    setVal.clearMod();
    ==================================================================
    Here's the error that i get:
    java.util.NoSuchElementException
    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:691)
    at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
    at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:281)
    at Echo03.main(Echo03.java:47)

    I haven't gone through your code but I also had a similar error....and the exception in my was because of an "&" instead of the entity reference & in one of the element values. I use a non-validating parser but if you use a validating one then this might not be the reason for your exception.

  • SAX Parser

    I am using the sax parser provided by the package javax.xml.parsers to parse an XML file. It works fine as long as I have an XML file which has English characters. When I use it for parsing a file which has Korean characters in it, the parser fails to recognize them.
    It used to throw an error "Line too long" on reading the Korean characters. Then I added an XML directive encoding="EUC-KR" and now it reads the file but does not recognize the characters correctly. It reads all the korean characters as question marks ('??').
    Any pointers on what can be done to fix this problem.
    Thanks,
    RahulJ

    Hi,
    We've got a very similar problem. I'm parsing with SAX and DOM but the MS special characters keep appearing as ? or ??.
    If the encoding is not specified in the XML file there are Parser Exceptions. If I set the encoding to "JISAutoDetect", "JIS", "MS932", "Cp1250 to Cp1258" or "ISO8859-1" then there are no exceptions but the stray characters still appear as ?s.
    I managed to display the left and the right quotation marks in a servlet by setting the response Content Type to "text/html; charset=Shift_JIS" and the encoding="Cp1252" in the XML file. But I still have problems with the rest of the characters.
    What kind of output do you use? Do you display in a web page or you just write to a file?
    Thanks,
    Ross

  • Using the SAX Parser

    As I reported in this thread: Carriage Returns in XSLT output I am trying to produce a text output file with each line terminating in cr-lf (using the output from ViewObject.writeXML() passed through the XSLProcessor.processXSL() method to apply a XSLT stylesheet transformation to it), but the cr characters in the stylesheet are being converted to nl characters, so I am ending up with two nl characters at the end of each line.
    I found a 2002 query (here: http://www.xslt.com/html/xsl-list/2002-04/msg00193.html) by someone with the same problem, and a reply by Steve Muench explaining it and stating that the Oracle SAX parser does not have the same problem.
    So my question now is - does the SAX parser still retain cr characters (or is it too now converting them to nl) and if it does, how do I make XSLProcessor.processXSL() use it rather than the default XML parser? Can I do it from within my code, or does it need to be set in some sort of environment variable? We are on version 9.0.5.2 of JDeveloper(10g)

    Repost

  • Problem in parsing an XML using SAX parser

    Hai All,
    I have got a problem in parsing an XML using SAX parser.
    I have an XML (sample below) which need to be parsed
    <line-items>
    <item num="1">
         <part-number>PN1234</part-number>
         <quantity uom="ea">10</quantity>
         <lpn>LPN1060</lpn>
         <reference num="1">Line ref 1</reference>
         <reference num="2">Line ref 2</reference>
         <reference num="3">Line ref 3</reference>
    </item>
    <item num="2">
         <part-number>PN1527</part-number>
         <quantity uom="lbs">5</quantity>
         <lpn>LPN2152</lpn>
         <reference num="1">Line ref 1</reference>
         <reference num="2">Line ref 2</reference>
         <reference num="3">Line ref 3</reference>
    </item>
    <item num="n">
    </item>
    </line-items>
    There can be any number of items( 1 to n). I need to parse these
    item values using SAX parser and invoke a stored procedure for
    each item with its
    values(partnumber,qty,lpn,refnum1,refnum2,refnum3).
    Suppose if there are 100 items, i need to invoke the stored
    procedure sp1() 100 times for each item.
    I need to invoke the stored procedure in endDocument() method of
    SAX event handler and not in endelement() method.
    What is the best way to store those values and invoke the stored
    procedure in enddocument() method.
    Any help would br greatly appreciated.
    Thanks in advance
    Pooja.

    VO or ValueObject is a trendy new name for Beans.
    So just create an item class with variables for each of the sub elements.
    <item>
    <part-number>PN1234</part-number>
    <quantity uom="ea">10</quantity>
    <lpn>LPN1060</lpn>
    <reference num="1">Line ref 1</reference>
    <reference num="2">Line ref 2</reference>
    <reference num="3">Line ref 3</reference>
    </item>
    public class ItemVO
    String partNumber;
    int quantity;
    String quantityType;
    String lpn;
    List references = new ArrayList();
    * @return Returns the lpn.
    public String getLpn()
    return this.lpn;
    * @param lpn The lpn to set.
    public void setLpn(String lpn)
    this.lpn = lpn;
    * @return Returns the partNumber.
    public String getPartNumber()
    return this.partNumber;
    * @param partNumber The partNumber to set.
    public void setPartNumber(String partNumber)
    this.partNumber = partNumber;
    * @return Returns the quantity.
    public int getQuantity()
    return this.quantity;
    * @param quantity The quantity to set.
    public void setQuantity(int quantity)
    this.quantity = quantity;
    * @return Returns the quantityType.
    public String getQuantityType()
    return this.quantityType;
    * @param quantityType The quantityType to set.
    public void setQuantityType(String quantityType)
    this.quantityType = quantityType;
    * @return Returns the references.
    public List getReferences()
    return this.references;
    * @param references The references to set.
    public void setReferences(List references)
    this.references = references;

  • SAX Parsing in Adapter Module

    Hi All,
    I need to build a custom Adapter Module where i want to use SAX Parsing for parsing XML document. I tried with a piece of Code but i'm getting following error while running the same:
    Error occurred while sending message (GUID 6da4ff1c-3736-4990-1881-a8f09edd5fde): null
    When i check the Audit Log the i just see following two lines:
    Success Channel JDBC_s_Article_Grp1: Query executed successfully and confirmation skipped. Data may be sent again ("TEST" mode)
    Send query result. Size: 1398556 characters
    There are no logs being created for module at all. Also when i run the same code with DOM parsing, it works perfectly fine.
    I have tries with re-deployment multiple times but no result.
    Any pointers?
    Regards,
    Anurag

    try to handle exceptions and use logging to know what the issue is.
    That is the best way to troubleshoot your code
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3bdc14e1-0901-0010-b5a9-a01e29d75a6a?quicklink=index&overridelayout=true
    refer section 4.4.2 Writing Audit Logs

  • SAX Parser ClassCastException

    Guidance on the issue described below would be appreciated.
    Product Oracle Containers for J2EE Product Version 10.0.3
    Platform Microsoft Windows
    HOW TO OVERRIDE PARSER IN 10.0.3 OAS 10G PREVIEW 2
    ### Provide the full build number for the OC4J version that you are running: ###
    Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer
    Preview (build 040227.1923)
    ### Which type of OC4J installation are you running? ###
    standalone OC4J installation (from zip file)
    ### If this OC4J instance is 'standalone', where was it installed? ###
    it's own dedicated ORACLE_HOME
    ### Provide the exact text and location for any error seen in a log file: ###
    java
    -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
    -Djavax.xml.parsers.TransformerFactory=org.apache.xalan.processor.TransformerFac
    toryImpl
    -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerF
    actoryImpl -Dorg.dom4j.verbose=true -DCRN_ROOT=f:\cognos\crn -jar oc4j.jar
    04/03/23 10:51:25 Node started with id=68984609063434
    04/03/23 10:51:44 log4j:WARN LogFileWatchdog: shutDownHierarchy
    04/03/23 10:51:44 log4j:WARN LogIPFControl - Unknown error during initialize
    04/03/23 10:51:44 log4j: Setting IPF internal debugging to true
    04/03/23 10:51:45 log4j:WARN No appenders could be found for logger
    (Audit.RTUsage.CAM.CRP.jcam).
    04/03/23 10:51:45 log4j:WARN Please initialize the log4j system properly.
    04/03/23 10:51:46 log4j: Log Server Port is: 9362
    04/03/23 10:51:46 log4j: Encoding set to: false
    04/03/23 10:51:46 log4j: Number of Server Worker Threads is: 10
    04/03/23 10:51:46 log4j: Encoding set to: false
    04/03/23 10:51:46 log4j: Relative file path set to:
    F:/cognos/crn/logs/crnserver.log
    04/03/23 10:51:46 log4j: Exception encountered while trying to convert
    configuration document into W3C Document.
    04/03/23 10:51:46 log4j:ERROR null
    04/03/23 10:51:47 Warning: Caught exception attempting to use JAXP to load a
    SAX XMLReader
    04/03/23 10:51:47 Warning: Exception was: java.lang.ClassCastException
    04/03/23 10:51:47 Warning: I will print the stack trace then carry on using the
    default SAX parser
    04/03/23 10:51:47 java.lang.ClassCastException
    04/03/23 10:51:47 at
    javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
    04/03/23 10:51:47 at
    org.dom4j.io.JAXPHelper.createXMLReader(JAXPHelper.java:34)
    04/03/23 10:51:47 at
    org.dom4j.io.SAXHelper.createXMLReaderViaJAXP(SAXHelper.java:80)
    04/03/23 10:51:47 at
    org.dom4j.io.SAXHelper.createXMLReader(SAXHelper.java:49)
    04/03/23 10:51:47 at
    org.dom4j.io.SAXReader.createXMLReader(SAXReader.java:528)
    04/03/23 10:51:47 at
    org.dom4j.io.SAXReader.getXMLReader(SAXReader.java:411)
    04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:277)
    04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:201)
    04/03/23 10:51:47 at org.dom4j.io.SAXReader.read(SAXReader.java:190)
    04/03/23 10:51:47 at
    com.cognos.cclcfgapi.CCLStartupConfiguration.getConfigDoc
    (CCLStartupConfiguration.java:253)
    04/03/23 10:51:47 at
    com.cognos.cclcfgapi.CCLStartupConfiguration.getStartupConfigurationDocumen
    t(CCLStartupConfiguration.java:136)
    04/03/23 10:51:47 at
    com.cognos.cclcfgapi.CCLStartupConfiguration.getStartupConfigurationDocument
    (CCLStartupConfiguration.java:112)
    04/03/23 10:51:47 at
    com.cognos.cclcfgapi.CCLConfiguration.init(CCLConfiguration.java:209)
    04/03/23 10:51:47 at
    com.cognos.pogo.config.ConfigurationImpl.reconfigure(ConfigurationImpl.java:43)
    04/03/23 10:51:47 at
    com.cognos.pogo.services.DispatcherServices.startInititalServices(DispatcherServ
    ices.java:394)
    04/03/23 10:51:47 at
    com.cognos.pogo.transport.PogoServlet$PogoStartup.run(PogoServlet.java:499)
    04/03/23 10:51:47 at java.lang.Thread.run(Unknown Source)
    04/03/23 10:51:48 Oracle Application Server Containers for J2EE 10g
    (10.0.3.0.0) - Developer Preview initialized
    ### Describe in detail the problem you are having: ###
    Trying to override the parser used by our application and getting the error
    above in the console. I also have <web-app-class-loader
    search-local-classes-first="true" include-war-manifest-class-path="true" />
    set in the orion-web.xml for our application.
    I've tried various options on the command line, this seems to get the furthest
    but our app doesn't start.

    Thanks, I did try that as well.....
    E:\o10g\j2ee\home>java -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dorg.xml.sax.driver=
    org.apache.xerces.parsers.SAXParser -Djavax.xml.parsers.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl
    -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl -Xbootclasspath/a:e:\o10g\dom4j-1.
    4\dom4f-1.4\lib\tool\xerces.jar -DCRN_ROOT=f:\cognos\crn -jar oc4j.jar
    04/03/25 07:50:28 Node started with id=68984609063434
    04/03/25 07:50:35 setting transaction-timeout to:30000
    04/03/25 07:50:48 log4j:WARN LogFileWatchdog: shutDownHierarchy
    04/03/25 07:50:48 log4j:WARN LogIPFControl - Unknown error during initialize
    04/03/25 07:50:48 log4j: Setting IPF internal debugging to true
    04/03/25 07:50:49 log4j:WARN No appenders could be found for logger (Audit.RTUsage.CAM.CRP.jcam).
    04/03/25 07:50:49 log4j:WARN Please initialize the log4j system properly.
    04/03/25 07:50:50 log4j: Log Server Port is: 9362
    04/03/25 07:50:50 log4j: Encoding set to: false
    04/03/25 07:50:50 log4j: Number of Server Worker Threads is: 10
    04/03/25 07:50:50 log4j: Encoding set to: false
    04/03/25 07:50:50 log4j: Relative file path set to: F:/cognos/crn/logs/crnserver.log
    04/03/25 07:50:50 log4j: Exception encountered while trying to convert configuration document into W3C Document.
    04/03/25 07:50:50 log4j:ERROR null
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-7 JVM used memory: 8699568
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-8 JVM used memory: 8837624
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-9 JVM used memory: 8838480
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-10 JVM used memory: 8839536
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-11 JVM used memory: 8840392
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-12 JVM used memory: 8841248
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-13 JVM used memory: 8842304
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-14 JVM used memory: 8843160
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-15 JVM used memory: 8844016
    04/03/25 07:50:50 log4j: ***** Thread begin: Thread-16 JVM used memory: 8845072
    04/03/25 07:50:51 Warning: Error occurred using JAXP to load a SAXParser. Will use Aelfred instead
    04/03/25 07:50:52 Oracle Application Server Containers for J2EE 10g (10.0.3.0.0) - Developer Preview initialized

  • SAX Parser and special character problem

    Hi,
    Could anyone help with the following problem?
    Background:
    1. Using a SAX Parser (Oracle Implementation) to read XML from a CLOB, convert this XML to another format to be inserted in the database.
    2. Due to performance issues we parse the input stream from the CLOB.
    3. For same reason, we are not using XSL.
    This is the problem we face:
    1. Values of some of the tags in the XML have special characters (Ex: &, <, >).
    2. While using the SAX Parser, the element handler function for the SAX Parser is called by the frame work with the value of these tags broken up with each of these characters being treated as a tag delimiter.
    Ex: <Description>SomeText_A & SomeText_B</Description>
    is treated as SomeText_A in first call to the handler; SomeText_B in the second call.
    The handler function does not get to see the "&" character.
    Thus, the final conversion is
    Say, <Description> is to be converted to <FreeText>
    we, get <FreeText>SomeText_A</FreeText>
    <FreeText>SomeText_B</FreeText>
    We tried using &; but it then breaks it up into SomeText_A, & and SomeText_B.
    How can we get the whole value for the <Description> tag in the characters() function in the SAXParser so that we can convert it to <FreeText>SomeText_A & SomeText_B</FreeText>.
    Thanks in advance..
    Chirdeep.

    We already tried that..looks like the line where I mentioned that it converted the entity referece characters to an ampersand..
    "We tried using <entity reference for &> but it then breaks it up into SomeText_A, & and SomeText_B."
    null

  • SAX parser splits up character data; I expected Ign. whitesp

    Im am working on a XML parser for loading data from some back
    end systems into an Oracle 8i database. I am using the SAX
    parser for this purpose. After doing some tests with larger
    amounts of XML data (> 1M), I found some unexpected behaviour.
    The parser sometimes splits up character data into two chunks of
    data. The XML looks as follows:
    <TAGNAME> this is the character data </TAGNAME>
    The parser raises the following events:
    1 startElement name = "TAGNAME"
    2 characters chbuf = " "
    3 characters chbuf = "this is the character data "
    4 endElement name = "TAGNAME"
    I expected an ignorableWhitespace event at step 2. The XML
    document contains repetitive tagnames. The strange thing about
    the parse process is that the parser splits up the character
    data only sometimes, and I can't determine any kind of logica
    for this behaviour. Most occurrences of exactly the same tagname
    and character data are parsed correctly (that is, as I
    expected).
    Am I dealing with correct behaviour here, or is it a bug??
    Rolf.
    null

    Oracle XML Team wrote:
    : Rolf van Deursen (guest) wrote:
    : : Im am working on a XML parser for loading data from some
    back
    : : end systems into an Oracle 8i database. I am using the SAX
    : : parser for this purpose. After doing some tests with larger
    : : amounts of XML data (> 1M), I found some unexpected
    behaviour.
    : : The parser sometimes splits up character data into two
    chunks
    : of
    : : data. The XML looks as follows:
    : : <TAGNAME> this is the character data </TAGNAME>
    : : The parser raises the following events:
    : : 1 startElement name = "TAGNAME"
    : : 2 characters chbuf = " "
    : : 3 characters chbuf = "this is the character data "
    : : 4 endElement name = "TAGNAME"
    : : I expected an ignorableWhitespace event at step 2. The XML
    : : document contains repetitive tagnames. The strange thing
    about
    : : the parse process is that the parser splits up the character
    : : data only sometimes, and I can't determine any kind of
    logica
    : : for this behaviour. Most occurrences of exactly the same
    : tagname
    : : and character data are parsed correctly (that is, as I
    : : expected).
    : : Am I dealing with correct behaviour here, or is it a bug??
    : : Rolf.
    : The behavior is expected and correct. Could you elaborate on
    why
    : you would expect the parser to treat the whitespace signalled
    in
    : step 2 as ignorable?
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    Thank you for your quick response.
    In my test XML, there are about 27500 tags containing character
    data. All character data starts with a whitespace character.
    After parsing the xml, the whitespace of only 5 (!) tags is
    treated as a seperate character event (so two character events
    are raised in succession). The remaining tags all raise only ONE
    character event for the entire character data. I can't explain
    the difference in treatment.
    null

Maybe you are looking for

  • Can't change my Apple ID

    I tried to change my apple ID and after I hit save changes, it goes back to my old ID. It won't let me change it! What can I do to change to my new email address?

  • HP HD-2200

     My computer crashed due to a bad motherboard. Installed a new motherboard. Then installed HP HD-2200 webcam. The web cam does not work in Yahoo. What do I do?

  • No fiscal year variant specified - error upon DSO activation

    In my DSO I need 2 fiscal periods - document day period and payment day period. For the first I use 0FISCPER IObj, for the second I've created CFISCPER (with a reference characteristic 0FISCPER). CFISCPER has 0FISCVARNT as compounding. There some occ

  • Adobe not allowing edits and seems to continue searching for server

    Currently running Adobe 10 on a PC and working with a document that is in collaboration with 2 other authors. The issue I am currently having is that I wish to be able to open the Document, make the necessary edits (and or comments) then save the doc

  • Avoiding duplicates in Pi

    Hi All, I am having scenario  where sap is getting data from ERP system  trough PI ( JMS to ABAP Proxy). Is there any mechanism to avoid duplicates with out sending to sap which are coming form sender. If yes can you please provide me the  procedure.