What is a DomParser/SaxParser?

Hi all,
I need to parse a couple of html files to make some changes to the tags. I was just going to use a simple bufferedReader/BufferedWriter with a sub string replacement method....but somebody suggested the use of a parser. Specifically a SaxParser. Whadayallthink? And for that matter, what is a SaxParser and how does it differ from a saxParser?
Regards,
Mat

SAX stands for Simple API for XML. Apparently, it is event-driven and is used for accessing XML documents and extracting information from them. However, it does not support manipulation of the internal structure of the documents it reads.
DOM stands for Document Object Model, and it specifies how HTML and XML documents can be represented as objects. It differs from SAX in that it can manipulate the internal structure of the documents it reads, but I've read that any changes made to the document are only stored in memory and don't affect the file directly. You'd have to have your program do that.
I have not used either of these or XML yet, but I am learning about them currently.
HTH
Jeff

Similar Messages

  • Problem with SAX parser - entity must finish with a semi-colon

    Hi,
    I'm pretty new to the complexities of using SAXParserFactory and its cousins of XMLReaderAdapter, HTMLBuilder, HTMLDocument, entity resolvers and the like, so wondered if perhaps someone could give me a hand with this problem.
    In a nutshell, my code is really nothing more than a glorified HTML parser - a web page editor, if you like. I read in an HTML file (only one that my software has created in the first place), parse it, then produce a Swing representation of the various tags I've parsed from the page and display this on a canvas. So, for instance, I would convert a simple <TABLE> of three rows and one column, via an HTMLTableElement, into a Swing JPanel containing three JLabels, suitably laid out.
    I then allow the user to amend the values of the various HTML attributes, and I then write the HTML representation back to the web page.
    It works reasonably well, albeit a bit heavy on resources. Here's a summary of the code for parsing an HTML file:
          htmlBuilder = new HTMLBuilder();
    parserFactory = SAXParserFactory.newInstance();
    parserFactory.setValidating(false);
    parserFactory.setNamespaceAware(true);
    FileInputStream fileInputStream = new FileInputStream(htmlFile);
    InputSource inputSource = new InputSource(fileInputStream);
    DoctypeChangerStream changer = new DoctypeChangerStream(inputSource.getByteStream());
    changer.setGenerator(
       new DoctypeGenerator()
          public Doctype generate(Doctype old)
             return new DoctypeImpl
             old.getRootElement(),
                              old.getPublicId(),
                              old.getSystemId(),
             old.getInternalSubset()
          resolver = new TSLLocalEntityResolver("-//W3C//DTD XHTML 1.0 Transitional//EN", "xhtml1-transitional.dtd");
          readerAdapter = new XMLReaderAdapter(parserFactory.newSAXParser().getXMLReader());
          readerAdapter.setDocumentHandler(htmlBuilder);
          readerAdapter.setEntityResolver(resolver);
          readerAdapter.parse(inputSource);
          htmlDocument = htmlBuilder.getHTMLDocument();
          htmlBody = (HTMLBodyElement)htmlDocument.getBody();
          traversal = (DocumentTraversal)htmlDocument;
          walker = traversal.createTreeWalker(htmlBody,NodeFilter.SHOW_ELEMENT, null, true);
          rootNode = new DefaultMutableTreeNode(new WidgetTreeRootNode(htmlFile));
          createNodes(walker); However, I'm having a problem parsing a piece of HTML for a streaming video widget. The key part of this HTML is as follows:
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                  id="client"
            width="100%"
            height="100%"
                  codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
                  <param name="movie" value="client.swf?user=lkcl&stream=stream2&streamtype=live&server=rtmp://192.168.250.206/oflaDemo" />
             etc....You will see that the <param> tag in the HTML has a value attribute which is a URL plus three URL parameters - looks absolutely standard, and in fact works absolutely correctly in a browser. However, when my readerAdapter.parse() method gets to this point, it throws an exception saying that there should be a semi-colon after the entity 'stream'. I can see whats happening - basically the SAXParser thinks that the ampersand marks the start of a new entity. When it finds '&stream' it expects it to finish with a semi-colon (e.g. much like and other such HTML characters). The only way I can get the parser past this point is to encode all the relevant ampersands to %26 -- but then the web page stops working ! Aaargh....
    Can someone explain what my options are for getting around this problem ? Some property I can set on the parser ? A different DTD ? Not to use SAX at all ? Override the parser's exception handler ? A completely different approach ?!
    Could you provide a simple example to explain what you mean ?
    Thanks in anticipation !

    You probably don't have the ampersands in your "value" attribute escaped properly. It should look like this:
    value="client.swf?user=lkcl&stream=...{code}
    Most HTML processors (i.e. browsers) will overlook that omission, because almost nobody does it right when they are generating HTML by hand, but XML processors won't.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Getting SAXParser to stop what it's doing

    I have a simple question: I'm creating a thread that uses a SAXParser to parse through a very large file. The full parse takes about ten hours. I'm doing this from within a Swing application. When the user hits the "cancel" button, I would like to be able to stop SAXParser from doing its parsing. I can't find anything in the API that looks like it would let me send a message to the parser telling it to quit.
    There must be a way to do this. SAXParser is what you use when you're parsing a file which is too big to fit in memory, so it will often be used in processing very large files.
    Any suggestions?
    Thanks

    i'd try
    class MyContentHandler extends DefaultHandler
            Object lock;
            boolean stop = false;
            public void stopMe()
                   synchronized(lock)
                         stop = true;
            public void startElement(String ns, String ln, String qn, Attributes a)
                    synchronized(lock)
                             if (stop)
                                      throw new SAXParserException("User Interrupted");
                    ..... //whatever you did before
          // other contenthandler methods as before
    }

  • Help! Failed to validate XML using setDocType on DOMParser

    Hi all:
    I am trying to use an existing DTD to parse
    an XML file, and I am using the setDocType
    method on the DOM parser to do this:
    DOMParser parser = new DOMParser();
    parser.setValidationMode(true);
    parser.setDoctype(dtd);
    parser.parse(reader); // reader contains XML stream
    But it does not seems to validate the XML
    document correctly. For example, if I have
    an element Graph defined as:
    <!ELEMENT Graph (Background,Title) >
    In my XML, if I define Title element to come before the Background element, it does not give me any error:
    <?xml version="1.0" encoding="UTF-8" ?>
    <Graph>
    <Title>.....
    <Background>....
    </Graph>
    It does catches other errors like undeclared attributes, however.
    Anyone knows what might have cause this?
    Thanks,
    Chadwick.

    You can try to set the following feature to 'true' for your SAXParser:
    http://apache.org/xml/features/continue-after-fatal-error
    At least Xerces supports this feature.

  • Oracle.xml.parser.v2.SAXParser error

    I'm reposting this error that I recently received one more time before removing the XML transforms from my Java projects and doing them in .NET.
    Code that was working fine suddenly getting a transform error using JDeveloper.
    Get the following:
    javax.servlet.ServletException: javax.xml.transform.TransformerConfigurationException: XML-22000: (Fatal Error) Error while parsing XSL file (weblogic.xml.jaxp.RegistryXMLReader cannot be cast to oracle.xml.parser.v2.SAXParser).
         at weblogic.servlet.jsp.PageContextImpl.handlePageException(PageContextImpl.java:417)
    Seems that
    <!--
    <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <h1>Project Weekly Hours Worked</h1>
    <table>
    <c:import url="HoursWorked.xml" var="xmlHoursWorked" charEncoding="windows-1252"/>
    <c:import url="./HoursWorked3.xsl" var="xslt" charEncoding="windows-1252"/>
    <x:transform xml="${xmlHoursWorked}" xslt="${xslt}" />
    </table>
    -->
    will not transform XML to HTML via XSL in JSP anymore.
    If I run the XSL i get the HTML results I expected in an HTML test page.
    So I know the XML and XSL is sound.
    XSL and DOM parsing in Java/Oracle was a major pain in the ass in the first place and now this.
    Well I've spent hours going through Oralce/Java documentation on XML, DOM and XSL transforms.
    All that time spent and still so unstable. I don't think I was ever able to really get what I wanted
    which was to transform my XML document to HTML, update via JSP and have the XML document
    be updated and ready to view in a summary page. The XML document changes were never really
    available unless I closed the app and restarted. So all in all a failure of capabilities compared to my
    use of XML in .NET.
    So........
    Me thinks it will be a good idea to take out the transforms and have my JSP use a script to invoke a
    method in a class that extracts it from a message. Just have PL/SQL interface with XML and do the
    transform or serialize thing there.
    I don't want to give up on XML but I'm tired of trying to jam a square peg into a round hole
    with Java and JDeveloper.
    Brian

    We don't support file references ("cv1_0.dtd"). Only url type references
    are supported, of the form:
    @ <!DOCTYPE cv1 SYSTEM "http://www.oracle.com/public/cv1_0.dtd>
    Note that the url should be accessible to the world without the need to authenticate.
    you could put your dtd in the "public" area in your iFS system.
    Thanks,
    Sirisha
    null

  • What's wrong with my transform? Please help!

    I have a program which is trying to transform some XML data into HTML. I'm using DOM, and am selecting a node with getElementByID(). This Node is then passed to the transformer, and the data it contains should be output with HTML markup. However, the transform outputs the XML data, but with none of the HTML formatting contained in the XSL! I have a very simple program here to demonstrate what I mean
    Here's the XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <people xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="file:/C:/test.xsd">
        <person employee_no="e124">
            <name>Mary Jane</name>
            <address>420 High St</address>
            <phone>555-0123</phone>
        </person>
        <person employee_no="e123">
            <name>John Smith</name>
            <address>123 Boulevard Rd</address>
            <phone>555-0918</phone>
        </person>
    </people>Here's the XSL:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:output method="html"/>
            <xsl:template match="/">
                <html>
                        <p>Name: <xsl:value-of select="person/name"/><br/>Address: <xsl:value-of select="person/address"/><br/>Phone: <xsl:value-of select="person/phone"/></p>
                </html>
            </xsl:template>
    </xsl:stylesheet>And here's the code that is giving me problems - it selects a node using getElementByID and tries to apply that node to the transform.
    package xsltest;
    import java.io.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.dom.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import org.w3c.dom.*;
    import org.apache.xerces.parsers.*;
    public class XSLTest {
      String xslPath = "C:\\test.xsl";
      String xmlPath = "C:\\test.xml";
      String xsdPath = "C:\\test.xsd";
      String outPath = "c:\\XSLTest.html";
      org.w3c.dom.Document xmlDoc;
      public XSLTest() {
        /*Load the XML file, with Schema validation turned on*/
        try {
            DOMParser parser = new DOMParser();
            parser.setFeature("http://xml.org/sax/features/validation", true);
            parser.setFeature("http://apache.org/xml/features/validation/schema", true);
            parser.parse(xmlPath);
            xmlDoc = parser.getDocument();
        catch (Exception e) { e.printStackTrace(); }
        File outFile = new File(outPath);
        File xslFile = new File(xslPath);
        StreamResult result = new StreamResult(outFile);
        StreamSource xsltSource = new StreamSource(xslFile);
        /*Select the element that we wish to output HTML for*/
        Node node = xmlDoc.getElementById("e124");
        DOMSource xmlSource = new DOMSource(node);
        try {
          javax.xml.transform.TransformerFactory tff = TransformerFactory.newInstance();
          Transformer transformer = tff.newTransformer(xsltSource);
          transformer.transform(xmlSource, result);
        catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        XSLTest test = new XSLTest();
    }When I do this, I get an empty document containing only:
    Mary Jane 420 High St 555-0123
    What am i doing wrong here?

    Hello,
    try this:
    change the line
    Node node = xmlDoc.getElementById("e124");
    with this content:
    Node node = null;
    org.w3c.dom.NodeList theList = xmlDoc.getElementsByTagName("person");
    for (int i = 0; i < theList.getLength(); i++)
    if ( ( (org.w3c.dom.Element) theList.item(i)).getAttribute("employee_no").equalsIgnoreCase("e124"))
    node=theList.item(i);
    The problem is, that the method "getElementByID" delivers "null" in your code.

  • How to set SAXParser at command-line interface to create a large XML file

    Hi,
    I am trying to create a large XML file (more than 50 MB) by selecting from Oracle database but failed because of "out of memory" error. According to "Oracle XML Developer Guide", we should use SAXParser to parsing a large XML file. But there is no example to show how to set SAXParser at command-line
    Following is what I use to get xml files. It works only when the file is small.
    java OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    When I set SAXParser at the way below,
    java oracle.xml.parser.v2.SAXParser OracleXML getXML -DateFormat -withDTD -rowsetTag PO_HDR -conn
    "jdbc:oracle:oci8:@server_name" -user "ID/password" "select * from table_name"
    it failed with the error message: "In class oracle.xml.parser.v2.SAXParser: void main(String argv[]) is not defined"
    Does anyone know how to solve the problem? I'll be appreciated very much for your help.
    Yi

    here are my ideas.
    register the xml schema.
    using xmldom, generate the desired xml output and return as xmltype.
    then you can use something like this to check.
    declare
    xmldoc xmltype ;
    begin
       -- populate xmldoc from you xmldom function
       -- validate against XML schema
       xmldoc.isSchemaValid(schema_url, root_element);
       if xmldoc.isSchemaValid = 1 then
            --valid schema
       else
            --invalid
       end if;
    end

  • ArrayIndexOutOfBoundsException during DOMParser.parse(...) operation

    Please provide assistance with clarifying any limitations of the DOMParser.parse() operations. Please let me know if there is an alternative approach to what I am doing below. The details of my situation follow:
    I am using Visual Cafe 3 with the Oracle XML parser 2.0.2.6 to parse an XML string using the DOMParser parse(Reader), parse(InputSource), parse(InputStream) operation in order to retrieve a DOMDocument object.
    I have taken several approaches all of which result in the following exception:
    "java.lang.ArrayIndexOutOfBoundsException: 16388"
    This error appears to be raised by XMLReader:
    oracle\xml\parser\v2\XMLReader(1411)... The java source is unavailable to debug the code.
    I have also changed the XML string to a simple innocuous string. But I still get the same message. The literal string value is as follows: "<?xml version="1.0"?><EMPLIST><EMP><ENAME>MARTIN</ENAME></EMP><EMP><ENAME>SCOTT</ENAME></EMP></EMPLIST>"
    The code fragments I have used to perform the parse() operations are given below:
    //Reader approach
    StringReader xmlReader = new StringReader( inXMLString );
    parser.parse( xmlReader );
    // InputSource approach
    InputSource source = new InputSource( xmlReader );
    parser.parse( source );
    // InputStream approach
    ByteArrayInputStream byteStream = new ByteArrayInputStream( inXMLString.getBytes() );
    parser.parse( byteStream );
    Any assistance would be greatly appreciated.
    null

    Please provide assistance with clarifying any limitations of the DOMParser.parse() operations. Please let me know if there is an alternative approach to what I am doing below. The details of my situation follow:
    I am using Visual Cafe 3 with the Oracle XML parser 2.0.2.6 to parse an XML string using the DOMParser parse(Reader), parse(InputSource), parse(InputStream) operation in order to retrieve a DOMDocument object.
    I have taken several approaches all of which result in the following exception:
    "java.lang.ArrayIndexOutOfBoundsException: 16388"
    This error appears to be raised by XMLReader:
    oracle\xml\parser\v2\XMLReader(1411)... The java source is unavailable to debug the code.
    I have also changed the XML string to a simple innocuous string. But I still get the same message. The literal string value is as follows: "<?xml version="1.0"?><EMPLIST><EMP><ENAME>MARTIN</ENAME></EMP><EMP><ENAME>SCOTT</ENAME></EMP></EMPLIST>"
    The code fragments I have used to perform the parse() operations are given below:
    //Reader approach
    StringReader xmlReader = new StringReader( inXMLString );
    parser.parse( xmlReader );
    // InputSource approach
    InputSource source = new InputSource( xmlReader );
    parser.parse( source );
    // InputStream approach
    ByteArrayInputStream byteStream = new ByteArrayInputStream( inXMLString.getBytes() );
    parser.parse( byteStream );
    Any assistance would be greatly appreciated.
    null

  • Java Stored Procedure SAXParser XML Schema Validation

    Using Oracle XML Developers Kit 10.2.0.2.0 - Production.
    Attempting to validate using XML Schema in a Java stored procedure with the code:
                   if ( schemaDoc == null )
                        // Obtain default connection
                        Connection conn = new OracleDriver().defaultConnection();
                        OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement("SELECT XmlDocObj FROM XmlDoc WHERE XmlDocNbr = 2");
                        OracleResultSet rset = (OracleResultSet)stmt.executeQuery();
                        if ( rset.next() )
                             // get the XMLType
                             XMLType schemaXml = (XMLType)rset.getObject(1);
                             XSDBuilder builder = new XSDBuilder();
                             XMLSchema schemaDoc = (XMLSchema)builder.build(new InputSource(schemaXml.getInputStream()));
                   if ( inst == null )
                        inst = new ValidateCoreRequest();
                   ErrorHandlerImpl handler = inst.getNewErrorHandler();
    SAXParser saxParser = new SAXParser();
    saxParser.setXMLSchema(schemaDoc);
    saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxParser.setErrorHandler(handler);
    saxParser.parse(new InputSource(new StringReader(docStr)));
    if( handler.validationError )
                        errorMsg[0] = handler.saxParseException.getMessage().substring(0, Math.min(199, handler.saxParseException.getMessage().length()));
    Never reports validation errors in the XML. Although the XDK Programmers Guide states "...you can use
    the oracle.xml.parser.schema.XSDBuilder class to build an XML schema and
    then configure the parser to use it by invoking the XMLParser.setXMLSchema()
    method. In this case, the XML parser automatically sets the validation mode to
    SCHEMA_STRICT_VALIDATION and ignores the schemaLocation and
    noNamespaceSchemaLocation attributes." No validation seems to occur. I have tried to set an xsi:noNamespaceSchemaLocation attribute on the root XML node, but this results in URL errors if the URL is not valid or schema build errors if the URL is valid, but does not point to a real location.
    It appears that without a schema location attribute, no schema validation occurs. Using setXMLSchema() with a database source does not seem to cause the schema location attributes to be ignored. At least for Java stored procedures.
    Does XML Schema validation work in the database for externally referenced schemas?
    Thank You,
    Art

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Jan Vissers ([email protected]):
    I have two schemas A and B. A contains a java stored procedure which calls a java stored procedure stored in B. Upon resolving the "A" Java Stored Procedures I get the following error:
    ORA-29545: badly formed class: at offset 3093 of Adapter.TFADPBeschikbaarheid.sendAanvraag expecting a class-oracle.xml.parser.v2.XMLDocument but encountered a class-oracle.xml.parser.v2.XMLDocument.
    ... Question:
    it is expecting something which it has in fact encountered... SO!!!! What is the error.
    Thx,
    Jan<HR></BLOCKQUOTE>
    Try this:
    Edit your XSU installation script located on lib directory of Oracle XSU's distribution:
    Find the line:
    loadjava -r -v -u $USER_PASSWORD xmlparserv2.jar
    Replace by:
    loadjava -r -v -g public -u $USER_PASSWORD xmlparserv2.jar
    And installs your Oracle XSU again.
    Best regards, Marcelo.

  • JDK 1.6 - XML, Xerces and DOMParser - Help?

    Please bear with me while I try to explain this thoroughly....
    I perviously wrote a JSP page using the following:
    Tomcat 5.5.x
    JDK 1.5x
    imports: org.w3c.dom.*,
    org.apache.xerces.parsers.*,
    org.xml.sax.*
    I have since upgraded to:
    Tomcat 6.0.x
    JDK 1.6x
    My JSP will no longer compile as the Xerces.jar file is not in my path.
    The specific error is:
    org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/xerces/parsers/DOMParser
    My use of the DOM (with xerces) is like this:
    org.w3c.dom.Document xmlparams=null;
    DOMParser parser=new DOMParser();
    InputSource is=new InputSource(new StringReader("myParameters.xml"));
    parser.parse(is);
    xmlparams=parser.getDocument();Then:
    Node fpref=xmlparams.getElementsByTagName("FormatPreference").item(0).getFirstChild();etc., etc.
    If I no longer want to use Xerces, what standard distribution libraries can I use instead ?
    Can you provide/link to a few examples?
    Or should I just distribute xerces.jar with my app?
    I'm hoping I don't have to rewrite my code for a different xml parser....
    Edited by: whoit on Jul 21, 2008 12:22 PM

    Never mind - I found the answer.
    I can eliminate xerces.jar by replacing the following code:
    import org.apache.xerces.parsers.*;
    org.w3c.dom.Document xmlDoc;
    DOMParser parser=new DOMParser();
    parser.parse(new File(xFileName));
    xmlDoc=parser.getDocument();with this:
    import javax.xml.parsers.*;
    org.w3c.dom.Document xmlDoc;
    DocumentBuilder parser= DocumentBuilderFactory.newInstance().newDocumentBuilder();
    xmlDoc=parser.parse(new File(xFileName));

  • DOMparser throws IOException when encounters Hungarian Characters

    Hoi!
    I wrote a piece of code that extracts some
    information from an XML document into a vector of Java classes, using the oracle.xml.parser.v2.DOMParser.
    And it worked. Or seemed to work...
    But when I put some articles in the XML file
    in Hungarian, the parser threw IOException.
    If I remplace the Hungarian characters to
    English "equivalents" a -> a etc., it works.
    I don't know. If XML is made up of Unicode characters, what's the problem with it?
    (The hex code of a was E1 in my text editor,
    as I'm using Win NT :(. )
    can I modify the xml prolog somehow?
    I'd rather not write a conversion program
    from a text file to another.
    Any ideas?
    and here's the code:
    DOMParser theParser = new DOMParser();
    XMLStreamToParse = XMLes.class.getResourceAsStream(xmlDocPath);
    theParser.setValidationMode(false);
    try{
    theParser.parse( XMLStreamToParse );
    //this throws IOException
    null

    What are you using as your test client?The test client is WebStone 1.0. WebStone always downloads the whole response, and reports the size of the response in bytes. From this I can see that when the IO exception occurs, webstone is unable to read the whole response, as it reports a smaller size.
    So, I do not think the problem is that the client has prematurely aborted its download. WebStone doesn't work that way. I think something has gone awry on the server side, and this worries me.

  • UTF-8 files with BOM chrashes DOMParser?

    Hi.
    We are storing XML-documents in an 8i databse with UTF-8 encoding (in CLOBS).
    Problem: If the Unicode XML-document contains a BOM the oracle.xml.parser.v2.DOMParser's
    parse()-method throws an exception.
    I get the following output when using the ParseXMLFromURL.java class supplied in JDeveloper 3.2 samples directory:
    Sample output >>>>
    System Output: XML parse error in file http://localhost/UTF-8_With_BOM.xml
    System Output: at line 1, character 1
    System Output: Start of root element expected.
    <<<<<<< Sample output
    If I change the XML-file not to include a BOM the parser works fine.
    (I set/unset the BOM using EmEditor from http://www.emurasoft.com/ if you'd like to try for yourselves).
    To me it looks like DOMParser interprets the BOM at the start of the XML-file as XML-content instead of a Unicode signature.
    IE 5.5 can handle both formats, shouldn't DOMParse also be able to handle that?
    Any ideas how I can get DOMParse to work with UTF-8(BOM) XML-files?
    Regards,
    Jan-Erik
    Sample XML:
    <?xml version="1.0" encoding='UTF-8'?>
    <newsdoc>
    <news>
    <newstitle>
    Document contains no BOM
    </newstitle>
    <introduction>
    See http://www.unicode.org/unicode/faq/utf_bom.html for info on BOM
    </introduction>
    </news>
    </newsdoc>
    null

    I have the same problem when trying to store UTF-8 encoded XML files with BOM marks in iFS version 1.1.9.0.7.
    The database is 8.1.7.1.1 created with UTF-8 charset.
    I have loaded the XDK for PLSQL 9.0.2.0.0A into the database and replaced the original %ORACLE_HOME%\lib\xmlparserv2.jar with the one distributed in this XDK.
    I get the following error message:
    Wed Aug 01 10:10:06 GMT+02:00 2001: \public\CV-Bank\CV_Patrik_Johansson_intDTD_BOM.xml:
    oracle.ifs.common.IfsException: IFS-12608: Error while pre-parsing with the SAXParser: at line (1), column (1): oracle.xml.parser.v2.XMLParseException: Start of root element expected.
    at oracle.ifs.beans.parsers.IfsXmlParser.preParse(IfsXmlParser.java, Compiled Code)
    at java.lang.Exception.<init>(Exception.java, Compiled Code)
    at oracle.ifs.common.IfsException.<init>(IfsException.java, Compiled Code)
    at oracle.ifs.common.IfsException.<init>(IfsException.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.preParse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.getParserName(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.parse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.beans.parsers.IfsXmlParser.parse(IfsXmlParser.java, Compiled Code)
    at oracle.ifs.utils.common.ParserHelper.parseExistingDocument(ParserHelper.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.parseFile(FileProxy.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.cleanupFile(FileProxy.java, Compiled Code)
    at oracle.ifs.protocols.ntfs.server.FileProxy.runFileProxy(Native Method)
    at oracle.ifs.protocols.ntfs.server.FileProxy.run(FileProxy.java, Compiled Code)
    This is a serious problem since we use an XML editor that adds BOM's.
    Regards
    Patrik Johansson

  • Dropped data in SAXParser client xml over http

    Hi all, I need some expert help.
    I have succeeded in getting our server to encode small gif image files using base64, and transmitting the resulting text in XML back to a client using SAXParser via http. The client overrides characters(char[] ch, int start, int length) in the content handler and decodes the text back to bytes, then reconstructs the gif file and displays it in the client GUI.
    Now I've moved on to some extremely large images and am running into problems. The server still appears to encode the image correctly. For this test image the server sends 886 character buffers 200 bytes long and 1 buffer 168 bytes long for a total of 887 buffers and 177368 characters, generated from 133026 bytes.
    My client parses the HttpURLConnection InputStream and parses it using SAXParser. The content handler characters() method handles 887 char[] reads. I would expect the first 886 times for the length argument in characters() to be 200 and the last to be 168, exactly like what the server generated, but there are a few intermittent times when length is less than 200. Some data has been lost.
    Does something need to be flushed on the server side that could be causing this? The server creates a Writer from the HttpURLConnection outputstream and writes to the writer each time a buffer of bytes has been decoded, like so:
    write("<dcm2:image>");
    char[] cdata = Base64.encode(bdata);
    // bdata.length = 150, cdata.length = 200
    write(cdata);
    write("</dcm2:image>");
    Or does the HttpURLConnection inputstream on the client side need to be wrapped in a particular input stream or stream reader? I've tried:
    parser.parse(new InputSource(new BufferedReader(new InputStreamReader(urlconn.getInputStream()))));
    I'm using Apache's Xerces 1.3.0, by the way.

    The cure appears to be to use a raw input stream. Do NOT wrap the input stream in any kind of reader!
    In other words, do this:
    parser.parse(new InputSource(conn.getInputStream()));
    But do NOT do this:
    parser.parse(new InputSource(new InputStreamReader(conn.getInputStream())));

  • Problems with using SAXParser.parse with an InputStream

    Hello:
    I have successfully run the echo01 program from the XML tutorial. I made the following changes to parse the output from a servlet which generates an XML document.
    URL recordedSensor = new URL("http://redbd01:8010/servlet/RecordedSensor?vin=1M000000000000001");
    URLConnection rsConn = recordedSensor.openConnection();
    // Parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse( rsConn.getInputStream(), handler);
    I get the following errors when I try to run the code.
    org.xml.sax.SAXParseException: java.lang.NullPointerException
    at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:524)
    at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
    at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:393)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:191)
    at ServletInterface.main(ServletInterface.java:29)
    I think I have the problem narrowed down to the handlers accessing the class variable out which is a Writer the emit() method uses to output the document. When I replace out.write in emit() with System.out.println() the code works.
    I've tried accessing other class variables in the handler methods with similar results.
    Anybody encountered similar problems? And what is the solution.
    Thanks in advance,
    Gary

    I have the same problem, if you find a solution let me know. I've double checked my objects to make sure their not null, I've checked my constructors in the extended default handler, not really sure where else to look, its such a simple program....

  • Using saxparser in the suite method from junit

    Hi, i have a problem using SAXParser in the suite method of junit.
    My little test class 'myParser' works fine but when I call the method 'doIt' from the 'suite' method from a class that implements TestCase (junit) I get a java.lang.ClassCastException: org.apache.xerces.parsers.StandardParserConfiguration
    in line 7.
    Does anyone have an idea what I made wrong??
    1) public class myParser {
    2)   
    3)   public myParser() {}
    4)   
    5)   public void doIt() {
    6)     try {
    7)       org.xml.sax.XMLReader parser = new org.apache.xerces.parsers.SAXParser();
    8)       parser.parse("anyFile.xml");
    9)     } catch (java.io.IOException IOe) {
    10)       System.out.println(IOe.getMessage());
    11)     } catch (org.xml.sax.SAXException SAXe) {
    12)       System.out.println(SAXe.getMessage());
    13)     }
    14)   }
    15) }

    Hi JPilot,
    I�ve this problem, too.
    greez ZB

