[#document: null]

Hi,
I try to to transfer access table data into an xml file using xerces dom parser, i get the following error. any ideas??

are you calling a "toString()" on a org.w3c.dom.Document?
if you do, then call a transform, you'll see the #document: null

Similar Messages

  • X:parse returning [#document: null]

    the following code is outputting [#document: null]
         <c:import var="sampleXML" url="../common/sample.xml" />
         <x:parse xml="${sampleXML}" var="parsedXML" />
    yet, if it c:out the variable sampleXML, it spits out the xml I have in the sample.xml file. any thoughts why this might be happening?
    thanks.

    ya, it's valid, and im just using <c:out value="${parsedXML}" />
    it's weird though. on my local i copy and pasted whats done here:
    http://www.java2s.com/Code/Java/JSTL/JSTLparseXMLdocument.htm
    and it still doesn't work, which would lead me to believe that it must be some config on my server? any thoughts?

  • DOM Document = null

    I am trying to build a DOM document. The code I wrote (taken from examples) always returns a null.
    There is no exception, everything seems OK but the document is null. It is unusable.
    My JVM : 1.4.2-03-b02 on Windows
    Same behavior on 1.4.2-08 on Linux
    I can't manage to find my mistake.
    Any clue ?
    Thanks in advance
    AF
    Here is the code
    package org.home.test.xerces;
    import java.io.File;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    public class Builder {
         public static void main(String[] args) {
              Document xmlDoc=null;
              try {
              DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
              dbFactory.setValidating(false);
              dbFactory.setNamespaceAware(false);
              DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
              xmlDoc = docBuilder.parse(new File("E:\\arnold\\test.xml") );
              System.out.println("Document builder : " + docBuilder);
              System.out.println("Document implementation : " + xmlDoc.getImplementation());
              System.out.println("Document : " + xmlDoc);
              catch (Exception e) {
                   System.out.println("Exception : " + e);
    Result in the console is:
    Document builder : org.apache.xerces.jaxp.DocumentBuilderImpl@1cb25f1
    Document implementation : org.apache.xerces.dom.DOMImplementationImpl@e3b895
    Document : [#document: null]

    The returned Document isn't null. If it was, you'd just get "null" without the "[#document" part. Don't assume that a given implementation of Document will have a toString that spits back the XML.
    Try printing out the doc's root element, or the names of the children.
    You might also look into jdom. I know it has some prettyprint methods.

  • Null but not null Document on UNIX - URGENT

    Hi, I hope someone can help me. I am using a simple DOMParser to read an xml file in. Now once I have this object I want to parse values out of it. Now on Windows this works fine. On UNIX I am getting something wierd. For instance:
    If I call:
    if(theDocument == null) {
    System.out.println("IT IS NULL");
    nothing happens
    BUT
    if I call
    System.out.println(theDocument);
    I get: [#document: null]
    and if I try to call
    theDocument.<anyMethod>
    it throws a null pointer exception
    BUT if I use XMLSerializer and serialize theDocument
    it prints out the XML perfectly.
    WHAT IS GOIN ON????????????
    I am desparate as I am at the end of a project and this is this is the last hurdle.
    If anyone knows why the object is null but isn't or anything I would greatly appreciate it.
    THANKS!!!!

    There is an issue, perhaps, because of the different EOL characters between Windows and Unix? If you wrote the parser yourself, does the code handle this difference? That's the only thing I can think of that would alter a parser working on a document between the two operating systems.
    - Saish
    'My karma ran over your dogma." - Anon

  • Error while converting document to html

    "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275"
    I use the procedure to convert the documents if it is not already converted before using procedure as follows
    PROCEDURE "STARDOC"."HTMLOUTPUT" (
    "DOCID" IN NUMBER) IS
    mklob clob;
    doccount number;
    errorcode number;
    errormessage varchar2(200);
    BEGIN -- executable part starts here
    SELECT COUNT(document_id) INTO doccount FROM docviewhtml where document_id=docid;
    --dbms_output.put_line(doccount);
    if doccount=0 then
         dbms_output.put_line('Document Not Found: Converting '||docid);
         --If document is not found run document coversion routine
         ctx_doc.filter('idxdocuments',docid, mklob,FALSE);
         INSERT INTO docviewhtml(document_id, html) VALUES (docid, mklob);
         COMMIT;
    elsif doccount=1 then
         --return;
         dbms_output.put_line('Document Found');
         --if document id found then return the document content
         null;
    else
         --dbms_output.put_line('Error occured');
         --need to deal with duplicate documents
         null;
    end if;
    dbms_lob.freetemporary(mklob);
    EXCEPTION
    --rollback when an exception occurs
         WHEN OTHERS THEN
              errorcode:=SQLCODE;
              errormessage:=SQLERRM;     
              dbms_output.put_line(sqlcode || ':' ||sqlerrm);
              ROLLBACK;
              LOGERROR(errorcode,errormessage);
    END "HTMLOUTPUT";
    i get the error when i convert large documents
    "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275"
    Also if there are any converion errors while converting documents to html. how to find them is there a log o fany sort.
    what is wrong. please help!
    Message was edited by:
    connect2sandeep

    You free your temporary lob, but never create it.

  • Webservices: returning xml document to client

    Can anyone please help me to the following problem.
    1. I have a java bean which i publish as webservice. I want to return an xml document on request from client(for time being my client is normal java client). when i call getDoc() from client i get classload exception. can anyone explain me why?
    public org.w3c.dom.Document getDoc() throws java.rmi.RemoteException {
    Document document = null;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse( new File("C:\\data\\RND\\XmlParser\\XmlParser\\src\\xmlparser\\employer.xml"));
    catch (Exception ex) {
    return document;
    2. if i have to send a xml file to clinet on request using web services(i assume i cant return an document as above), is it feasible(my xml file is a transaction file) to send a xml file as string?
    3. how to transfer a xml file into a string?

    I'm almost sure that the error is because the Document class is not supported by JAX-RPC (see page 384 of the Java Web Services Tutorial).
    Try sending your XML as a String.
    This code may help you to transform between XML and String and viceversa:
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import org.xml.sax.*;
    import org.w3c.dom.*;
    public static Document toXmlDocument(String xml) throws IOException, SAXException, ParserConfigurationException
    StringReader reader = new StringReader(xml);
    InputSource source = new InputSource(reader);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document xmlDoc = builder.parse(source);
    return ( xmlDoc );
    public static String toXmlString(Node node) throws TransformerConfigurationException, TransformerException
    StringWriter writer = new StringWriter();
    DOMSource source = new DOMSource(node);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer();
    StreamResult result = new StreamResult(writer);
    transformer.transform(source,result);
    return ( writer.toString() );
    }

  • Problem in Coverting XML String into Document

    Hi,
    I am getting some problem while parsing a String XML in to Document object.
    CODE :
    public static Document converDocument(String xml){
    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try {
    builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
    e.printStackTrace();
    Document document = null;
    try {
    document = builder.parse(new InputSource(new StringReader(xml)));
    System.out.println("Document is after parsing ====>>>"+document);
    } catch (SAXException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    } catch (IOException e1) {
    e1.printStackTrace();
    return document;
    The xml which I am passing is :
    <?xml version="1.0" encoding="UTF-8"?>
    <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>abc</body>
    </note>
    It is giving the document as null;
    Can anybody please help?
    Regards,
    sheeetal.

    >
    Vikas Sridharan wrote:

    >       CALL TRANSFORMATION ('ID')
    >       SOURCE XML = lv_output_str "<============ ERRONEOUS = HERE
    >       RESULT ref = <fst_dyn_table> .
    >
    Remove the "=" sign, this code will work :
          CALL TRANSFORMATION ('ID')
          SOURCE XML lv_output_str
          RESULT ref = <fst_dyn_table> .

  • Prolem with usage of Document in jsp

    Hi Ppl,
    Following is a part of my code in jsp..
    <%
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    String filename = "D:\\integral\\1.0\\Resources\\ApacheTomcat4.0\\webapps\\examples\\jsp\\cal\\input1.xml";
    Document doc = factory.newDocumentBuilder().parse(new File(filename));
    out.println(doc);
    %>
    The problem is doc is getting null after this expression. The file is present in that location. I have imported org.w3c.dom.* as well. Is there any other configuration required...
    Thanks in advance.
    -- Ashish

    Hi,
    After executing your code I get the following output:
    [#document: null]
    I guess it does not mean that document object is null because when I
    add the following statement to your code it gives the expected output.
    Element element = doc.getDocumentElement();
    System.out.print("Document elelment = " +element);
    Just add the above lines and check if you get the document element.
    -Amol

  • Dom parsing -- ruturning null?

    when trying to parse an xml file using DocumentBuilder.parse, i dont get any exceptions, it just returns null. I wrote a succinct Test class to debug and still cannot find the problem. below is the output, and the method i wrote.
    thanx for your help:-)
    matt
    output looks like this:
    entering Test.parse
    factory = org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@7fa65e
    builder = org.apache.xerces.jaxp.DocumentBuilderImpl@8385e3
    doc = [#document: null]
    leaving Test.parse
    the parse method looks like this:
    public Document parse(File xmlFile)
    System.out.println("entering Test.parse");
    DocumentBuilderFactory factory = null;
    DocumentBuilder builder = null;
    Document doc = null;
    try
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(xmlFile);
    System.out.println("factory = " + factory);
    System.out.println("builder = " + builder);
    System.out.println("doc = " + doc);
    }//end try
    catch(Exception e)
    e.printStackTrace();
    }//end catch e
    System.out.println("leaving Test.parse");
    return doc;
    }//end parse

    The parse() method doesn't return null, "[#document: null]" is what's returned by toString() method when you print it. Call getDocumentElement() method for the document returned by parse() to get the root node of the document.
    /Sasha
    when trying to parse an xml file using
    DocumentBuilder.parse, i dont get any exceptions, it
    just returns null. I wrote a succinct Test class to
    debug and still cannot find the problem. below is the
    output, and the method i wrote.
    thanx for your help:-)
    matt
    output looks like this:
    entering Test.parse
    factory =
    org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@7fa65
    builder =
    org.apache.xerces.jaxp.DocumentBuilderImpl@8385e3
    doc = [#document: null]
    leaving Test.parse
    the parse method looks like this:
    public Document parse(File xmlFile)
    System.out.println("entering Test.parse");
    DocumentBuilderFactory factory = null;
    DocumentBuilder builder = null;
    Document doc = null;
    try
    factory =
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(xmlFile);
    System.out.println("factory = " +
    ctory = " + factory);
    System.out.println("builder = " +
    ilder = " + builder);
    System.out.println("doc = " + doc);
    }//end try
    catch(Exception e)
    e.printStackTrace();
    }//end catch e
    System.out.println("leaving Test.parse");
    return doc;
    }//end parse

  • Errors while using plsql clob document in notification email

    bq. hello
    I am having a problem sending a plsql clob document in a notification email.Basically the procedure retrives some rows of data from the database and formats it as HTML before converting to clob. The email is generated fine when only a couple of rows are generated. however when the rows increase the workflow errors. we are using oracle ERP
    ---------------------------------Error Message-----
    An Error occurred in the following Event Subscription: Event Subscription
    Event Error Name: WFE_DISPATCH_GEN_ERR
    Event Error Message: 3835: Error '-20002 - ORA-20002: 2018: Unable to generate the notification XML. Caused by: 2020: Error when getting notification content. Caused by: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Wf_Notification.NTF_Table(8, H)
    BATCH_INFO.Batch Information(209112, text/html)
    Wf_Notification.GetAttrClob(263883, BATCH_INFO, text/html)
    Wf_Notification.oldGetAttrClob(263883, BATCH_INFO, text/html)
    WF_NOTIFICATION.GetFullBody(nid =&gt; 263883, disptype =&gt; text/html)
    WF_MAIL.GetLOBMessage3(nid =&gt; 263883, ' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'.
    Event Error Stack:
    WF_MAIL.GetLOBMessage3(263883, WFMAIL, 2020: Error when getting notification content. Caused by: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Wf_Notification.NTF_Table(8, H)
    BATCH_INFO.Batch Information(209112, text/html)
    Wf_Notification.GetAttrClob(263883, BATCH_INFO, text/html)
    Wf_Notification.oldGetAttrClob(263883, BATCH_INFO, text/html)
    WF_NOTIFICATION.GetFullBody(nid =&gt; 263883, disptype =&gt; text/html)
    WF_MAIL.GetLOBMessage3(nid =&gt; 263883, r_ntf_pref =&gt; MAILHTML), Step -&gt; Getting text/html body)
    WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 263883)
    WF_XML.Generate(oracle.apps.wf.notification.send, 263883)
    WF_XML.Generate(oracle.apps.wf.notification.send, 263883)
    Wf_Event.setMessage(oracle.apps.wf.notification.send, 263883, WF_XML.Generate)
    Wf_Event.dispatch_internal()
    The Procedure is
    bq. /********************************************************************************* \\ Procedure: BATCH_INFO \\ Purpose: Program displays batch level information. \\ *********************************************************************************/ \\ PROCEDURE batch_info ( \\ document_id IN VARCHAR2, \\ display_type IN VARCHAR2, \\ document IN OUT NOCOPY CLOB, \\ document_type IN OUT NOCOPY VARCHAR2 \\ ) \\ IS \\ table_width VARCHAR2 (8) := '100%'; \\ i PLS_INTEGER; \\ j PLS_INTEGER; \\ l_cells wf_notification.tdtype; \\ l_result VARCHAR2 (32767); \\ l_je_batch_name VARCHAR2 (100); \\ l_period_name VARCHAR2 (15); \\ l_control_total NUMBER; \\ l_running_total_dr NUMBER; \\ l_running_total_cr NUMBER; \\ l_document long; \\ cdoc clob; \\ amount NUMBER; \\ charbuff VARCHAR2(32767); \\ charbuff_size NUMBER; \\ CURSOR c_get_je (batch_id IN NUMBER) \\ IS \\ SELECT (SELECT description \\ FROM gl_lookups \\ WHERE lookup_type = 'BATCH_STATUS' \\ AND lookup_code = batch_status) batch_status, \\ je_source, \\ (SELECT user_je_category_name \\ FROM gl_je_categories \\ WHERE je_category_name = je_category) je_category, \\ period_name, batch_name, header_name, \\ header_running_total_dr_num debit, \\ header_running_total_cr_num credit \\ FROM apps.gl_je_batches_headers_v \\ WHERE je_batch_id = batch_id; \\ BEGIN \\ IF display_type = wf_notification.doc_text \\ THEN \\ document := NULL; \\ ELSE \\ /* ===========Second table Start=============*/ \\ j := 0; \\ i := 0; \\ j := 1; \\ /* Header*/ \\ l_cells (j) := 'S:' || 'Batch Status'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Source'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Category'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Period'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Batch Name'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Name'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Debit'; \\ j := j + 1; \\ l_cells (j) := 'S:' || 'Journal Credit'; \\ j := j + 1; \\ i := 0; \\ /* Body*/ \\ SELECT NAME, default_period_name, control_total, \\ running_total_dr, running_total_cr \\ INTO l_je_batch_name, l_period_name, l_control_total, \\ l_running_total_dr, l_running_total_cr \\ FROM gl.gl_je_batches \\ WHERE je_batch_id = TO_NUMBER (document_id); \\ FOR histr IN c_get_je (TO_NUMBER (document_id)) \\ LOOP \\ l_cells (j) := 'S:' || histr.batch_status; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.je_source; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.je_category; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.period_name; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.batch_name; \\ j := j + 1; \\ l_cells (j) := 'S:' || histr.header_name; \\ j := j + 1; \\ l_cells (j) := \\ 'S:' \\ || NVL (TO_CHAR (histr.debit, \\ 'L999G999G999G999G999G999G999D99'), \\ '&' || 'nbsp;' \\ ); \\ j := j + 1; \\ l_cells (j) := \\ 'S:' \\ || NVL (TO_CHAR (histr.credit, \\ 'L999G999G999G999G999G999G999D99' \\ ), \\ '&' || 'nbsp;' \\ ); \\ j := j + 1; \\ i := i + 1; \\ END LOOP; \\ table_width := '100%'; \\ wf_notification.ntf_table (l_cells, 8, 'HL', l_result); \\ /* Write data to clob */ \\ -- create temp clob \\ dbms_lob.createTemporary(cdoc,false,dbms_lob.call); \\ charbuff_size:=length(l_result); \\ write html data to temp clob \\ dbms_lob.writeappend(cdoc,charbuff_size,l_result); \\ write temp clob to document \\ amount:=dbms_lob.getlength(cdoc); \\ dbms_lob.copy(document,cdoc,amount,1,1); \\ END IF; \\ document_type := 'text/html'; \\ EXCEPTION \\ WHEN OTHERS \\ THEN \\ wf_core.CONTEXT ('BATCH_INFO', 'Batch Information', document_id,display_type); \\ RAISE; \\ END batch_info;
    Can somebody please guide me
    thank you

    The stack trace below the "ORA-06502: PL/SQL: numeric or value error: character string buffer too small" error suggests that this is being generated by the Wf_Notification.NTF_Table call. Given the way you have described the problem, I would assume that the HTML generated by that call for the data in l_cells is exceeding the length of your l_result variable (32767).
    Have you checked the length of the data generated by this call for a single record and then divided 32767 by that number to work out the maximum number of rows you can support with this call?
    If it is simply that you have too much data for WF_Notification.NTF_Table to produce the table within the 32767 limit, you try generating the HTML in smaller chunks and adding them to the CLOB bit by bit. For example, if 10 records work, then generate the HTML for 10 records, chop off the </table> from the result and add it to the clob. Then do the next 10 records (without the header this time) and chop off the <table> and </table> tags and add that to the clob. When you are done, add the closing </table> tag to the clob and return it.
    I haven't done this with returning a clob, but I have done this with shorter strings to generate a HTML table with the standard look and feel but with headers in different places than could be done by default.
    theFurryOne

  • Modifying a DOM document.

    i have a 100 MB file...where I am suppose to change a node value to null..
    i am using simple dom parser to achieve this task and it is working fine...
    but i need to pass
    -server -Xms 1G -Xmg 1G option to the java compiler and height is...it is taking 5 hours to complete updating the file.
    there are around 20000 records in my xml file.
    here is the code
    import java.io.File;
    import java.io.IOException;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Element;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    public class ChangeNodevalue {
         public static void main(String [] args) {
              Document document = null;
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             factory.setValidating(false);
             factory.setNamespaceAware(false);
             try {
                  DocumentBuilder builder = factory.newDocumentBuilder();
                    document = builder.parse( new File("d:/samples/myprogs/valuechange.xml"));
                  replace(document, "PostalAddress", "CityNm");
                  DOMSource source = new DOMSource(document);
                // Prepare the output file
                 File file = new File("D:/samples/myprogs/valuechange1.xml");
                 StreamResult result = new StreamResult(file);
                 // Write the DOM document to the file
                 Transformer xformer = TransformerFactory.newInstance().newTransformer();
                 System.out.println("Wrote to new file");
                 xformer.transform(source, result);
             catch (SAXParseException spe) {
               spe.printStackTrace();
             catch (SAXException sxe) {
               sxe.printStackTrace();
             catch (ParserConfigurationException pce) {
               pce.printStackTrace();
             catch (IOException ioe) {
               ioe.printStackTrace();
            catch(TransformerConfigurationException tce) {
                 tce.printStackTrace();
            catch(TransformerException te) {
                 te.printStackTrace();
    public static void replace(Document doc, String tag, String sub_tag){ 
                Element child = null;
                NodeList matches = doc.getElementsByTagName(tag);
                for (int cd = 0; cd < matches.getLength(); cd++) {
                          Element tag1 = (Element)matches.item(cd);
                          NodeList children = tag1.getChildNodes();
                          for (int i = 0; i < children.getLength(); i++) {
                                 if ((children.item(i)).getNodeName().equals(sub_tag)) {
                                 System.out.println((children.item(i)).getNodeName());
                                 child = (Element)children.item(i);
                                 if (child != null) {
                                          System.out.println(child.getFirstChild().getNodeValue());
                                     child.getFirstChild().setNodeValue("");
    }will use of JAXP / some other parser will do any good....any inputs???
    thank you..
    chintan.

    I don't believe the Xerces parser can be configured to leave entity references as is if the entity reference is located in an attribute value. I think you might have more luck if the entity reference is inside an element.

  • Could not parse well-formed HTML 4.01/XHTML 1.0 document using JDOM

    Hi All,
    I am having difficulty reading two well-formed HTML document using JDOM when running offline (not on the Internet). The first few lines of these documents are listed below:
      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
      2 <!-- saved from url=(0044)http://www.mongabay.com/igapo/zipcodes/CA.htm -->
      3 <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Cities and Towns in California starting with A - Zip codes United States of America</TITLE>
      4 <META http-equiv=Content-Type content="text/html; charset=UTF-8">
      5 <META
      6 content="california, cities, towns, villages, list, zipcodes, postal codes, us, ca"
      7 name=keywords>
      8 <META
      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      5 <meta name="keywords" content="8024, california, postcode, map, america, postal code, alabama Hills, Adelaide, Aberdeen, la, la, california" />
      6 <meta name="description" content="93545 zip code for Alabama Hills, Adelaide and Aberdeen (LA), California (CA) with map and local information." />
    The Java snippets that references these documents (local files) is as follows:
    1      public static void main(String[] argv) 
    2       {
    3            File zipcodefile = new File("C:\\TEMP\\Zipcodes Listing for California.txt");  // former
    4            //                                                     or
    5            File zipcodefile = new File("C:\\TEMP\\Zipcodes Listing for California  - 93545 - Los Angeles, CA.txt");  // later
    6            try
    7            {
    8                SAXBuilder saxBuilder=new SAXBuilder("org.apache.xerces.parsers.SAXParser");
    9                // saxBuilder.setValidation(false);
    10              org.jdom.Document  doc = saxBuilder.build(zipcodefile);
    11              System.out.println(doc.getContent());
    12              System.out.println(doc.getDocType());
    13              ....( i ) This program would does not work even while it was running on-line (has Internet access). The execution process would exit on line 10 but not sure whether it completes it or not. Don't understand why though?
    ( ii ) What is the difference between the two files as far as the format goes? I thought HTML 4.01 is equivalent to XHTML 1.0? In other word, they are already well-formatted and so they can be parse directly by an XML parser such as Xerces. In other word, it is not necessary to use tool such as Tidy to convert to clean up missing tags?
    ( iii ) why are the tags in the former file in capital? Do parsers in general distinguish tags in capital compared to lower case?
    I am very new to XML parsing and would appreciate some guidances.
    Thanks a lot,
    Jack

    Hi,
    I am following a possible solution (http://devdiary.motime.com/post/471628/Why+implement+your+own+EntityResolver?) on how to redirect references to entities within an XML document to a local file but do not understand why it is not picking up the parsing file (former). Below is a complete change of ZipcodeTidy2JDomParser to include my own EntityResolver:
    1  public class ZipcodeTidy2JDomParser {
    2     public static void main(String[] argv) {
    3         try {
    4             File zipcodefile = new File("C:\\TEMP\\File zipcodefile = new File("C:\\TEMP\\Zipcodes Listing for California.txt"); // former
    5             SAXBuilder saxBuilder = new SAXBuilder(false);
    6             saxBuilder.setEntityResolver(new EntityResolver() {
    7             public InputSource resolveEntity(String publicId, String systemId) {
    8                 try {
    9                     if (systemId != null && systemId.endsWith(".dtd")) {
    10                         return new InputSource(getClass().getResource("E:\\Temp\\Software Development\\Download\\Forum\\html-loose.dtd").openStream());
    11                     }
    12                 }
    13                 catch (IOException e) {
    14                     e.printStackTrace();
    15                 }
    16                 return null;
    17               }
    18             });
    19             InputStream is = new FileInputStream(zipcodefile.getName());
    20      //     InputStream is = new FileInputStream(zipcodefile);
    21             Document document = null;
    22             try {
    23                 document = saxBuilder.build(is);
    24     //          document = saxBuilder.build(zipcodefile);
    25             }
    26             catch (JDOMException e) {
    27                 e.printStackTrace();
    28             } catch (IOException e) {
    29                 e.printStackTrace();
    30             }
    31             finally {
    32                 if (document == null) return;
    33             }
    34             System.out.println(document.getContent());
    35             System.out.println(document.getDocType());
    The output from running ZipcodeTidy2JDomParser is:
    java.io.FileNotFoundException: Zipcodes Listing for California.txt. (The system cannot find the file specified)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(FileInputStream.java:106)
            at java.io.FileInputStream.<init>(FileInputStream.java:66)
            at JDOMXPath.ZipcodeTidy2JDomParser.main(ZipcodeTidy2JDomParser.java:19){code}
    Could any see where this issue is coming from?
    The author of the same thread suggest that line 5 should add an extra parameter (SAXBuilder saxBuilder = new SAXBuilder(false, "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"). However, the SAXBuilder constructor does not accept the second paramter. Any ideas?
    Many thanks,
    Jack                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Org.w3c.dom.Document toString() ?

    hi i have a constructed org.w3c.dom.Document var newDoc...
    in ibm developerworks tutorial there is a line newDoc.toString() but that gives "[#document null]"
    newDoc.getDocumentElement().getNodeValue() gives the xml string in jdk 1.4 but not in jdk 1.3 wih apache xerces 2.6.2
    how to i get the xml in string output? (i do not wish to use sun java web service development platform)
    please email responses to vishalrao at gmail dot com , thanks!

    From what I saw there was no change and the document getNodeValue always returns null in jdk1.4 as well.
    you can use the transform api to serialize xml into any serialized output form, including strings.
    look into http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/Transformer.html

  • String to org.w3c.dom.Document conversion problem

    Hi all
    I am using JDK 5 and am having scenario to convert String to w3c.Document object , by the way of finding solution i got a code snippet in sun forum
    final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DATA>sample</DATA>"; // xml to convert
    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    final DocumentBuilder builder = factory.newDocumentBuilder();
    final Document document = builder.parse(new InputSource(new StringReader(xml)));
    System.out.println(document);
    But when i try to execute this code , am gettng output as null. , i dont know why this code behaving like that , can you please help me to solve the problem?
    Thanks
    Prabu.P

    imprabu wrote:
    I am using JDK 5 and am having scenario to convert String to w3c.Document object, by the way of finding solution i got a code snippet in sun forum
    System.out.println(document);
    Hi Prabu,
    This is not the way you can print a DOM Document. You can do it using Transformer:
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DATA>sample</DATA>"; // xml to convert
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    //Wong Way of printing a DOM Document. this equal to Object.toString(), Which is of no use for you.
    System.out.println(document); // It will just print: [#document: null]
    // Using Transformer to print DOM Document
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    Source source = new DOMSource(document);
    Result output = new StreamResult(System.out);
    transformer.transform(source, output); // This will print: <?xml version="1.0" encoding="UTF-8"?><DATA>sample</DATA>*Cheers,
    typurohit* (Tejas Purohit)

  • Web Service Security is not working when migrating application from Tomcat

    Hi,
    We have a application running successfully in tomcat6 It calls a Webservice call through TIBCO BW interface.
    When we deployed the same WAR file in Weblogic 10.3.2, it gives me a error on Prefix[ds] not able to locate namespace URI not found error.
    IN Tomcat, its a existing application uses AxilUtility to get the soap messages after signing document for bothe encyption and decryption.
    Please anybody help me out, is there any other jars needs to be locate in Weblogic to run this application. Its fine with Tomcat and gives error in Weblogic10.3.2
    Please help me out
    Thanks in advance

    Hi Rajkumar,
    Thanks for you reply. Please let me now if you have any ideas..thnks a lot....
    Below is the error message what i am getting through weblogic console.
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
    ervletContext.java:2202)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
    ontext.java:2108)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
    ava:1432)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.io.IOException: error:weblogic.xml.stream.XMLStreamException: Pr
    efix [ds] used without binding it to a namespace URI
    at weblogic.xml.xmlnode.XMLNode.read(XMLNode.java:744)
    at weblogic.xml.xmlnode.XMLNode.readChildren(XMLNode.java:1054)
    at weblogic.xml.xmlnode.XMLNode.read(XMLNode.java:742)
    at weblogic.xml.xmlnode.XMLNode.readChildren(XMLNode.java:1054)
    at weblogic.xml.xmlnode.XMLNode.read(XMLNode.java:742)
    at weblogic.xml.xmlnode.XMLNode.readChildren(XMLNode.java:1054)
    at weblogic.xml.xmlnode.XMLNode.read(XMLNode.java:742)
    at weblogic.xml.xmlnode.XMLNode.readInternal(XMLNode.java:713)
    at weblogic.xml.xmlnode.XMLNode.readInternal(XMLNode.java:722)
    at weblogic.xml.xmlnode.NodeBuilder.build(NodeBuilder.java:44)
    at weblogic.xml.xmlnode.NodeBuilder.<init>(NodeBuilder.java:24)
    at weblogic.webservice.core.soap.SOAPEnvelopeImpl.<init>(SOAPEnvelopeImp
    l.java:154)
    at weblogic.webservice.core.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.j
    ava:200)
    ... 78 more
    java.lang.NullPointerException
    at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
    at com.db.alat.wss.WSSClient.postSoapMessage(WSSClient.java:358)
    at com.db.alat.wss.WSSClient.WSSEncDec(WSSClient.java:102)
    at com.db.alat.service.CollateralAccounts.getAccountsSummary(CollateralA
    ccounts.java:55)
    at com.db.alat.CH.CHMapper.getGroup(CHMapper.java:281)
    at com.db.alat.BackingBeans.BorrowerDetailsBean.getClientDataCH(Borrower
    DetailsBean.java:1034)
    at com.db.alat.BackingBeans.BorrowerDetailsBean.<init>(BorrowerDetailsBe
    an.java:766)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:186
    at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106)
    at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver
    .java:86)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
    at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELRe
    solver.java:72)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:68)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:107)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
    And i have the loggers which gives the system out statements. You can identify the difference in both logs is the sys out ...Convert Signed Document back to Soap Message.
    IN tomcat i am getting the return object after calling the method
    SOAPMessage signedMsg = (SOAPMessage) AxisUtil.toSOAPMessage(signedDoc);
    But in Weblogic i am getting NULL. You can c in SOAPMessageImpl[SOAPPartImpl[null]]
    Tomocat Logs:
    Message Context..................1.........................org.apache.axis.MessageContext@c393a1
    2011-04-21 05:35:56,906 8672 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) Unsigned Envelop............2.........................<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><RqDetail xmlns="http://schemas.db.com/esb/emf/pwm/ALAT/Services/CLIENT-getCandidateCollateralAccounts-RR" xmlns:cli="http://schemas.db.com/esb/emf/pwm/ClientElements" xmlns:com="http://schemas.db.com/esb/emf/pwm/CommonAggregates" xmlns:com1="http://schemas.db.com/esb/emf/pwm/CommonElements">
    <cli:ClientID BusinessUnit="CH">7cf8e78f86212a65398d50766de95a762318d3eee1350c1105d4b751825a690b</cli:ClientID>
    <cli:ClientType>B</cli:ClientType>
    <com:Field>
    <com1:Name>INITIALPAGE</com1:Name>
    <com1:Value>YES</com1:Value>
    </com:Field>
    </RqDetail></SOAP-ENV:Body></SOAP-ENV:Envelope>
    2011-04-21 05:35:56,906 8672 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) DOCUMENT is .......:[#document: null]
    2011-04-21 05:35:56,906 8672 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) KEYSTORE is .......:java.security.KeyStore@127fa03
    2011-04-21 05:35:57,078 8844 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) ..................................3.........................
    2011-04-21 05:35:57,094 8860 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) ..................................4.........................
    2011-04-21 05:35:57,297 9063 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) Signed Document is .......:[#document: null]
    2011-04-21 05:35:57,437 9203 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) Convert Signed Document back to Soap Message .......:[email protected]33662
    2011-04-21 05:35:57,469 9235 INFO [com.db.alat.wss.WSSClient] (http-8080-1:) ..................................5.........................
    Weblogic Logs:
    Message Context..................1.........................org.apache.axis.MessageContext@460d4
    2011-04-26 01:15:45,859 2640 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) Unsigned Envelop............2.........................<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><RqDetail xmlns="http://schemas.db.com/esb/emf/pwm/ALAT/Services/CLIENT-getCandidateCollateralAccounts-RR" xmlns:cli="http://schemas.db.com/esb/emf/pwm/ClientElements" xmlns:com="http://schemas.db.com/esb/emf/pwm/CommonAggregates" xmlns:com1="http://schemas.db.com/esb/emf/pwm/CommonElements">
    <cli:ClientID BusinessUnit="CH">2b285aa27f1899d87de00f04099506ad24aaf1c18b0b6b071a8acd19b1732fb9</cli:ClientID>
    <cli:ClientType>B</cli:ClientType>
    <com:Field>
    <com1:Name>INITIALPAGE</com1:Name>
    <com1:Value>YES</com1:Value>
    </com:Field>
    </RqDetail></SOAP-ENV:Body></SOAP-ENV:Envelope>
    2011-04-26 01:15:45,875 2656 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) DOCUMENT is .......:[#document: null]
    2011-04-26 01:15:45,875 2656 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) KEYSTORE is .......:java.security.KeyStore@167d3c4
    2011-04-26 01:15:45,984 2765 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) ..................................3.........................
    2011-04-26 01:15:46,016 2797 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) ..................................4.........................
    2011-04-26 01:15:46,234 3015 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) Signed Document is .......:[#document: null]
    2011-04-26 01:15:46,313 3094 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) Convert Signed Document back to Soap Message .......:SOAPMessageImpl[SOAPPartImpl[null]]
    2011-04-26 01:15:46,328 3109 INFO [com.db.alat.wss.WSSClient] ([ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)':) ..................................5.........................

Maybe you are looking for