Using DOM APIs

Hi all,
I am using the org.w3c.dom api to create a new xml document, say. for eg., as shown below -
<root>
<element>
<child 1> value </child1>
<child 2> value </child2>
</element>
</root>
I used the following code to get this file generated -
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document documentDA = builder.newDocument();
Element rootDA = documentDA.createElement("root");
documentDA.appendChild(rootDA);
Node elementDA = rootDA.appendChild(documentDA.createTextNode("element"));
     Node child1 = elementDA.appendChild(documentDA.createTextNode("child1"));
     child1.setTextContent("1");
     Node child2 = elementDA.appendChild(documentDA.createTextNode("child2"));
     child2.setTextContent("desc1");
Once the "element" is created under the root, I would like to know the API to create the two children under this element. I get heirarchy exceptions thrown with the above code. Please help me to resolve the issue and let me know the exact API for creating the children nodes.
Thanks in advance!!!!

You are not adding the elementDA to the root node each time it is created. You only do it after the loop.
This should work better:
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();
          Document documentDA = builder.newDocument();
          Element rootDA = documentDA.createElement("DedicatedAccounts");
          documentDA.appendChild(rootDA);
          Node elementDA = null;
          for (int i = 0; i < 2; i++) {
               elementDA = documentDA.createElement("DedicatedAccount");
               rootDA.appendChild(elementDA);
               Node DAID = documentDA.createElement("DAID");
               Node DADesc = documentDA.createElement("DAdesc");
               DAID.appendChild( documentDA.createTextNode( Integer.toString(i) ) );
               DADesc.appendChild( documentDA.createTextNode( "desc" ) );
               elementDA.appendChild(DAID);
               elementDA.appendChild(DADesc);
          Transformer xformer = TransformerFactory.newInstance().newTransformer();
          xformer.transform(new DOMSource(rootDA), new StreamResult(System.out));- Roy
P.S. When you post code mark the code in your post, and press the code button. This add tag before and after your code and makes it a lot more readable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to move XML tree to another level using DOM api ?

    <p>
    Hi,
    </p>
    <p>
    I have a followin function
    </p>
    <p>
    <font face="courier new,courier"><strong>    public void printEmployeesAsXML(){
    </strong></font>
    </p>
    <p>
    <font face="courier new,courier"><strong>        ViewObject vo = getEmployees();
            Node no = vo.writeXML(-1,XMLInterface.XML_OPT_ALL_ROWS);
            XMLNode oraXML = (XMLNode)no; 
            try {
                    oraXML.print(System.out);
                } catch (IOException e) {
                    e.printStackTrace();
        } </strong></font>
    </p>
    <p>
    <font face="courier new,courier"><strong>that gives me following XML:</strong></font>
    </p>
    <p>
    <font face="courier new,courier"><strong>&lt;Employees&gt;
       &lt;Employee&gt;
          &lt;Empno&gt;7369&lt;/Empno&gt;
          &lt;LastName&gt;SMITH&lt;/LastName&gt;
          &lt;Job&gt;CLERK&lt;/Job&gt;
          &lt;Manager&gt;7902&lt;/Manager&gt;
          &lt;HireDate&gt;1980-12-17&lt;/HireDate&gt;
          &lt;Salary&gt;800&lt;/Salary&gt;
          &lt;Deptno&gt;20&lt;/Deptno&gt;
       &lt;/Employee&gt;</strong></font>
    <font face="courier new,courier"><strong>&lt;/Employees&gt;</strong></font>
    </p>
    <p>
    I always wil have only one row, so I need following XML:
    <font face="courier new,courier"><strong>
       &lt;Employee&gt;
          &lt;Empno&gt;7369&lt;/Empno&gt;
          &lt;LastName&gt;SMITH&lt;/LastName&gt;
          &lt;Job&gt;CLERK&lt;/Job&gt;
          &lt;Manager&gt;7902&lt;/Manager&gt;
          &lt;HireDate&gt;1980-12-17&lt;/HireDate&gt;
          &lt;Salary&gt;800&lt;/Salary&gt;
          &lt;Deptno&gt;20&lt;/Deptno&gt;
       &lt;/Employee&gt;</strong></font>
    </p>
    <p>
    Question is how to remove <strong>&lt;/Employees&gt;</strong> tag using w3c DOM API and move tree one level above
    </p>
    <p>
    Kuba 
    </p>
    <p>
    </p>

    The XSLT for the required transformation is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"/>
    <xsl:template match="/Employees">
    <xsl:copy-of select="Employee"/>
    </xsl:template>
    </xsl:stylesheet>

  • Extracting Attrubutes using DOM API (I need help!!!!)

    Hi,
    I need some help on how to extract (or parse) the Attributes value in the XML using the DBMS_XMLDOM package.
    Here is the XML sample.
    <COMPANY>
    <DEPARTMENT DEPT="10">
    <EMP ID="123" NAME="JOHN" />
    <EMP ID="456" NAME="PETER" />
    <EMP ID="789" NAME="PAUL" />
    </DEPARTMENT>
    <DEPARTMENT DEPT="20">
    <EMP ID="987" NAME="SIMON" />
    <EMP ID="654" NAME="JAMES" />
    <EMP ID="321" NAME="ANDREW" />
    </DEPARTMENT>
    <DEPARTMENT DEPT="30">
    <EMP ID="129" NAME="JOHN" />
    <EMP ID="348" NAME="PETER" />
    <EMP ID="567" NAME="PAUL" />
    </DEPARTMENT>
    </COMPANY>
    BTW, we are using Oracle v9.2.0.4.0
    Thanks in advance

    The following procedure may help...
    procedure uploadFiles(FILE_LIST varchar2 default 'ls.xml', UPLOAD_DIRECTORY_NAME varchar2 default USER, REPOSITORY_FOLDER_PATH varchar2 default '/home/' || USER , BATCH_SIZE number default 1)
    as
    pathSeperator varchar2(1) := '/';
    DIRECTORY_PATH varchar2(256);
    SUBDIRECTORY_PATH varchar2(256);
    TARGET_FOLDER_PATH varchar2(256);
    TARGET_FILE_PATH varchar2(256);
    TARGET_FILE_NAME varchar2(256);
    RESOURCE_PATH varchar2(256);
    LAST_FOLDER_PATH varchar2(256) := ' ';
    sqlStatement varchar2(256);
    FILELIST_XML XMLTYPE := XMLType(bfilename(UPLOAD_DIRECTORY_NAME,FILE_LIST),nls_charset_id('AL32UTF8'));
    CONTENT_XML XMLType;
    result boolean;
    filecount binary_integer := 0;
    FILELIST_DOM DBMS_XMLDOM.DOMDOCUMENT;
    FILES_NL DBMS_XMLDOM.DOMNODELIST;
    DIRECTORY_NL DBMS_XMLDOM.DOMNODELIST;
    FILENAME_NL DBMS_XMLDOM.DOMNODELIST;
    FILES_NODE DBMS_XMLDOM.DOMNODE;
    DIRECTORY_NODE DBMS_XMLDOM.DOMNODE;
    FILE_NODE DBMS_XMLDOM.DOMNODE;
    TEXT_NODE DBMS_XMLDOM.DOMNODE;
    ENCODING_ATTR DBMS_XMLDOM.DOMATTR;
    REPLACE_ATTR DBMS_XMLDOM.DOMATTR;
    PATH VARCHAR2(256);
    FILE_NAME VARCHAR2(256);
    ENCODING_TEXT VARCHAR2(32);
    ATTR_VALUE VARCHAR2(256);
    REPLACE_OPTION BOOLEAN;
    REPLACE_DEFAULT BOOLEAN;
    DEBUG_BUFFER VARCHAR2(255);
    begin
    -- Create the set of Folders in the XDB Repository
    FILELIST_DOM := DBMS_XMLDOM.newDOMDocument(FILELIST_XML);
    DIRECTORY_NL := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(FILELIST_DOM,'directory');
    FOR i in 0 .. (DBMS_XMLDOM.GETLENGTH(DIRECTORY_NL) - 1) LOOP
    DIRECTORY_NODE := DBMS_XMLDOM.ITEM(DIRECTORY_NL,i);
    TEXT_NODE := DBMS_XMLDOM.GETFIRSTCHILD(DIRECTORY_NODE);
    DIRECTORY_PATH := DBMS_XMLDOM.GETNODEVALUE(TEXT_NODE);
    DIRECTORY_PATH := REPOSITORY_FOLDER_PATH || DIRECTORY_PATH;
    createDirectoryTree(DIRECTORY_PATH);
    END LOOP;
    -- Find the Local File System Path to the target Directory.
    select DIRECTORY_PATH
    into DIRECTORY_PATH
    from ALL_DIRECTORIES
    where DIRECTORY_NAME = UPLOAD_DIRECTORY_NAME;
    -- dbms_output.put_line('OS Root = ' || DIRECTORY_PATH);
    -- Load the Resources into the XML DB Repository
    FILES_NL := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(FILELIST_DOM,'files');
    FILES_NODE := DBMS_XMLDOM.ITEM(FILES_NL,0);
    REPLACE_DEFAULT := FALSE;
    REPLACE_ATTR := DBMS_XMLDOM.getAttributeNode(DBMS_XMLDOM.MAKEELEMENT(FILES_NODE),'replace');
    if not (DBMS_XMLDOM.ISNULL(REPLACE_ATTR)) then
    REPLACE_DEFAULT := xdb_dom_helper.varchar_to_boolean(DBMS_XMLDOM.getVALUE(REPLACE_ATTR));
    end if;
    FILENAME_NL := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(FILELIST_DOM,'file');
    FOR i in 0 .. (DBMS_XMLDOM.GETLENGTH(FILENAME_NL) - 1) LOOP
    FILE_NODE := DBMS_XMLDOM.ITEM(FILENAME_NL,i);
    TEXT_NODE := DBMS_XMLDOM.GETFIRSTCHILD(FILE_NODE);
    TARGET_FILE_PATH := DBMS_XMLDOM.GETNODEVALUE(TEXT_NODE);
    -- dbms_output.put_line('Source = ' || TARGET_FILE_PATH);
    TARGET_FILE_NAME := substr(TARGET_FILE_PATH,instr(TARGET_FILE_PATH,pathSeperator,-1)+1);
    -- dbms_output.put_line('File = ' || TARGET_FILE_NAME);
    TARGET_FOLDER_PATH := substr(TARGET_FILE_PATH,1,instr(TARGET_FILE_PATH,pathSeperator,-1));
    TARGET_FOLDER_PATH := substr(TARGET_FOLDER_PATH,instr(TARGET_FOLDER_PATH,pathSeperator));
    TARGET_FOLDER_PATH := substr(TARGET_FOLDER_PATH,1,length(TARGET_FOLDER_PATH)-1);
    ENCODING_ATTR := DBMS_XMLDOM.getAttributeNode(DBMS_XMLDOM.MAKEELEMENT(FILE_NODE),'encoding');
    ENCODING_TEXT := 'AL32UTF8';
    if not (DBMS_XMLDOM.ISNULL(ENCODING_ATTR)) then
    ENCODING_TEXT := DBMS_XMLDOM.getValue(ENCODING_ATTR);
    dbms_output.put_line('Encoding for ' || TARGET_FILE_NAME || ' = ' || ENCODING_TEXT);
    end if;
    REPLACE_ATTR := DBMS_XMLDOM.getAttributeNode(DBMS_XMLDOM.MAKEELEMENT(FILE_NODE),'Replace');
    REPLACE_OPTION := REPLACE_DEFAULT;
    if not (DBMS_XMLDOM.ISNULL(REPLACE_ATTR)) then
    REPLACE_OPTION := xdb_dom_helper.varchar_to_boolean(DBMS_XMLDOM.getValue(REPLACE_ATTR));
    end if;
    if (LAST_FOLDER_PATH != TARGET_FOLDER_PATH) then
    SUBDIRECTORY_PATH := DIRECTORY_PATH || TARGET_FOLDER_PATH;
    -- dbms_output.put_line('Directory = ' || SUBDIRECTORY_PATH);
    sqlStatement := 'create or replace directory SUBDIR as ''' || SUBDIRECTORY_PATH || '''';
    execute immediate sqlStatement;
    LAST_FOLDER_PATH := TARGET_FOLDER_PATH;
    end if;
    CONTENT_XML := xmltype(bfilename('SUBDIR',TARGET_FILE_NAME),nls_charset_id(ENCODING_TEXT));
    RESOURCE_PATH := REPOSITORY_FOLDER_PATH || TARGET_FOLDER_PATH || '/' || TARGET_FILE_NAME;
    -- dbms_output.put_line('Target = ' || RESOURCE_PATH);
    if (REPLACE_OPTION and dbms_xdb.existsResource(RESOURCE_PATH)) then
    dbms_xdb.deleteResource(RESOURCE_PATH);
    end if;
    result := dbms_xdb.createResource(RESOURCE_PATH,CONTENT_XML);
    filecount := filecount + 1;
    if (filecount = BATCH_SIZE) then
    filecount := 0;
    commit;
    end if;
    END LOOP;
    end;
    For instance code to get an 'encoding' attribute from a 'file' element

  • How ECMAScript enabled SVG Documnt be generated dynamically using DOM API.

    <?xml version="1.0" encoding="UTF-8"?>
    <svg height="200cm" width="200cm">
    <script type="text/ecmascript">
    <![CDATA[function rect_click(id){appletHost.getSelectedRectId(id);}]]>
    </script>
    <rect fill="none" height="1.0cm" i="5" id="B7001-09" j="0" stroke="blue" stroke-width="1" width="2.0cm" x="27.0cm" y="0.8cm" onclick="rect_click('B7001')"/>
    <rect fill="none" height="1.0cm" i="5" id="B7001-09" j="0" stroke="blue" stroke-width="1" width="2.0cm" x="27.0cm" y="0.8cm"/>
    <rect fill="none" height="1.0cm" i="5" id="B7001-09" j="0" stroke="blue" stroke-width="1" width="2.0cm" x="27.0cm" y="0.8cm"/>
    </svg>

    Sorry to ask u this question, its ver simple.
    Create CDATA Section through the document and append it to the Script Element..
    Element script = doc.createElement("script");
    script.setAttribute("type","text/ecmascript");
    script.appendChild(doc.createCDATASection("function rect_click(id){appletHost.getSelectedRectId(id);}"));
    doc.getDocumentElement().appendChild(script);
    Output inside <svg> tag::
    <script type="text/ecmascript">
    <![CDATA[function rect_click(id){appletHost.getSelectedRectId(id);}]]>
    </script>
    Rohit Joshi

  • Writing to a xml file using DOM API

    Hi,
    I try to write some elements in an existing xml file.
    Document doc = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    try
         builder = factory.newDocumentBuilder();
         doc = builder.parse("c:/WUTEMP/rules.xml");
         Element rules = doc.getDocumentElement();
         Element eRule = doc.createElement("rule");
         rules.appendChild(eRule);
         Element ruleSyntax = doc.createElement("rule-syntax");
         eRule.appendChild(ruleSyntax);
         ruleSyntax.appendChild(doc.createTextNode(syntax));
    It runs without errors but the xml file isn't changed. Some ideas ?
    Structure of xml file:
    <rules>
    </rules>
    And executing code above must resulting in :
    <rules>
    <rule-syntax> </rule-syntax>
    </rules>
    But nothing happens with the file.

    Code below did the trick:
    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(new File("c:/WUTEMP/rules.xml"));
    xformer.transform(source, result);

  • Problem with DOM API

    Hi,
    I use org.w3c.dom to create an XML file.
    I need to configure "xmlns" into father and child tags, because I have to send my XML to a soap webservice,
    and the server arises "error in schema XML" if I put "xmlns" only in father, not in child.
    The problem is that DOM API automatically removes the "xmlns" from child, and I didn't find a way to force it
    to use "xmlns" at any time.
    This is my XML before to generate the DOM tree:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?> 
      <nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2"> 
        <enviNFe versao="2.00" xmlns="http://www.portalfiscal.inf.br/nfe"> 
          <idLote>75600</idLote> 
          <NFe xmlns="http://www.portalfiscal.inf.br/nfe"> 
            ... many internal tags ...
          </NFe> 
        </enviNFe> 
    </nfeDadosMsg>After to generate the DOM tree, NFe becomes without "xmlns", only "<NFe>".
    If I change to:
    <NFe xmlns="http://www.portalfiscal.inf.br/nfeXXX">then the DOM tree becomes fine with "xmlns" into enviNFe and NFe, but
    because the xmlns's are differents.

    If you stop thinking of that as an "xmlns attribute" and start thinking of it as what it really is, namely a namespace declaration, then you might understand the part of the DOM documentation which refers to namespaces better. You might also track down the rule which describes what a "default" namespace is and how it's inherited (and overridden) by child elements. Without that these things are just going to be a mystery to you.
    Also be sure to make your DOM be namespace-aware if you're going to use namespaces. By default it isn't. I believe it's the factory which has the setNamespaceAware method and not the parser.

  • How to identify a CDATA section in DOM API?

    I'm having a problem reading a CDATA section from using the DOM API. A call to Node.getNodeType() doesn't return CDATA_SECTION_NODE as expected but returns TEXT_NODE. Also, a call to getValue() doesn't return <![CDATA[<foo>]]> but returns
    <foo> instead. Does anyone know how to get getNodeType() to return the proper value?
    For example suppose I have the following XML:
    <?XML version="1.0"?>
    <document>
    <elm><![CDATA[text with <b>HTML</b>]]></elm>
    </document>
    A call to getNodeType() for the value Node (the child of the <elm> node) returns TEXT_NODE. I would expect it to return CDATA_SECTION_NODE.
    Ken

    C'mon Oracle people -- help me out here,
    Is this a known bug or what? I just discovered that if you do a cloneNode()
    the CDATA section gets messed up, too.
    Ken
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Kenneth Liu ([email protected]):
    I'm having a problem reading a CDATA section from using the DOM API. A call to Node.getNodeType() doesn't return CDATA_SECTION_NODE as expected but returns TEXT_NODE. Also, a call to getValue() doesn't return <![CDATA[<foo>]]> but returns
    <foo> instead. Does anyone know how to get getNodeType() to return the proper value?
    For example suppose I have the following XML:
    <?XML version="1.0"?>
    <document>
    <elm><![CDATA[text with <b>HTML</b>]]></elm>
    </document>
    A call to getNodeType() for the value Node (the child of the <elm> node) returns TEXT_NODE. I would expect it to return CDATA_SECTION_NODE.
    Ken<HR></BLOCKQUOTE>
    null

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

  • Cross-DOM API and/or Techniques for simple image manipulation

    Am I correct in assuming that Cross-DOM API calls presume the target application is running? That is, these calls are not out to a "shared" library so to speak, but actually communication between two running apps.
    Assuming that is the case, is there any way, within Bridge itself, to do simple manipulations on files, such as scaling, and file type conversion. Am I required to have photoshop running to do this?

    Not sure on which platform you are using, and hoping it is not for hires/hiquality purposes, but you could use one of the many engines, for example the AppleScript Graphic Core.
    If you want/have to use PhotoShop, for what I know it has to be running.
    Bye!

  • Namespace declaration using DOM

    Hi,
    I am using DOM to create an XML document. How do I declare namespace?
    I want to know which API is used to create namespace declaration in an XML document.
    I want my final XML document to be
    <RootElement xmlns:c="http://pradeep.somesite.com">
    <name>pradeep</name>
    <RootElement>
    My problem is how to put the xml ns declaraton in RootElement.
    Some one plz help;
    thanks in adv.

    xmlns is like any other attribute.
    Try something like:
    NamedNodeMap attributes = rootElement.getAttributes();
    Attr namespace = myDoc.createAttribute("xmlns");
    namespace.setValue("........");
    attributes.setNamedItem(namespace);

  • Rounding of decimal values into XML using DOM

    I want to roundoff 10.456 to 10.4(while generating the xml) using DOM.
    Please let me know how to handle this?
    Thanks in advance

    read the java.lang.Math API
    there are rounding functions there
    and next time please just use a search engine

  • How and from where can I download the dom API?

    I'm looking to use the functionality in the dom API, to convert a html document to dom and then traverse it and pull out any information I require from the tree-like dom structure. I've been told that the best way to do this is to use the dom package, but where do I get it from? Because it is not incorporated into the standard Java 1.4 that I have on my machine.
    Any help would be great.
    Cheers
    Anjum

    I don't believe it works at all in 1.4 other than the simple
    "get the title of the html documnent" example they show.
    Bug 4803577 aggregates all the dom bug reports. There are alot.
    This bug report indicates the fixes are in 1.5.

  • HELP: Using DOM in J2ME

    I'm trying to use DOM in J2ME, but I'm unable to find a API that has a documentFactory. Can anyone help me?

    "I'm using J2ME" isn't very informative, because there are a number of basic J2ME APIs, called profiles. For mobile phones it's generally MIDP (1.0 or 2.0); for devices like PocketPC it's as likely to be FP (Foundation Profile), PBP (Personal Basis Profile), or PP (Personal Profile), again having multiple versions.

  • Why is the "Common DOM API" not included in main JDK1.4 / JAXP1.1 packages?

    Hi,
    It's good the core XML DOM is implemented in Java, and even better that this is to become integrated into JDK1.4. However, I don't understand why the JDK1.4 / JAXP 1.1 only includes the "org.w3c.dom" package and not the other DOM packages ("org.w3c.dom.events", etc. such as those implemented in Xerces or those that appear in the Common DOM API).
    Can anyone explain how to use this functionality (all DOM APIs) using JAXP 1.1 or JDK 1.4 ? Or must I stick to including the Apache implementation?
    Some useful references:
    http://java.sun.com/j2se/1.4/docs/guide/plugin/dom/index.html
    http://xml.apache.org/xerces-j/
    Hopefully someone can explain this a bit more to me...
    Thanks,
    Chris

    I am curious for the answer to this as well... I have been using Java SDK 1.3.1 with Apache's xerces 2.0.0-beta4, and am now trying to upgrade to SDK 1.4 with xerces 2.0.0..
    Also, what about package org.w3c.dom.ranges? Does anyone know if this an Apache-defined package, or is it a standard w3c one (in which case, why is it not part of the Common DOM API set)?
    Thanks for any help!

  • Question using Java API in a multi threaded application for MDX queries

    Currently I’m building a web application that makes a lot of MDX calls using the Essbase Java API. Each time we run an MDX call we basically run the following code:
    IEssbase ess = IEssbase.Home.create(IEssbase.JAPI_VERSION);
    IEssDomain dom = ess.signOn(userName, password, false, null, "embedded");
    IEssCubeView cv = cv=dom.openCubeView("view", hostName, appName, cubeName);
    IEssOpMdxQuery op = cv.createIEssOpMdxQuery();
    op.setQuery(false,mdx,false,IEssOpMdxQuery.EEssMemberIdentifierType.NAME);
    cv.performOperation(op);
    IEssMdDataSet mddata = cv.getMdDataSet();
    cv.close();
    My questions is, is this the correct way to use the API in multi threaded environment where many users may be hitting the application at the same time? For every request do I need to create a separate IEssbase object and sign on to an IEssDomain? Or can I use a single IEssbase and IEssDomain object for the entire application? If not should I call the IEssDomain.signOff() method after each user’s request has completed? Which of the above objects are thread safe? I’m using Essabae 9.3.1. Any insight would be really appreciated.
    Thanks
    David

    Thanks for the input friend,
    I should have mentioned that in my application all
    connections to Essbase use the same user name and
    password so the filtering isn’t a concern. This is my
    first Java application using Essbase has a data
    source, I’m used to connecting to various SQL
    databases and I always use a connection pool, how is
    connection pooling handled in the Essbase java API?I'm not sure what happened to it since I never used it, but there used to be something called the High Availability Services or something that was essentially a connection pool for Essbase JAPI connections, but it required an extra license.
    Since you don't care about identity (everyone has full access to everything), you can create your own connection pool, but you'll have to manage your multithreading yourself. Its been this way since the beginning. The C API isn't/wasn't thread-safe either (we tried).

Maybe you are looking for