Maybe you are looking for

  • Disappointed in CS6 and Adobe in general

    I am more and more disappointed in CS6 and Adobe in general.  I no longer have any respect for Adobe or their products. I can't read the new title editing function in Premiere CS6 (it was fine in CS5). Somebody here said you can make it bigger: No yo

  • I had itunes on my Dell laptop, i downloaded an apple update and now error message 126

    I had itunes on my Dell laptop, i downloaded an apple update and now I get error message widows 126 and error message MSVCR80.dll. Help please.

  • APSE 10 START PROBLEM

    HI I HAVE PROBLEM WITH MY APSE 10,AFTER CLICKING ADOBE ICON ON MY PULPIT DONT RESPOND,ONCE COMPUTER IS RESTARTED WORKING WITHOUT PROBLEM TILL NEXT TIME WHAT CAN I DOO PLEASE FOR HELP PS MY LAPTOP IS HP PAVILION DV6 WITH WIN7 OS

  • Sto excise invoice for plant

    Hi I am creating sto between plant for a company code I  create a po for stowith doc type  UB maintain all setting as invoicing tab in not coming in po ( i think its sap stanterd) where i will maintain excise value for that sto material and how I sho

  • Mobile Reports

    Hi All, I got a task to implement the mobile BI. Any Guru's please guide me how to integrate the OBIEE/OBIA reports in Android ICS Mobile, IPad and some of mobile devices. Please give me clear idea about which OS it will support and everything end to