SAX Parser For XML

Hello all,
I am trying Parsing XML thorugh SAX. Were to get SJXP.jar and parser.jar files on sun site
if any body have these files plz mail :[email protected]

String buf = (new String(ch, start, length)).trim();
if (thisElement != "root"){   
if ((buf.length() == 0) && (thisElement !="") ){
It run ok!
Thanks 58871!
Now, i want to export oracle table to xml file like :
<?xml version="1.0" encoding="UTF-8"?>
<root>
<emp>
<ename>aaa</ename>
<sal>3000</sal>
</emp>
<emp>
<ename>bbb</ename>
<sal>5000</sal>
</emp>
</root>
Can SAX export to xml format?
Pham Thanh Tung

Similar Messages

  • Java +XML (SAX) Parser for Oracle 8.1.5 EE

    Hi there :)
    I am looking java classes for SAX to parse XML. I cannot find a valid parser, cause after downloaded from Oracle XDK for java, when i try to load this calasses i get a messages that i alot of classes connot be resolved.
    If somebody have valid classes on Ora 8.1.5 please send me mail.
    Adam

    Have i possibilities to using some javatypes in oracle java stored procedure if this class is not loaded into db?
    Cause i would like to create a java stored procedure to parse and insert some data from xml. I was thinking to pass xml file name as a parameter to my java procedure.
    I must use Oracle 8.1.5 with jdk 1.1.7, and the best parser for me is SAX.
    Please help.
    Have i possobilities to use class inside oracle, which are placed outside oracle?
    Something like classpath, where can i modify value (but classpath inside oracle)?

  • Sax Parser for loading XML file

    We have a requirment by which we need to load huge XMl file in our DB everyday.
    THe XML file format is like --
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <emp>
    <ename>aaa</ename>
    <sal>3000</sal>
    </emp>
    <emp>
    <ename>bbb</ename>
    <sal>5000</sal>
    </emp>
    <dept>
    <name>productiong</name>
    <location>USA</location>
    <dept>
    I have written XMl SAX parser to load this file into DB -
    import org.xml.sax.helpers.DefaultHandler;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.XMLReader;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.Attributes;
    import java.io.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    import oracle.jdbc.pool.OracleDataSource;
    import java.util.*;
    public class test extends DefaultHandler
    String thisElement="";
    String table_name="";
    String table_name_2="";
    String sql="";
    String value_clause="";
    StringBuffer value_clauseBuffer;
    String Insert_sql="";
    int flag;
    String columnNames="";
    String questionmarks="";
    static String conStr = "jdbc:oracle:thin:@abcd1234:1521:dss501";
    static Connection conn;
    String arrayValues[] = new String[30];
    int j = 0;
    int emptyElementFlag = 0;
    public SurveyReader() throws SQLException, FileNotFoundException, IOException{
    DBConnect("username", "password");
    public static void DBConnect(String username, String password)
    throws SQLException, FileNotFoundException, IOException {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(conStr, username, password);
    conn.setAutoCommit(true);
    public void startElement(String namespaceURI, String localName,
    String qName, Attributes atts) throws SAXException {
    thisElement = qName;
    if (thisElement!=table_name){
    columnNames = columnNames + ", " + qName;
    questionmarks = questionmarks +", " + "?";
    emptyElementFlag =0;
    public void characters(char[] ch, int start, int length)
    throws SAXException {
    if (thisElement !="root"){     
    if ((length == 0) && (thisElement !="") ){
    table_name = thisElement;
    sql = " Insert into "+ table_name +"(";
    value_clause="";
    value_clauseBuffer =null;
    columnNames = "";
    questionmarks ="";
    j =0;
    if ((length != 0) && (thisElement!="") && (thisElement!=table_name)){
    emptyElementFlag = 1;
    String s = new String(ch, start, length);
    String newString = s.replaceAll("'", "''");
    // String newString = s;
    if (value_clauseBuffer== null){
    value_clauseBuffer = new StringBuffer(newString);
    else{
    value_clauseBuffer.append(newString);
    public void endElement(String namespaceURI, String localName, String qName)
    throws SAXException {
    if (thisElement !="root"){
    if ((!(value_clauseBuffer == null))||((emptyElementFlag ==0) && (qName !=table_name))) {
    try{
    //value_clauseBuffer.append("', '");
    if (value_clauseBuffer == null){
    arrayValues[j]="";
    else{
    arrayValues[j]=""+value_clauseBuffer;
    j = j+1;
    value_clauseBuffer = null;
    emptyElementFlag =0;
    }catch(Exception e){
    System.err.println(e);
    System.exit(2);
    if (qName == table_name){
    if (!(value_clauseBuffer == null)){
    value_clause = "'"+value_clauseBuffer;
    columnNames =columnNames.substring(1, columnNames.length());
    int paramNumber = j;
    questionmarks =questionmarks.substring(1, questionmarks.length());
    sql = sql + columnNames + " ) values (" + questionmarks +"); ";
    Insert_sql=Insert_sql + sql;
    sql = "Begin "+sql + " End; ";
         try{
         PreparedStatement pstat = conn.prepareStatement(sql);
    for (int i=0; i<=j-1; i++ ){
    int k = i+1;
    pstat.setObject(k, arrayValues);
         ResultSet rset = pstat.executeQuery();
         rset.close();
         pstat.close();
    catch (Exception e) {
    System.err.println(e);
    System.out.print("sql " + sql);
    System.exit(1);
    table_name_2 = table_name;
    thisElement = "";
    public static void main (String args[]) {
    XMLReader xmlReader = null;
    System.out.println("Time " + new java.util.Date());
    try {
    SAXParserFactory spfactory = SAXParserFactory.newInstance();
    spfactory.setValidating(false);
    SAXParser saxParser = spfactory.newSAXParser();
    xmlReader = saxParser.getXMLReader();
    xmlReader.setContentHandler(new SurveyReader());
    xmlReader.setErrorHandler(new SurveyReader());
    InputSource source = new InputSource("short.xml");
    xmlReader.parse(source);
    conn.close();
    } catch (Exception e) {
    System.err.println(e);
    System.exit(1);
    This parser takes 2 hours to laod file of size around 8MB.
    ANy suggestions on improving performance of the parser.
    ANy other approach I should be taking to load this file into DB.
    We are using ORacle 9i DB with Character set UTF 8.
    Thanks!

    String buf = (new String(ch, start, length)).trim();
    if (thisElement != "root"){   
    if ((buf.length() == 0) && (thisElement !="") ){
    It run ok!
    Thanks 58871!
    Now, i want to export oracle table to xml file like :
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <emp>
    <ename>aaa</ename>
    <sal>3000</sal>
    </emp>
    <emp>
    <ename>bbb</ename>
    <sal>5000</sal>
    </emp>
    </root>
    Can SAX export to xml format?
    Pham Thanh Tung

  • SAX Parser for Oracle 8.1.5

    I need SAX parser - i want load this class into DB. Any ideas?
    Adam

    Have i possibilities to using some javatypes in oracle java stored procedure if this class is not loaded into db?
    Cause i would like to create a java stored procedure to parse and insert some data from xml. I was thinking to pass xml file name as a parameter to my java procedure.
    I must use Oracle 8.1.5 with jdk 1.1.7, and the best parser for me is SAX.
    Please help.
    Have i possobilities to use class inside oracle, which are placed outside oracle?
    Something like classpath, where can i modify value (but classpath inside oracle)?

  • SAX support for XML 1.1

    Hi again
    I was searching for a method like setVersion(1.1) on the SAX parser, but I couldn't find any.
    Does anyone know if SAX supports 1.1, and if so then how? Or did I not find it because it doesn't exist..?

    Actually, the SAX and StAX parsers in JAXP 1.4 support XML 1.1.Well, that's interesting to know. I was under the impression that XML 1.1 had been released and completely ignored by users of XML, since I hadn't read a single thing about it for about two years.
    And I must say this idea of people from Sun who actually know what the hell they are talking about coming here and answering questions is a considerable improvement.

  • SAX parser for PL/SQL

    For a long time on technet the
    PL/SQL parser release notes have
    said that they will be supporting
    SAX in a future release. Is there
    any idea of when this support may
    materialize? Or is Java the only
    option for a parser in the db for
    the near future that can handle large
    documents?
    null

    What would you want to use as the implementation of the SAX2 ContentHandler interface in PL/SQL? Stored procedure-based callbacks? Just curious how you would envision this working. Your input is valuable to our future thinking in this area. Most teams using PL/SQL that want to use SAX have written Java Stored Procedures that use SAX internally inside the stored procedure (written in Java) but are not doing the SAX parsing with PL/SQL-based callbacks.

  • PL/SQL Parser for XML

    When production version of Oracle XML Parser for PL/SQL is
    available?
    and what are other XML utilities to be available for PL/SQL?
    null

    Do you have more precison about the date of the production
    version of Oracle XML Parser for PL/SQL?
    Oracle XML Team wrote:
    : We have not yet announced a production date for the PL/SQL
    : version as this just went beta and we need to get sufficient
    : feedback. Have you tried it? Other PL/SQL XML utilities can
    be
    : found at http://www.oracle.com/xml/plsxml/index.html.
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    : Boris Kolodny (guest) wrote:
    : : When production version of Oracle XML Parser for PL/SQL is
    : : available?
    : : and what are other XML utilities to be available for PL/SQL?
    null

  • Custom parser for XML

    Hello forum,
    I want to put in iFS XML documents with binary content encoded in base64.
    I have created "PrintedDoc" base on "Document" with new attributes: Name, Pages, PeportName.
    I created test XML file and iFS parses it just fine.
    This is an example of XML file:
    <?xml version = '1.0' standalone = 'yes'?>
    <PrintedDoc>
    <Name> Angebot-Nr. 123 vom 12.06.2002.pdf </Name>
    <FolderPath> /printed/Angebote </FolderPath>
    <Pages> 3 </Pages>
    <Format RefType="name"> PDF </Format>
    <ReportName> Angebot </ReportName>
    <Content>AABC-+.....AABCD</Content>
    </PrintedDoc>
    Now I want to decode content back into binary format and store binary data. I have written java class for decoding. I will write a parser that decodes base64 content into binary data.
    My question: How I can register my parser for that xml document? I read about including namespace into document and registering custom XML parser, but this will give me the whole xml document as incoming data.
    I would appreciate if you share your experience or give some hints.
    TIA
    Alexandre

    Hi again,
    I'm trying to write XML pareser implementing XmlParserInterface. I have implemented parse methods and used IfsXmlParser.CreateDOM to get parsed XMLDocument.
    As far as I know, my xml parser should be instaneiated by IfsXmlParser, which in turn calls one of parse methods. The problem is that XmlParserInterface doesn't contain constructors to implement. For example, interface Parser has constructor with argument of type LibrarySession.
    How I can get current LibrarySession from my XML parser? Should I implement both interfaces Parser and XmlParserInterface?
    Thanks for any help,
    Alexandre.
    PS: are Java sources of iFS available somewhere? It would be helpful to get knowledge of how the things working. There is no documentation for creating XML parsers. I have only found about writing usual custom parsers in Developer Guide and a little in iFS API. But that is very scant. :(((

  • SAX Parser for Oracle 8.1.5 needed!!! Urgent

    Please help.
    If you know something please send me mail.
    Regards
    Kail

    Would you tell us how your will use SAX parser?

  • Parser for XML as output from DB..

    Hi Guys,
    Can some one tell me a parser which can take a query and gives the output as an XML format. And takes an XML file and puts the data into DB. pl. let me know from where i can download the parser. and if u have any sample code pl give me.
    Any help would be appreciated greatly.
    Thanks in advance.
    Anil([email protected]).

    Thanks alot Bernhard.
    I got it. But now i would like to know, can i specify the XML format to be generated(DTD kind of thing)when we make a query, like the query will be getting the data of two tables say master and child. so for each record of master there can be multiple childs. at that time i dont want the master data come along with all the childs(master data duplication should not be there). let me put like this. In the master tag there can/should be multiple child tags(sub tags). can this be done using the XSU or XDK ? In the same way can we insert data into two tables at a time. its like we will be taking the data from two tables do some operations reduce some data and then insert into two tables again. can this be achieved with xml file. And i would like to know how to generate one xml for one master record(including its child records, going to be join or sub query etc..) Am i clear on to my question ? If u have any sample data on this could u give me. once again thanks alot for the url.
    Any help would be appreciated greatly.
    Thanks in advance.
    Anil([email protected]).

  • Parser for XML

    Hi you all,
    I would just like to hear from you, what parser do you usually use to work with XML.
    JAXP or JDOM.
    THere so many choices...
    Many Thanks,
    MeTitus

    `hi
    DOM is mainly used if we have to build or alter the xml docs and sax if we have to only read the xml docs
    DOM is mainly prefered in the real world
    hope this helps

  • AGAIN - Needed SAX parser for java on Oracle 8.1.5

    like in subject.
    I load succesful sax2, but i need load more useful parser like from oracle or ibm.
    But when i try i get a lot of errors like ORA-29534 (NullPointerOperation).
    Kail

    Only XML Parser v2 release 2.0.2.7 from Oracle works in 8.1.5, and this release does not support SAX2 unfortunately.

  • PLSQL parser for XML

    What is wrong with this?
    declare
    n xmlparser.DOMNode;
    n1 xmlparser.DOMNode;
    n2 xmlparser.DOMNode;
    e xmlparser.DOMElement;
    begin
    e := xmlparser.createElement (document,'TEST_ELEMENT');
    n1 := xmlparser.makeNode(e);
    n2 := xmlparser.appendChild(n,xmlparser.makeNode(e));
    creates a empty node
    <Location>
    <Country>US
    <TEST_ELEMENT/>
    </Country>
    </Location>
    Question : How can I create a Text Node under <TEST_ELEMENT>,
    example
    <TEST_ELEMENT>Test element comment node
    </TEST_ELEMENT>
    Thanks for your help.
    null

    sk (guest) wrote:
    : What is wrong with this?
    : declare
    : n xmlparser.DOMNode;
    : n1 xmlparser.DOMNode;
    : n2 xmlparser.DOMNode;
    : e xmlparser.DOMElement;
    : begin
    : e := xmlparser.createElement (document,'TEST_ELEMENT');
    : n1 := xmlparser.makeNode(e);
    : n2 := xmlparser.appendChild(n,xmlparser.makeNode(e));
    : creates a empty node
    : <Location>
    : <Country>US
    : <TEST_ELEMENT/>
    : </Country>
    : </Location>
    : Question : How can I create a Text Node under <TEST_ELEMENT>,
    : example
    : <TEST_ELEMENT>Test element comment node
    : </TEST_ELEMENT>
    : Thanks for your help.
    Use the createTextNode method to create a new text node. Then
    convert the DOMElement to a DOMNode using makeNode. Now, you can
    use appendChild to append the text node to the DOMElement.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • Xml sax parser

    Hi all,
    I am newbie to xml. I am using SAX parser for parsing xml documents. I have to write a code which parses all types of xsd files(including which can contain inline , referenced or both). Can anyone help / guide me how to code a generic xsd parser??
    Thanks in advance,

    An XSD file is an XML file, so you can parse it using sax.
    See :
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/2a_echo.html
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/work/Echo02.java
    See also:
    http://www.oracle.com/technology/tech/xml/xdk/doc/production/java/doc/java/javadoc/oracle/xml/parser/schema/XMLSchema.html#getXMLSchemaNodeTable

  • SAX, incor. data for XML element, XML 1.1 doc (1.0 ok) in JRE 6 (JRE 5 ok)

    Hello,
    for some reason, the test case below fails when driven with Java 6. Looks like, when long string data is stored in a XML element, DocumentHandler's characters() method will be provided with incorrect data.
    With XML 1.0, parsing works fine in all my tests, Apache Xerces, JRE 5, JRE 6.
    With XML 1.1., parsing works fine with Apache Xerces, JRE5 but not with JRE6.
    I've checked it with latest JRE 6 update 4.
    Anyone else xperiencing such problems with XML1.1 parsing when using JAXP bundled with Java 6?
    I've tried to file a bug at bugdatabase, but for some reason I got no response for my issue - so I'm trying the forum now ;-)
    Thanx for comments
    Merten
    import java.io.StringReader;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import junit.framework.TestCase;
    import junit.framework.TestResult;
    import junit.framework.TestSuite;
    /** snippet to demonstrate problem in SAXParser */
    public class ProblemWithSAXParser extends TestCase
    public static void main(String[] args)
    TestResult result=junit.textui.TestRunner.run(suite());
    System.exit(result.wasSuccessful() ? 0 : 1);
    private static junit.framework.Test suite()
    final TestSuite ts=new TestSuite();
    ts.addTestSuite(ProblemWithSAXParser.class);
    return (ts);
    /** small DocumentHandler, just waiting for one and only XML element <c></c> */
    class MySAXDocumentHandler extends DefaultHandler
    boolean listening=false;
    public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
    throws SAXException
    System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
    if("c".equals(qName))
    listening=true;
    public void endElement(final String uri, final String localName, final String qName) throws SAXException
    System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
    if("c".equals(qName))
    listening=false;
    public void characters(final char ch[], final int start, final int length) throws SAXException
    if(listening)
    final String str=new String(ch, start, length);
    System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
    + str);
    sb.append(str);
    private final StringBuffer sb=new StringBuffer();
    /** return what I got for XML element <c></c> */
    public String toString()
    return (sb.toString());
    /** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
    * content in the XML element */
    public void testWithSunAndApache() throws Exception
    // test XML element content for <c> element
    final StringBuffer plain_str=new StringBuffer("");
    for(int i=0; i < 500; i++)
    plain_str.append("0123456789 This is some text ").append(i).append(". ");
    final String xml_orig=plain_str.toString();
    // SAX parsers, one Sun, one (original) Apache Xerces
    // accept that Apache Xerces is not in path ...
    final String prop_name="javax.xml.parsers.SAXParserFactory";
    final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
    final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
    System.setProperty(prop_name, prop_val_sun);
    final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
    System.out.println("SaxParser Sun= " + sax_sun);
    assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
    System.setProperty(prop_name, prop_val_apache);
    SAXParser sax_apache;
    try
    sax_apache=SAXParserFactory.newInstance().newSAXParser();
    catch(final Throwable t)
    System.err.println("no Apache Xerces in path? " + t);
    sax_apache=null;
    System.out.println("SaxParser Apache= " + sax_apache);
    assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
    // i==0: XML 1.0, i==1: XML 1.1
    for(int i=0; i <= 1; i++)
    assert i == 0 || i == 1;
    final String xml_version=(i == 0 ? "1.0" : "1.1");
    final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
    sb.append(xml_orig);
    sb.append("</c>");
    final String xml=sb.toString();
    // parse it!
    final StringReader string_reader_sun, string_reader_apache;
    string_reader_sun=new StringReader(xml);
    final InputSource input_source_sun=new InputSource(string_reader_sun);
    string_reader_apache=new StringReader(xml);
    final InputSource input_source_apache=new InputSource(string_reader_apache);
    final MySAXDocumentHandler my_handler_sun, my_handler_apache;
    my_handler_sun=new MySAXDocumentHandler();
    my_handler_apache=new MySAXDocumentHandler();
    sax_sun.parse(input_source_sun, my_handler_sun);
    if(sax_apache!=null)
    sax_apache.parse(input_source_apache, my_handler_apache);
    final String xml_sun=my_handler_sun.toString();
    final String xml_apache=my_handler_apache.toString();
    assertNotNull(xml_sun);
    assertNotNull(xml_apache);
    System.out.println("xml version " + xml_version);
    System.out.println("xml " + xml);
    System.out.println("xml_orig " + xml_orig);
    System.out.println("xml_sun " + xml_sun);
    System.out.println("xml_apache " + xml_apache);
    // test the data returned from DocumentHandler
    if(sax_apache!=null)
    assertEquals(xml_orig, xml_apache);
    assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
    assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
    }

    thanx, DrClap, haven't seen the "code" button for some reason, code is attached again
    The output of my test is like this for JRE6 (truncated)
    xml_sun 456789 This is is some text 0. 0123456789 This is some text 1.
    xml_apache 0123456789 This is some text 0. 0123456789 This is some text 1.
    Notice, xml_sun not only starts wrong ("0123" missing) - for some reason, the text there is not "This is some text" but "This is is some text" - very interesting in a way. I guess there's an issue with repeated text chunks ...
    So, the data in my XML element is kind of changed, the length of the string is okay but the characters are "misplaced" or so :-) I thought about a problem with StringBuffer first, but the StringBuffer works fine for Apache ... so I really think there's an issue with JRE 6's parser for XML 1.1
    Merten
    import java.io.StringReader;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import junit.framework.TestCase;
    import junit.framework.TestResult;
    import junit.framework.TestSuite;
    /** snippet to demonstrate problem in SAXParser */
    public class ProblemWithSAXParser extends TestCase
    public static void main(String[] args)
      TestResult result=junit.textui.TestRunner.run(suite());
      System.exit(result.wasSuccessful() ? 0 : 1);
    private static junit.framework.Test suite()
      final TestSuite ts=new TestSuite();
      ts.addTestSuite(ProblemWithSAXParser.class);
      return (ts);
    /** small DocumentHandler, just waiting for one and only XML element <c></c> */
    class MySAXDocumentHandler extends DefaultHandler
      boolean listening=false;
      public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
        throws SAXException
       System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
       if("c".equals(qName))
        listening=true;
      public void endElement(final String uri, final String localName, final String qName) throws SAXException
       System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
       if("c".equals(qName))
        listening=false;
      public void characters(final char ch[], final int start, final int length) throws SAXException
       if(listening)
        final String str=new String(ch, start, length);
        System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
          + str);
        sb.append(str);
      private final StringBuffer sb=new StringBuffer();
      /** return what I got for XML element <c></c> */
      public String toString()
       return (sb.toString());
    /** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
      * content in the XML element */
    public void testWithSunAndApache() throws Exception
      // test XML element content for <c> element
      final StringBuffer plain_str=new StringBuffer("");
      for(int i=0; i < 500; i++)
       plain_str.append("0123456789 This is some text ").append(i).append(". ");
      final String xml_orig=plain_str.toString();
      // SAX parsers, one Sun, one (original) Apache Xerces
      // accept that Apache Xerces is not in path ...
      final String prop_name="javax.xml.parsers.SAXParserFactory";
      final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
      final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
      System.setProperty(prop_name, prop_val_sun);
      final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
      System.out.println("SaxParser Sun= " + sax_sun);
      assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
      System.setProperty(prop_name, prop_val_apache);
      SAXParser sax_apache;
      try
       sax_apache=SAXParserFactory.newInstance().newSAXParser();
      catch(final Throwable t)
       System.err.println("no Apache Xerces in path? " + t);
       sax_apache=null;
      System.out.println("SaxParser Apache= " + sax_apache);
      assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
      // i==0: XML 1.0, i==1: XML 1.1
      for(int i=0; i <= 1; i++)
       assert i == 0 || i == 1;
       final String xml_version=(i == 0 ? "1.0" : "1.1");
       final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
       sb.append(xml_orig);
       sb.append("</c>");
       final String xml=sb.toString();
       // parse it!
       final StringReader string_reader_sun, string_reader_apache;
       string_reader_sun=new StringReader(xml);
       final InputSource input_source_sun=new InputSource(string_reader_sun);
       string_reader_apache=new StringReader(xml);
       final InputSource input_source_apache=new InputSource(string_reader_apache);
       final MySAXDocumentHandler my_handler_sun, my_handler_apache;
       my_handler_sun=new MySAXDocumentHandler();
       my_handler_apache=new MySAXDocumentHandler();
       sax_sun.parse(input_source_sun, my_handler_sun);
       if(sax_apache!=null)
        sax_apache.parse(input_source_apache, my_handler_apache);
       final String xml_sun=my_handler_sun.toString();
       final String xml_apache=my_handler_apache.toString();
       assertNotNull(xml_sun);
       assertNotNull(xml_apache);
       System.out.println("xml version " + xml_version);
       System.out.println("xml        " + xml);
       System.out.println("xml_orig   " + xml_orig);
       System.out.println("xml_sun    " + xml_sun);
       System.out.println("xml_apache " + xml_apache);
       // test the data returned from DocumentHandler
       if(sax_apache!=null)
        assertEquals(xml_orig, xml_apache);
       assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
       assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
    }

Maybe you are looking for

  • Xml publisher graph is not displaying

    Hi All, I have created xml report which is having graph .It display through oracle apps(conc pgrm ) properly in test instance but after moving to production graph is not displaying .for that i have checked Xserver setup also everything is working fin

  • Sharing iPhoto6 between users on one computer

    I would like multiple users on a single iMac to have access to all the pictures in iPhoto. And when I import new photos under one user, I want everyone to see them. I've read the answers to previous posts on this topic, but hoped that in the last 6 m

  • How to update photoshop files in DW8

    I had purchased a template from dreamtemplates.com #0064 to save me some time and get my site up sooner. I do not have a url yet to show you all. The template came with the images prepared in photoshop included in a psd file along with the images and

  • Internal server error http 500, open document

    I have a webintelligence cluster installation. IIS6.5 sp3W2003 sp1 When I open a report, I have an internal server error http error 500. In the log I see something like : "The specified module could not be found".  But I don't now which module it is.

  • Heeellp pleeease "bbm group" not receiving messages i posssttt ...

    okk a couple friends and i have a group set on bbm... we've had this for over a year.. about 3 days ago everyone in the group just stop seing my messages or picture post... i did a batt pull, i even went to the measures of backing up my bbm deleting