Which do I use, JAX, DOM, JDOM?

Discussion in 'XML' started by john smith, Feb 26, 2005.

  1. john smith

    john smith Guest

    hello,

    I am having to read an XML document and grab some elements and attributes
    and then convert that to anther XML document.

    Which should I use? JAX, DOM, JDOM?

    I don't really understand the difference and when to use the above.

    Thanks so much.
     
    john smith, Feb 26, 2005
    #1
    1. Advertising

  2. john smith

    Frank Meyer Guest

    hi,

    > I am having to read an XML document and grab some elements and attributes
    > and then convert that to anther XML document.
    >
    > Which should I use? JAX, DOM, JDOM?
    >
    > I don't really understand the difference and when to use the above.


    DOM: language-independent API for accessing XML

    JAXP: API in Java for DOM, SAX, XSLT; part of the J2SE-specification

    JDOM: API in Java with some more features than DOM; not part of J2SE and
    only supported by some parsers

    If you just want to transform one XML-document into another you should
    use XSLT ( http://w3.org/TR/xslt ). If you want to embed this process
    into your own Java-application, you should use JAXP for the Java-part.

    regards
    frank
     
    Frank Meyer, Feb 27, 2005
    #2
    1. Advertising

  3. john smith wrote:

    > I am having to read an XML document and grab some elements and attributes
    > and then convert that to anther XML document.
    >
    > Which should I use? JAX, DOM, JDOM?
    >
    > I don't really understand the difference and when to use the above.


    DOM usually means the W3C DOM specification which is meant to be
    language independent by using some IDL (interface description language)
    to define a tree based API for manipulating XML (and HTML) documents.
    The W3C DOM specification then goes on to define two language bindings,
    one for Java, one for ECMAScript. As the specification should be
    implementable on top of existing implementations and as the API has to
    work with scripting languages with loose typing as well as with
    languages like Java with strong typing the Java binding the W3C suggests
    for the DOM doesn't define any classes but only interfaces to be
    implemented. Where overloading in Java would be possible it is not done
    as overloading in ECMAScript is not possible and the API is meant to be
    consistent in different languages.
    As a result of this many pure or main Java programmers dislike the W3C
    DOM and have implemented Java specific and Java natural DOM APIs, one of
    which is JDOM. But there are others like XOM.
    JAXP is Sun's term for the different XML related Java APIs in the Sun
    Java development kit/JDK, it is mainly an abstraction layer (or even
    several ones) to allow you to use different parsers or DOM
    implementations or XSLT implementations or XPath implementations that
    are around under a common way to create parsers.

    What you should or want to use depends on many criteria, Sun Java 1.4
    and Sun Java 1.5 have W3C DOM support thus if you want to only rely on
    the classes installed by the Sun JDK/JRE then you do not have JDOM for
    instance or XOM. You would need an additional download for that and
    anyone using your software too.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wendy S
    Replies:
    1
    Views:
    6,470
    Darren Davison
    Aug 5, 2003
  2. Karl Uppiano

    Migrating JAX-RPC to JAX-WS

    Karl Uppiano, Dec 15, 2006, in forum: Java
    Replies:
    1
    Views:
    580
    Karl Uppiano
    Dec 15, 2006
  3. Karl Uppiano
    Replies:
    3
    Views:
    679
    Karl Uppiano
    Dec 19, 2006
  4. Replies:
    0
    Views:
    776
  5. Sascha Roth
    Replies:
    2
    Views:
    842
    Sascha Roth
    Jul 3, 2009
Loading...

Share This Page