Implementing DOM Interface with existing Java classes

I had planned on using some tree-like Java classes as a Document Object Model, which would give me access to all sorts of XML and DOM tools like parsers and XSLT transformers. Initially, I thought all that would be neccessary is to implement all the DOM Interfaces in org.w3c.dom and then I would have a set of classes that conformed to DOM Level 1. It was my understanding that interfaces such as DOMImplementation and Document would interface with various XML tools, allowing creation of a class that implements Document and then Document would have its various factory methods that know how to create the various DOM nodes such as Element, Attr, Text, NamedNodeMap, NodeList, etc.
The problem I'm seeing now is that the JAXP specification (which is what the latest Xerces and Xalan tools conform to) has something called a DocumentBuilder and DocumentBuilderFactory that appear to be necessary to tell the framework what type of class to instantiate that implements the Document DOM interface. Those appear to have a lot of methods that deal with parsing of XML documents and I didn't really want to write or even subclass any existing Parsers in order to get the functionality of traversing and transforming a set of classes that implement the DOM interface.
Am I missing something here? Is it possible to plug in any (set of classes for) DOMImplementation and get them to work with the various DOM and XML tools out there?
Is there an easier way to allow parts of an application access to internal data structures but have the more generic tools or APIs, such as XSL transformers, access that same set of classes as a DOM with the generic DOM interface methods?
Can someone provide me with some guidance here? I'm in the process of finalizing some design on a system and need to know if this is possible or if I need to alter my design.
Thanks.

If I understand you correctly, I think I am working on a similar issue. I am unhappy with the methods given by the DOM for retrieving data from the XML file and for building a file. Our software has a bunch of code that uses these classes and it is extremely ugly. My solution was to create a facade on top of the DOM model. Essentially I have some simple classes that store all the pertinent info (for me) about the XML structure. Essentially that is the element or attribute name, its values and in the case of the element, it's children. This makes it easier for me to build and retreive the data. What I then built was a loader class and a builder class. The loader takes an XML file and parses it in using the DOM classes and builds a structure using my classes and returns the root element. The builder takes a root element and creates a DOM object out of it. This frees me of having to code around the DOM classes all over the place and makes it simple to upgrade our XML code if the DOM changes or a better DOM is released. I am using factories to facilitate this and allow me to have loaders for specific types of XML documents so that I can have a class for each which further simplifies the XML related tasks of other developers on my team.

