By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

JAXB, XSLT comparison

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>>>>> "Sony" == Sony Antony <so********@hotmail.com> 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:otherwise>
<!-- element does not exist, do what is needed -->
</xsl:otherwise>
</xsl:choose>
--
Arto V. Viitanen av@cs.uta.fi
University of Tampere, Department of Computer and Information Sciences
Tampere, Finland http://www.cs.uta.fi/~av/
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.