XMLType.getDOM().createDocumentFragment() NOT org.w3c.dom.DocumentFragment ?

Hi,
i have an XMLType variable xml ( (XMLType) ResultSet.getObject() ) and i want to create an org.w3c.DocumentFragment by : xml.createDocumentFragment(). But i get a ClassCastException.
oracle.xdb.dom.XDBDocumentFragment does not implement org.w3c.dom.DocumentFragment ?
Thanks
Alessandro Scotti

I think that oracle.xdb.dom.XDBDocumentFragment is "internal" oracle view of org.w3c.dom.DocumentFragment
because xmltype!= DOM Document.One question:
how I can implement org.w3c.dom.DocumentFragment.getOwnerDocument() method?
Regards.

Similar Messages

  • Extends collection using generic type of org.w3c.dom.Element

    Hi, all.
    I am trying to extending collection using PriorityBlockingQueue.
    Extended queue is generic type of org.w3c.dom.Element.
    public class MyQueue<Element> extends PriorityBlockingQueue<Element> {***/}
    Compiler misunderstand to type of Element (as like E ?, not org.w3c.dom.Element), then methods in the code "this.peek ()" will be error reported by type difference.
    At fact, I tried it into MyQueue<Node> extends PriorityBlockingQueue<Node>, it not causes any misunderstanding.
    Is there any hack to indicates that the type is org.w3c.dom.Element ? This mean, MyQueue<org.w3c.dom.Element> extends PriorityBlockingQueue<org.w3c.dom.Element>...
    Thanks.

    public class MyQueue extends PriorityBlockingQueue<org.w3c.dom.Element>

  • XDK 10.1.0.2.0 NT XMLType and org.w3c.dom.Document problem/bug?

    Hi Chaps,
    I have Oracle 11g1 server side and am using the Oracle XDK 10.1.0.2.0 for Windows client side with Sun Java JDK 6 (1.6.0_06-b02).
    (I couldnt find an XDK for 11g1???)
    I have a table in my database that has an XMLType, its a very simple table -
    CREATE TABLE hcr_xml_test
    RRN VARCHAR(24) PRIMARY KEY,
    ClipID VARCHAR2(27),
    Lodgement XMLType
    XMLTYPE COLUMN Lodgement
    STORE AS OBJECT RELATIONAL
    ELEMENT "/www.hcrregister.com/RequestServices/Messages/ConditionReportCreateRequest_1.xsd#ConditionReportCreateRequest_1"
    Thats all fine, however with the XDK I am trying to construct an XMLType for use with JDBC from a valid org.w3c.dom.Document so that I can insert a row into my table. My code looks like this -
    XMLType xml = new XMLType(realCon, doc);
    stmt = (OraclePreparedStatement) realCon.prepareStatement(sql);
    stmt.setString(1, id.getRRN());
    stmt.setString(2, id.getCenteraClipID());
    stmt.setObject(3, xml);
    stmt.execute();
    doc is a org.w3c.dom.Document
    realCon is a java.sql.Connection
    That code throws a SQLException at the line "stmt.setObject(3, xml);" -
    java.sql.SQLException: Fail to convert to internal representation
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
    at oracle.sql.OPAQUE.<init>(OPAQUE.java:85)
    at oracle.xdb.XMLType.toDatum(XMLType.java:480)
    at oracle.jdbc.driver.OraclePreparedStatement.setORADataInternal(OraclePreparedStatement.java:7437)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8158)
    at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8149)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:229)
    at uk.co.landmarkinfo.registers.datawarehouse.tools.oracle.lodgementloader.DocumentProcessor.run(DocumentProcessor.java:232)
    Inspecting the exception I can see that the vendorCode is 17059.
    If I use "XMLType xml = XMLType.createXML(realCon, doc);" then xml is null instead of throwing a SQLException, so something isnt working here...
    However, if I serialize my Document to a String first and give that String to either the XMLType Constructor or XMLType.createXML() then it all works fine -
    /////TEMP
    Transformer transformer = saxTransformerFactory.newTransformer();
    transformer.setOutputProperty("omit-xml-declaration", "no");
    transformer.setOutputProperty("indent", "yes");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    transformer.transform(new DOMSource(doc), new StreamResult(baos));
    XMLType stringXML = new XMLType(realCon, new String(baos.toByteArray()));
    ////END TEMP
    stmt = (OraclePreparedStatement) realCon.prepareStatement(sql);
    stmt.setString(1, id.getRRN());
    stmt.setString(2, id.getCenteraClipID());
    stmt.setObject(3, stringXML);
    stmt.execute();
    But why do I need to serialize to a String first??? Looking at the javadoc I dont think I should have to do this. So is there a problem in Oracles XDB handling of Document or have I missed something?

    Anyone has any idea? Please help!!!
    xu

  • Method invokeMethod(java.lang.String, org.w3c.dom.Element) not found

    I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
    I will upload the 3 files that are being used for this.
    When I rebuild my files I get the following error in CustomerCO.java:
    Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
    Line 78 reads as follows:
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    Any suggestions?
    PS: I am a newbie to java and framework :-(
    Here are my files:
    CustomerCO.java:
    /*===========================================================================+
    | Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
    | All rights reserved. |
    +===========================================================================+
    | HISTORY |
    +===========================================================================*/
    package xxcu.oracle.apps.ar.customer.server.webui;
    import java.io.Serializable;
    import java.lang.Exception;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import org.w3c.dom.Element;
    import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
    * Controller for ...
    public class CustomerCO extends OAControllerImpl implements Serializable
    public static final String RCS_ID="$Header$";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    * Layout and page setup logic for a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    * 2009.07.09, Roy Feirud, lagt til for å utføre spørring
    if (pageContext.getParameter("Search") != null)
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    //Setter søkekriteriene til LindorffWS
    String Name = pageContext.getParameter("SearchName");
    String Address = pageContext.getParameter("SearchAddress");
    String Zip = pageContext.getParameter("SearchZipCode");
    String City = pageContext.getParameter("SearchCity");
    String Born = pageContext.getParameter("SearchBorn");
    String Phone = pageContext.getParameter("SearchPhoneNo");
    Serializable[] param = { Name, Address, Zip, City, Born, Phone };
    //Bygger søkestrengen
    String SearchString = (String)am.invokeMethod("initBuildString", param );
    //Initialiserer LindorffWS
    LindorffWS WsConnection = new LindorffWS();
    try
    //Kaller Web Sevice fra Lindorff
    Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    catch(Exception WsExp)
    // WsConnection = new LindorffWS();
    System.out.println("Kall til LindorffWS feilet!");
    am.invokeMethod("initQueryCustomer");
    CustomerAMImpl.java:
    package xxcu.oracle.apps.ar.customer.server;
    import java.io.Serializable;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.server.OADBTransaction;
    import oracle.apps.fnd.framework.server.OAExceptionUtils;
    import org.w3c.dom.Element;
    // --- File generated by Oracle Business Components for Java.
    public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
    * This is the default constructor (do not remove)
    public CustomerAMImpl()
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
    * Container's getter for CustomerVO1
    public CustomerVOImpl getCustomerVO1()
    return (CustomerVOImpl)findViewObject("CustomerVO1");
    * 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
    public void initQueryCustomer()
    CustomerVOImpl vo = getCustomerVO1();
    if (vo!=null)
    vo.initQuery();
    * 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
    public String initBuildString(String Name
    ,String Address
    ,String Zip
    ,String City
    ,String Born
    ,String Phone)
    String ws_string = null;
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setString(1,Name);
    cs.setString(2,Address);
    cs.setString(3,Zip);
    cs.setString(4,City);
    cs.setString(5,Born);
    cs.setString(6,Phone);
    cs.registerOutParameter(7,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    ws_string = cs.getString(7);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return ws_string;
    public String initSaveXml(Element WsXml)
    String Status = "Error";
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setObject(1,WsXml);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    Status = cs.getString(2);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return Status;
    LindorffWS.java:
    package xxcu.oracle.apps.ar.customer.ws;
    import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    //import org.apache.soap.encoding.soapenc.BeanSerializer;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    //import org.apache.soap.util.xml.QName;
    import java.util.Vector;
    import org.w3c.dom.Element;
    import java.net.URL;
    import org.apache.soap.Body;
    import org.apache.soap.Envelope;
    import org.apache.soap.messaging.Message;
    import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
    * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
    * Date Created: Fri Jul 10 10:37:21 CEST 2009
    * WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
    public class LindorffWS extends WrappedDocLiteralStub
    public LindorffWS()
    m_httpConnection = new OracleSOAPHTTPConnection();
    public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
    private OracleSOAPHTTPConnection m_httpConnection = null;
    private SOAPMappingRegistry m_smr = null;
    public Element XmlFulltextOperator(String xmlString) throws Exception
    URL endpointURL = new URL(endpoint);
    Envelope requestEnv = new Envelope();
    Body requestBody = new Body();
    Vector requestBodyEntries = new Vector();
    String wrappingName = "XmlFulltextOperator";
    String targetNamespace = "http://services.lindorffmatch.com/search";
    Vector requestData = new Vector();
    requestData.add(new Object[] {"xmlString", xmlString});
    requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
    requestBody.setBodyEntries(requestBodyEntries);
    requestEnv.setBody(requestBody);
    Message msg = new Message();
    msg.setSOAPTransport(m_httpConnection);
    msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
    Envelope responseEnv = msg.receiveEnvelope();
    Body responseBody = responseEnv.getBody();
    Vector responseData = responseBody.getBodyEntries();
    return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
    _______________________________________________________________________________________________________________________________

    Hi,
    Create an Interface to your application Module then from interface call your method,
    refer http://www.oraclearea51.com/oracle-technical-articles/oa-framework/oa-framework-beginners-guide/213-how-to-call-am-methods-from-controller-without-using-invokemethod.html for creating Interface for AM and calling it in controller.
    Regards,
    Reetesh Sharma

  • Jdev: method invokeMethod(java.lang.String, org.w3c.dom.Element) not found

    I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
    I will upload the 3 files that are being used for this.
    When I rebuild my files I get the following error in CustomerCO.java:
    Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
    Line 78 reads as follows:
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    Any suggestions?
    PS: I am a newbie to java and framework
    Here are my files:
    CustomerCO.java:
    /*===========================================================================+
    Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA
    All rights reserved.
    ===========================================================================
    HISTORY
    +===========================================================================*/
    package xxcu.oracle.apps.ar.customer.server.webui;
    import java.io.Serializable;
    import java.lang.Exception;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import org.w3c.dom.Element;
    import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
    * Controller for ...
    public class CustomerCO extends OAControllerImpl implements Serializable
    public static final String RCS_ID="$Header$";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    * Layout and page setup logic for a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    * 2009.07.09, Roy Feirud, lagt til for å utføre spørring
    if (pageContext.getParameter("Search") != null)
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    //Setter søkekriteriene til LindorffWS
    String Name = pageContext.getParameter("SearchName");
    String Address = pageContext.getParameter("SearchAddress");
    String Zip = pageContext.getParameter("SearchZipCode");
    String City = pageContext.getParameter("SearchCity");
    String Born = pageContext.getParameter("SearchBorn");
    String Phone = pageContext.getParameter("SearchPhoneNo");
    Serializable[] param = { Name, Address, Zip, City, Born, Phone };
    //Bygger søkestrengen
    String SearchString = (String)am.invokeMethod("initBuildString", param );
    //Initialiserer LindorffWS
    LindorffWS WsConnection = new LindorffWS();
    try
    //Kaller Web Sevice fra Lindorff
    Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    catch(Exception WsExp)
    // WsConnection = new LindorffWS();
    System.out.println("Kall til LindorffWS feilet!");
    am.invokeMethod("initQueryCustomer");
    CustomerAMImpl.java:
    package xxcu.oracle.apps.ar.customer.server;
    import java.io.Serializable;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.server.OADBTransaction;
    import oracle.apps.fnd.framework.server.OAExceptionUtils;
    import org.w3c.dom.Element;
    // --- File generated by Oracle Business Components for Java.
    public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
    * This is the default constructor (do not remove)
    public CustomerAMImpl()
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
    * Container's getter for CustomerVO1
    public CustomerVOImpl getCustomerVO1()
    return (CustomerVOImpl)findViewObject("CustomerVO1");
    * 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
    public void initQueryCustomer()
    CustomerVOImpl vo = getCustomerVO1();
    if (vo!=null)
    vo.initQuery();
    * 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
    public String initBuildString(String Name
    ,String Address
    ,String Zip
    ,String City
    ,String Born
    ,String Phone)
    String ws_string = null;
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setString(1,Name);
    cs.setString(2,Address);
    cs.setString(3,Zip);
    cs.setString(4,City);
    cs.setString(5,Born);
    cs.setString(6,Phone);
    cs.registerOutParameter(7,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    ws_string = cs.getString(7);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return ws_string;
    public String initSaveXml(Element WsXml)
    String Status = "Error";
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setObject(1,WsXml);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    Status = cs.getString(2);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return Status;
    LindorffWS.java:
    package xxcu.oracle.apps.ar.customer.ws;
    import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    //import org.apache.soap.encoding.soapenc.BeanSerializer;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    //import org.apache.soap.util.xml.QName;
    import java.util.Vector;
    import org.w3c.dom.Element;
    import java.net.URL;
    import org.apache.soap.Body;
    import org.apache.soap.Envelope;
    import org.apache.soap.messaging.Message;
    import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
    * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
    * Date Created: Fri Jul 10 10:37:21 CEST 2009
    * WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
    public class LindorffWS extends WrappedDocLiteralStub
    public LindorffWS()
    m_httpConnection = new OracleSOAPHTTPConnection();
    public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
    private OracleSOAPHTTPConnection m_httpConnection = null;
    private SOAPMappingRegistry m_smr = null;
    public Element XmlFulltextOperator(String xmlString) throws Exception
    URL endpointURL = new URL(endpoint);
    Envelope requestEnv = new Envelope();
    Body requestBody = new Body();
    Vector requestBodyEntries = new Vector();
    String wrappingName = "XmlFulltextOperator";
    String targetNamespace = "http://services.lindorffmatch.com/search";
    Vector requestData = new Vector();
    requestData.add(new Object[] {"xmlString", xmlString});
    requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
    requestBody.setBodyEntries(requestBodyEntries);
    requestEnv.setBody(requestBody);
    Message msg = new Message();
    msg.setSOAPTransport(m_httpConnection);
    msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
    Envelope responseEnv = msg.receiveEnvelope();
    Body responseBody = responseEnv.getBody();
    Vector responseData = responseBody.getBodyEntries();
    return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
    _______________________________________________________________________________________________________________________________

    Hi,
    wrong forum. If this is a problem related to the use of OA framework, please use the OA framework forum here on OTN
    Frank

  • Org.w3c.dom.Document not found

    I'm using jdk 1.6 and I'm getting "cannot find symbol" element when I try to compile to following simple code:
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Element;
    import org.w3c.dom.Document;
    import org.xml.sax.SAXException;
    public class TestXml {
        public static void main(String[] args) {
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          DocumentBuilder builder = factory.newDocumentBuilder();
          Document = builder.newDocument();
          Element root = (Element) document.createElement("gene");
    }What do I need to get this to compile? I thought jaxp was built into jdk1.6, so why is it not being found?

    javac TestXml.java
    TestXml.java:14: cannot find symbol
    symbol  : variable Document
    location: class TestXml
          Document = builder.newDocument();
          ^
    TestXml.java:15: cannot find symbol
    symbol  : variable document
    location: class TestXml
          Element root = (Element) document.createElement("gene");
                                   ^
    2 errorsIn eclipse, the problem is shown as "Document cannot be resolved."

  • Org.w3c.dom.Document.getElementById() not working for me

    I am having trouble using the .getelementById for the org.w3c.dom.Document class. I have devised a workaround, but was wondering what I have been doing wrong in the first place.
    My XML file contains, in part, a bunch of "sections" as outlined below:
    <section id="uniqueString">
       <icon ... />
       <window ... />
    </section>I want to get a "section" whose ID is String s . I tried using .getElementById()
    // document is of class org.w3c.dom.Document, and has parsed in an XML file
    // String s = "uniqueString"
    Element e = document.getElementById(s);However, e is null every time I run this. I have tried it with different Strings which look for other XML tags, but it always is null . I have devised a workaround:
    NodeList sections = document.getElementsByTagName("section");
    for (int i = 0; i < sections.getLength(); ++i) {
         if (((Element) sections.item(i)).getAttribute("id").equals(s)) {
              e = (Element) sections.item(i);
    // Do something with eSo the functionality I need is there; however, I was just wondering if anybody sees what I'm doing wrong in the attempt to use getElementById(). It's not essential that I find out, however it would improve my program's readability, probably improve the efficiency, and help me understand whatever concept I seem to be missing. I have been all through the javadoc online and I can't seem to figure out what's up with it.

    This is a user error. If it is any consolation, it is not uncommon.
    By "Id" this method looks for the attribute defined in the schema for this kind of XML file as an ID. It may or may not be "id".
    The JavaDoc for this method says:
    Attributes with the name "ID" or "id" are not of type ID unless so defined.
    So, you could have an attribute "programnum" defined as an ID in the schema, and find a value of that attribute with the getElementById() method.
    Dave Patterson

  • Help: program error: package org.w3c.dom does not exist

    i 've already downloaded and unpacked the java-xml-pack by following the given instruction. again when i compile the program, the compiler still can't locate the package.. org.w3c.dom where i've already import org.w3c.dom.* at the beginning of the program. so, until now, the symbol like Document, Node still can't be resolved.
    is there any important step that i've missed ??

    Even I have faced the same problem, the Reasons can be:
    1. Take the latest packages of all the JAR files U need for XML Parsing.
    2. Set the class path for all the JAR files.
    2nd thing should be the reason for U getting the error.
    All The Best.

  • Problem casting org.w3c.dom.Document to oracle.xml.parser.v2.XMLDocument

    I have the following problem:
    I get my xml-documents as an XMLType from the database and want to compare these using the supplied Oracle class oracle.xml.differ.XMLDiff (i use the java version supplied with Oracle 9i r2).
    XMLType.getDOM() returns the xml-document as a org.w3c.dom.Document,
    what i need for oracle.xml.differ.XMLDiff is a oracle.xml.parser.v2.XMLDocument.
    How can i cast/convert between these two formats?
    thanks!
    p.s. cross-posting with Re: Casting/Converting XMLType to XMLDocument? (but i think this forum is more relevant).

    Hi,
    thanks for the suggestion: i have written the code shown below. It results in a casting error.
    As far as i know, i don't use a oracle.xdb.dom.XDBDocument, i only use a oracle.xdb.XMLType as the input parameter for my conversion-method:
    any new suggestions ???
    p.s. the second method which is commented does work, but is a bit verbose.
       private static oracle.xml.parser.v2.XMLDocument convert2XMLDocument(XMLType xml) {
         // simple version (should work according to tech. doc. 9i r2/ 10g r1 database)
         oracle.xml.parser.v2.XMLDocument doc = null;
         try {
            // n.b. probleem is dat XMLType.getDOM() een w3c.Document object teruggeeft ipv een oracle.XMLDocument.
            System.out.println("convert2XMLDocument(): casting w3c.Document naar oracle.XMLDocument.");
            doc = (oracle.xml.parser.v2.XMLDocument) xml.getDOM(); // public org.w3c.dom.Document getDOM()
            System.out.println("convert2XMLDocument(): done casting w3c.Document naar oracle.XMLDocument.");
         catch (Exception e) {
            e.printStackTrace(System.out);
        return doc;
       private static XMLDocument convert2XMLDocument(XMLType xml) {
         // complex version: works ok !!!
         XMLDocument doc = null;
         try{
            DOMParser parser  = new DOMParser();
            parser.setValidationMode(oracle.xml.parser.v2.XMLParser.NONVALIDATING);
            parser.setPreserveWhitespace (true);   
            parser.parse(new StringReader(xml.getStringVal()));
            doc = parser.getDocument();
        catch ( XMLParseException e ) {
          e.printStackTrace(System.out);
        catch ( SQLException e ) {
          e.printStackTrace(System.out);
        catch ( Exception e ) {
          e.printStackTrace(System.out);
        return doc;
    convert2XMLDocument(): casting w3c.Document naar oracle.XMLDocument.
        java.lang.ClassCastException: oracle.xdb.dom.XDBDocument
         at pnb.bdb.xml.testJDBC.convert2XMLDocument(testJDBC.java:305)
         at pnb.bdb.xml.testJDBC.main(testJDBC.java:187)

  • Diff between oracle's org.w3c.dom in xmlParserV2.jar and JREs impl?

    New to Java/oracle enviornment.
    I have an class that retrieves clobs from 10g. I need to include oracles xmlParserV2.jar in the classpath for XMLType support.
    I then added this class to my app.
    When I do this, areas in my app that previously used the JRE org.w3c.dom bombs with the exception: AbstractMethodError: getTextContent()....
    I am assuming that when I set xmlParserv2.jar in my class path, that my app is now using oracle's implementation of the org.w3c.dom....
    I say this because I see the org.w3c.dom.. in the xmlParserv2jar. Is my app running into some incompatibility with the way oracle has implemented the org.w3c.dom.
    Is there a xmlParserv2.jar without the org.w3c stuff?
    I need the XMLType support from xmlParserv2.jar. Is the XMLType support dependent on oracles implementation of the org.w3c.dom....?
    Thanks everyone;
    Any help appreciated.

    I dont find the j2ee_1.3.01.jar file in a simple oc4j installation. Its present in the bpel/lib directory if you install the full soa suite.
    I removed the oc4jclient.jar, and I see the same behavior as mentioned above. If I just have two jar files - orabpel.jar and orabpel-common.jar, my application does not start up (no logs are created). When I add the j2ee_1.3.01.jar, then the logs are created but I see the LinkageError in the opmn logs.
    Thx,
    Prabhat

  • Document in org.w3c.dom.*??

    Is Document in org.w3c.dom.* a file?what is its extension?
    How can i write a file with it?

    org.w3c.dom.Document is a class that represents an XML document.
    It does not represent an XML stream as mlk says.
    It doesn't have anything to do with files. You can use an XML parser to build up a Document in memory from an XML file or any other data source that produces XML. Class org.w3c.dom.Document does not have any methods by itself that you can use to write to an XML file.
    XML files usually have the extension ".xml", but they can also have other extensions.
    See this: Working with XML: The Java/XML Tutorial

  • Org.w3c.dom.Document to/from String ?

    I need to be able to parse (once) an XML string, and then pass the parsed object around to/from different objects.
    I tried to use org.w3c.dom.Document,
    generated by javax.xml.parsers.DocumentBuilder .
    HOWEVER - I don't see any way to parse an xml String!
    The doc-builder parse() method accepts either a file/url, or an InputStream.
    When I tried to use the StringBufferInputStream I found-out it is deprecated, and that I should use StringReader.
    BUT I cannot parse using StringReader ! (the method parse() doesn't work with it)
    Is there anyway to parse a String to create a Document ?
    ========================================================
    And that's only HALF my problem:
    I did parse an input file into a Document, to experiment a little.
    I then wanted to convert it to an XML String - but couldn't.
    How do I get the xml String from a Document ?
    I cannot: How do I save it to a file ?
    I must say that under .NET both tasks are TRIVIAL:
    XmlDocument.LoadXML()
    XmlDocument.OuterXml
    Thanks
    Meir

    The doc-builder parse() method accepts either a file/url, or an InputStream.This isn't true. Look it up again. There are overridden versions of parse() that use File, InputSource, InputStream, or String. The String one isn't what you want, because the String it takes is a URL pointing to the XML and not the XML itself. The File one doesn't work for you because you don't have a file, and you've already said why the InputStream one doesn't work for you.
    So that leaves the version that takes an InputSource. So, what is an InputSource anyway? You could look it up just by clicking on the link in the API docs...

  • Set Name of org.w3c.dom.Node (= chang the TagNam)

    Hi all,
    How I can set name of my object org.w3c.dom.Node.
    In fact, this is an Element and I want to chang the tag <label> to <LABEL> befort write out DOM to XML File
    thanks a lot
    dseaa

    org.w3c.dom.Element interface does not have a setTagName() method.
    Implement interface org/w3c/dom/contentModel/CMElementDeclaration which has a setTagName() method.
    http://www.w3.org/TR/2001/WD-DOM-Level-3-CMLS-20010419/java-binding.html

  • XML Parsing exception: org.w3c.dom.ls.LSException

    Hi All,
    <p>We have a WSM(Webservice Management Application) product which will generate a 'Proxy WSDL URL' for a 'Real WSDL URL' and it does security/auditing/logging/routing and other stuffs at runtime while getting a webservice request (on Proxy WSDL) and route it to the Functional(Real WSDL URL - Application server where the actual webservice is deployed) endpoint.
    On receiving response from the functional endpoint, it again comes back to WSM which has to just give the response back to the user unless and until some special policies are attached (like schema validation policy - it will validate the response body based on the schema XSD) </p>
    <p/>
    <p>Here, while reading the response (from functional/application endpoint) over the wire and at the time of creating the actual SoapResponse (XmlResponse) for the end user
    xercesImpl.jar is used to parse the data -lsParser.parse(lsInput); which is throwing the exception <b>"org.w3c.dom.ls.LSException: An invalid XML character (Unicode: 0x16) was found in the element content of the document" </b>when it sees not properly formatted XML at any cause (having incompatible data/special character).</p>
    <p/>
    <p><b>As the exception does not even give enough information like where the XML is corrupt/having incompatible data/special character, we cant have a control to do anything from our application/product side ,as it is third party jar xercesImpl.jar. It would be really very helpful if we
    > either get a option/boolean to turn off the validation logic which is done internally in xercesImpl.jar at the time of parsing 'lsParser.parse(lsInput);'
    > or get additional information in the exception (original cause - like the incompatible/special character (or) a full corrupted response in the exception itself) with which we can get a clue to resolve the issue.</b></p>
    <p/>
    Thanks in Advance
    Priya

    I did a search on Sun site, nothing came back.
    It is on http://xml.apache.org/xerces2-j though.
    You might need to go there and download it. or make sure your
    classpath includes the right jar file.

  • Importing package org.w3c.dom

    Hi,
    I am quite new to Java programming. Therefore solving my prob. is surely kind of obvious to a lot of you guys...
    For my program I need a type named "Element" defined in org.w3c.dom. Though I did not use the type directly anywhere in my code, my Builder (Eclipse) told me that it could not build my prog because: "The compilation unit indirectly references the missing type org.w3c.dom.Element"
    I tried to import that package:
    1. downloaded the zip (downloded http://www.w3.org/TR/2002/WD-DOM-Level-3-LS-20020725/java-binding.zip)
    2. put it in a subfolder of my project
    3. set the classpath correctly
    4. added import org.w3c.dom.* to my prg (adding "import org.w3c.dom.Element" results in an error)
    After that he properly imported the package as the import line of code was not underlined in red anymore. Nevertheless the annoying error message (The comp. unit indirectly...) did not disappear. I still can not build the prog. So I expected not to find the type "Element" defined in that package. But unziping the package showed me that there is in fact a type named "Element" in "./org/w3c/dom".
    Maybe it is worth noting that using the "Java Browsing" functionality of my Eclipse on this package results in "Selected package fragment does not contain any Java resource". The package symbol in the tree structure is displayed in gray instead of yellow too (all yellow packages permit browsing).
    Does anyone have a clue how to overcome that da... prob?
    Must the package be compiled before, as there are no classes within? And if yes, how do I accomplish that?
    Regards
    Matthias

    Even I have faced the same problem, the Reasons can be:
    1. Take the latest packages of all the JAR files U need for XML Parsing.
    2. Set the class path for all the JAR files.
    2nd thing should be the reason for U getting the error.
    All The Best.

Maybe you are looking for