JAXB, XSLT comparison

Discussion in 'Java' started by Sony Antony, Jul 17, 2003.

  1. Sony Antony

    Sony Antony Guest

    We have a situation wherin we should translate the incoming XML based
    on one schema to the outgoing XML that is based on another schema.
    Since both input and output are both XML, XSLT was the natural
    preference.

    But there was a requirement that demanded a part of the generated XML
    to be different depending on whether an element was present or not in
    the incoming XML. Since we were only beginning with XML, we couldn t
    find the Xpath xsl:if combination that will generate this logic. ( Can
    somebody help me here, though that is not the main topic of this
    posting )

    So somebody came up with JAXB. We changed the program so that the
    incoming XML was converted to Java objects using JAXB. Then there was
    the ‘if' statement in java and the result was converted to XML again
    using JAXB.
    At this time this was thought to be an inefficient ad hoc way of
    getting the task done. But then I read more about JAXB and came to
    know that JAXB generated code can be as fast as a SAX parser.
    Now it appears to me that XSLT might be using DOM parser internally
    and that it might be actually slower than the JAXB way.
    I know I should do an actual performance comparison to reach any
    conclusions. But can somebody theoretically compare which of these
    methods will be faster.

    Thanks a lot for reading
    --sony
     
    Sony Antony, Jul 17, 2003
    #1
    1. Advertising

  2. >>>>> "Sony" == Sony Antony <> writes:

    Sony> We have a situation wherin we should translate the incoming XML based
    Sony> on one schema to the outgoing XML that is based on another schema.
    Sony> Since both input and output are both XML, XSLT was the natural
    Sony> preference.

    Sony> But there was a requirement that demanded a part of the generated XML
    Sony> to be different depending on whether an element was present or not in
    Sony> the incoming XML. Since we were only beginning with XML, we couldn t
    Sony> find the Xpath xsl:if combination that will generate this logic. ( Can
    Sony> somebody help me here, though that is not the main topic of this
    Sony> posting )

    XSLT's xsl:if is not like ifs in general programming languages, since it does
    not come with xsl:else. Instead, you should use xsl:choose, like

    <xsl:choose>
    <xsl:when test="nameoftheelement">
    <!-- do what you need with the element -->
    </xsl:when>
    <xsl:eek:therwise>
    <!-- element does not exist, do what is needed -->
    </xsl:eek:therwise>
    </xsl:choose>


    --
    Arto V. Viitanen
    University of Tampere, Department of Computer and Information Sciences
    Tampere, Finland http://www.cs.uta.fi/~av/
     
    Arto V. Viitanen, Jul 18, 2003
    #2
    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. Stylus Studio
    Replies:
    0
    Views:
    690
    Stylus Studio
    Aug 3, 2004
  2. Sony Antony

    JAXB, XSLT comparison

    Sony Antony, Jul 17, 2003, in forum: XML
    Replies:
    1
    Views:
    3,975
    Arto V. Viitanen
    Jul 18, 2003
  3. Benjamin Hillsley
    Replies:
    3
    Views:
    1,692
    Dimitre Novatchev
    Sep 25, 2003
  4. ted
    Replies:
    1
    Views:
    626
    Laurens
    Jan 26, 2004
  5. Deepu
    Replies:
    1
    Views:
    245
    ccc31807
    Feb 7, 2011
Loading...

Share This Page