Similar Messages

  • Map xsd complex type to existing java class without adding JAXB annotations

    Hello
    I've got a case where I should map an xsd complex type to an existing Java class without modifying that class, i.e. without adding JAXB annotations to that class.
    Is this possible somehow?
    As far as I've understood, the <javaType> declaration (adapter, parse/print methods) can only be used for xsd simple types.
    Thanks, Tom

    It should be possible to implement an XmlAdapter<...,...> which performs the required conversion between the original type and a JAXB-annotated type. Then, at the places where the original type is used, the @XmlJavaTypeAdapter annotation would be used.
    The xjc compiler supports this for xsd simple types (xjc:javaType annotation), but not for complex types.
    Any idea why this is restricted to simple types?
    Would it be possible to implement a xjc plugin which does this for complex types?
    Thanks Tom.

  • How to create a UML diagram from a existing .java/.class file?

    I want to create a UML diagram from a existing .java/.class file automatic in JDeveloper. Can I get it? thanks!

    create a new class diagram and then simply drag the java classes from your project onto the diagram area.

  • ISetup new custom interface using BC4J/java class

    Hi,
    I am able to create new custom interface using the link :- How to setup an user to be Oracle iSetup Super user ? but I have not seen anything for BC4J filter set, as per oracle iSetup developer guide clearly explains step by step process how to create custom BC4J interface type, but they have not mention how to add filters, as per oracle developer guide we have to use 'iSetup Framework' for BC4J, if we select type as 'iSetup Framework' then we don't have option to add filter parameters.
    Any idea how to see existing  iSetup interface repository values, Search shows the result, but we can't go in details? any idea to see this?
    Oracle have good interface repository but most of them does not have option to filter, and  update so I want to customize them by adding new interfaces with filterable and update option
    Regards
    Anil

    First, be sure your properties file is in the root of the classpath.
    The Messages.properties or Messages_en.properties should be in the WEB-INF/classes/ directory of the war or as a root file of a jar included in the classpath (WEB-INF/lib).
    If it doesn't work, try adding a "/" before the file name. The classloader will try to find it as a root file of the classpath.
    For example:
              ResourceBundle messages = ResourceBundle.getBundle("/Messages", locale);
    If you are using sun appserver, the classloader hierarchy is configured by default from inside the war to outside, so it will search first in the WEB-INF/classes/Messages_en.properties and then it will search the file inside each jar file in WEB-INF/lib.
    If you want more information, check the classloader hierarchy of the appserver you are using.
    Hope it helps.

  • Implementing Runnable interface  Vs  extending Thread class

    hi,
    i've come to know by some people says that Implementing Runnbale interface while creating a thread is better option rather than extending a Thread class. HOw and Why? Can anybody explain.?

    Its the same amount of programming work...
    Sometimes it is not possible to extend Thread, becuase your threaded class might have to extend something else.
    The only difference between implementing Runnable and extending Thread is that by extending Thread, each of your threads has a unique object associated with it, whereas with Runnable, many threads share the same object instance.
    http://developerlife.com/lessons/threadsintro/default.htm#Implementing

  • Use Sun Java Studio 2 with Existing Java Application

    I have started using Sun Java Studio 2 and having fun and little difficulty creating a new Java web application from scatch. My question is where do I find information on Java Studio configuration to allow Java Studio to load up and modify Java server pages/forms in an existing Java application that I did not write?
    The Java application has been created with Javabeans and using BEA Weblogic version 7, with a SQL-Server 2000 database backend.
    Below is a bit of code out of one of the main Java forms.
    <%@ page buffer="256kb" autoFlush="false" errorPage="../../common/system/error.jsp"
    import="psdi.jsp.beans.*, psdi.jsp.common.*, psdi.jsp.app.wotrack.*, psdi.jsp.util.* , psdi.mbo.* , psdi.util.* "%>
    I have looked around and have not found what I need to setup in Java Studio to allow me to load up a form and view it in the Visual designer, I keep getting errors on the psdi. references and cannot load up any pages.
    I see on the server install ia folder under the main root <DIR> called <apps>, and inside the <apps> folder is a folder called <jsp> and in the <jsp> folder are sub folders for each main module within the application with all the related .jsp files. I have been manually editing the .jsp files using Windows Notpad and saving the changes. Then I rebuild the .ear file and my changes work fine. Since I have a lot of changes to make there has to be a better way than using Notpad.
    My hope is somewhere is a point-by-point document on what to so I can use Sun Java Studio 2 to make my changes in a visual IDE.
    Any assistance would really be appreciated.

    Hi Giri,
    Yep, this I know,b ut when I do I get errors messages and am looking for some form of point-bypoint instuction that better explains how to setup up custom libraries in Sun Java Studio, custom tags, etc.

  • JBoss with regular Java class

    Can I use JBoss with a regular Java class? If no... which's the best way to make this?

    Yes.
    You'll have to read the JBoss documentation to find out where you need to place the regular Java class. Once you have done so, you can...
    <%@ page import="com.carnargos.packages.*" %>
    <html>
    <body>
    <%
          HelloWorld hw = new HelloWorld( );
    %>
    <%= hw.getGreetings( ); %>
    </body>
    </html>

  • Newbie: first time interfacing with existing site

    Hi, first post here.
    Our company has an existing website that was created several
    years ago by someone no longer with the company. It is ColdFusion
    based.
    For the last few years, I have been in charge of site
    management. I have no formal background or training as a webmaster,
    so my experience growth has been awkward and unconventional.
    I've been doing coding using a text editor to do direct html
    manipulation. I then test "live" on our site, usually on a hidden
    page. As my company grows, I have not had the time to keep up with
    site expansion, and I have yet to date to find a reliable full time
    or part time webmaster replacement for me (believe me, I've tried)!
    So in the meantime, I have decided to see if I can simplify
    my work using Dreamweaver.
    So far, I am not off to a great start.
    I have downloaded our entire site to our local networked
    server in order to have a local architecture mirror. However, since
    our local server does not have CF installed, I realize that I
    cannot test locally.
    I set up remote access to our web server, and Dreamweaver
    connects successfully when I test in site management.
    However, when I go to "remote view" or "testing server" and
    accept the prompt to Get Dependent Files, I always end up with a
    partially complete view of the page I want to see, with many
    missing elements.
    Am I asking too much from Dreamweaver, since in essence I am
    asking it to come in and manage a very mature and extensively
    developed site after the fact? Is the program able to fully
    interface with any established site as long as its programming
    language is supported?
    Thanks for any basic advice here.
    Tod

    Sounds like maybe you haven't told us everything. Does your
    site use
    Coldfusion programming? If so, you can always download the
    free
    developer version and test locally.
    As far as testing HTML locally, you don't need a remote
    connection.
    You can download the files to your computer and use the
    Preview in
    Browser to test the pages before you load them. And yes, you
    should
    be able to scroll up and down and see the entire page if it's
    coded
    properly.
    Or am I totally misunderstanding your question?

  • Class implementing two interfaces with same methods

    interface Foo {
    public void execute();
    interface Bar {
    public void execute();
    class Dam implements Foo, Bar {
    public void execute() {
    //Which interface's execute method is being called here?
    How do I make the Damn class have different implemenations for the execute method of the Foo and the Bar interfaces?

    hi,
    //Which interface's execute method is being calledinterfaces' method are neither called to be executed by the JVM because they're not concrete implementation but only signature declaration.
    How do I make the Damn class have different
    implemenations for the execute method of the Foo and
    the Bar interfaces?this can't be done if the signatures are the same, but if they're not, for instance
    public void execute( int i )
    public void execute( String s )
    then you can have two implementation...anyway, what's the point if the signature are the same ? if you really want them to do different things why wouldn't you name them differently ?
    raphaele

  • File does not exist: /java/classes message in Apache error log file

    I am getting several of these messages in the Apache error logfile.
    File does not exist: $JAVA_TOP (this is actually my physical patch for $JAVA_TOP)
    Is it normal to see this messages or some configuration is wrong?
    thanks,
    Azodpe

    Please post the details of the application release, database version and OS.
    I am getting several of these messages in the Apache error logfile.
    File does not exist: $JAVA_TOP (this is actually my physical patch for $JAVA_TOP)Is this the complete error message?
    Is it normal to see this messages or some configuration is wrong?If your application is functioning properly with no issues, then you can ignore those errors.
    Thanks,
    Hussein

  • Urgent: How to map existing java classes

    I created an IDL file where I want to use java.sql.ResultSet. The line is:
    module CMS {
    interface Comm {
    ResultSet search(in string searchString);
    The ResultSet has to be the ResultSet as in java.sql.ResultSet. I tried to add the following code:
    module java {
    module sql {
    interface ResultSet {
    but it doesn't work. Who can help me?

    I think that you can try the type "Any"
    Then after the client receive the any object it can be cast to the object you have.

  • Strategy for mapping existing Java classes to db uing toplink

    I have simple POJO, I used the JDev Class Diagram to add relations to the POJO and then tried to map using Toplink to Database. Is this the correct Strategy? or Should I directly use POJOs without the relationsships, to map to DB using TOPLINK?

    Assuming your schema is as follows
    User table has a primary key ID with other columns
    MentorRel table has two columns (e.g. mentor_id and protege_id) that are FKs pointing to the User.ID ( primary key)
    I would suggest that you normalize your schema further by creating a column in User table called MentorID which will be a self referencing FK. This will automatically capture your 1:M relationship between a Mentor and Protege (as a User can be a Mentor or a Protege). You will also get rid of the MentorRel table this way.
    Once you are done, you will be able to map this nicely. Let me know if this does not work.

  • Integrating performance evaluation with existing java code.

    I have a few methods and I want to integrate a custom timer class which will measure the time taken for the method to execute. basically the timer class just starts the time at the start of the method and once the method completes it subtract the final time from the start time to give me total time spent in this method. I was wondering if there's a way by which i can integrate my timer without actually changing my methods.I have to start the timer when the method is going to execute and end the timer once it has finished executing. Any design pattern you think could help me?

    If your topic doesn't change, please stay in your original post.

  • What is wrong with this Java class and method?

    Created a managed bean and following method as shown below.
    public void setEvent(DisclosureEvent disclosureEvent, CoreShowDetail detail) {
    if (disclosureEvent.isExpanded()) {
    detail.setDisclosed(!detail.isDisclosed());
    -- Then integrated above in the following jspx.
    <af:showOnePanel inlineStyle="width:400px;height:300px;"
    binding="#{ShowApanel.showOnePanel1}"
    id="showOnePanel1">
    <af:showDetailItem text="ADF Faces Components"
    binding="#{ShowApanel.showDetailItem3}"
    id="showDetailItem3" disclosureListener="#{ShowApanel.setEvent}">
    <af:panelHeader text="ADF Faces Components First Child"
    binding="#{ShowApanel.panelHeader6}"
    id="panelHeader6"/>
    <af:panelHeader text="ADF Faces Components Second Child"
    binding="#{ShowApanel.panelHeader5}"
    id="panelHeader5"/>
    </af:showDetailItem>
    <af:showDetailItem text="Architecture"
    binding="#{ShowApanel.showDetailItem2}"
    id="showDetailItem2"
    disclosureListener="#{ShowApanel.setEvent}">
    <af:panelHeader text="Architecture First Child"
    binding="#{ShowApanel.panelHeader4}"
    id="panelHeader4"/>
    <af:panelHeader text="Architecture Second Child"
    binding="#{ShowApanel.panelHeader3}"
    id="panelHeader3"/>
    </af:showDetailItem>
    </af:showOnePanel>
    THE ISSUE:[b]
    I am still not able to programmatically disclose or undisclose the panel component.
    Where am I going wrong? Please help.
    Thanks,
    Ruchir

    Hello Frank,
    I put several print statments but none of them is executing on browser. Does this mean that the method is not being called even once?
    public void setEvent(DisclosureEvent disclosureEvent, CoreShowDetail detail) {
    System.out.println("HelloServer Exiting ...");
    if (disclosureEvent.isExpanded()) {
    System.out.println("HelloServer Exiting1 ...");
    // detail.setDisclosed(!detail.isDisclosed());
    System.out.println("HelloServer Exiting2 ...");
    Thanks,
    Ruchir

  • Accessing Java Class using JNDI

    Hi,
    I am looking for a way for accessing a java class (non-ejb) and invoking a method in it using JNDI.
    Thanks

    See if the follwing helps u
    1).implement Referencable interface for your java class. Implement serialize interface also.
    2).Referencable interface has a methd referencable() which will be invoked by JNDI naming system when a lookup is made by client.
    3) in referencable method create a Refrence object.(Reference is a api class).This Reference object can be created to contain a lot of info about the remote obj u have registered. In that u can say the class that be used to create your client side stub.
    4).now when client does a lookup, jndi creates a stub using Reference object and sends it to client.
    5)the methods now u call gets passed on to actual machine running ur remote object

Maybe you are looking for

  • Vendor Replication with Foriegn Currency

    Hi, I am with SRM 4.0 & Extended Classic. I have one backend purchase organization and one SRM purchase Organization. I created Vendor in ECC with EUR & backend purchase org. I replicated Vendor with Foriegn Courency and when carrying out sourcing ap

  • Micro USB cable

    Would someone give me a link or model number for the "micro USB cable" that specifically goes from the Apple TV 2/3 gen to a MacBook Pro 13 2012? Thanks!

  • My Airport connection drops whenever the Mac sleeps or reboots

    My iBook on the same network doesn't do this. I guess it's a settingI'venot got right, rather than a fault as such. Any ideas? Thanks iMac Dual Core   Mac OS X (10.4.8)  

  • Remove Application Builder while creating  workspace in Apex

    hi, am using apex in 11g database,am creating a workspace but it contain application Builder,Sql Workshop and Utilities.. My objective is i want only sql workshop no need Application builder and utilities while creating workspace in Oracle Apex. guid

  • How to setup auto dim, when light darkens

    when i went to the Mac Store, the guy working there showed me this auto dim feature, that when the light around the laptop(environment) darkens the laptop gets brighter and the keyboard lights up. i just bought my laptop and got it today and i would