See the following for the basis of tranformations
Main Topics
Browse All TopicsI am a lead systems engineer that has been away from heads-down coding for a couple of years now so my recollection is a bit foggy.
I have a coder who is developing in Java and needs to apply an XSL Transform to an XML string before posting the string to a web service. As this coder has never used XML/XSLT before I want to keep this as simple as possible.
For the sake of an example, suppose the coder has:
String xmlText = "<XML><ROW><ORGID>Business
I will have him write an XSLT file that simply changes the names of the fields so that the resultant string is:
String postTransform "<XML><ROW><BusinessUnit>B
I remember enough of the XSLT code to be useful, but my background was in C# and C++, not Java -- so I'm at a bit of a loss on the most efficient method for opening and applying the XSLT document to the XML string.
I really just need something quick, dirty and efficient. I would prefer to not have to incorporate the entire XMLDOM architecture to apply a simple transform.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi!
Here are some XML Transform examples you can look at
http://www.java2s.com/Code
And here are some other XML examples
http://www.java2s.com/Code
Hope this helps.
Regards,
Tomas Helgi
To clarify:
I *already* understand XML and XSLT - that is not the issue.
I have an XML string in JAVA that I want to apply the XSLT to while "on the fly".
I don't want to create an XML document and attach the XSLT to it. I don't want to have to spool anything off to the physical drive.
In fact, we may be using this XSLT for a relatively large volume of XML text in a batch form. Ideally I'd like to be able to cache the XSLT text in memory and perform the transforms without spooling everything out to the heavy XMLDOM class.
use the following (to create dom) in conjunction with what I posted in the link above
http://helpdesk.objects.co
you can load the xsl from memory using a similar technique ie change the source
Hi!
The javax.xml.transform.stream
http://www.java2s.com/Code
and the API
http://java.sun.com/j2ee/1
has a InputStream as input in one of it's constructors.
That way you can take the "on the fly"-data and pass it to the Transformation class as a byte-stream
and transform it on the fly. :)
Hope this helps.
Regards,
Tomas Helgi
>As this coder has never used XML/XSLT before I want to keep this as simple as possible.
Does he use JSP ? If yes, then he could use JSTL XML tags Once you set things up, he could use something like
<%@ taglib prefix="c" uri="http://java.sun.com/j
<%@ taglib prefix="x" uri="http://java.sun.com/j
<c:import url="text.xml" var="doc" />
<c:import url="xslTest.xsl" var="xsl" />
<x:transform xml="${doc}" xslt="${xsl}" />
See
http://www.ibm.com/develop
http://www.roseindia.net/j
Business Accounts
Answer for Membership
by: MRomaniPosted on 2009-11-05 at 11:47:04ID: 25753156
Maybe these sites can be of some help:
i/kit/2004 k/ctl257/J avaXSLT/ Ch 05.html avaworld/j w-09-2000/ jw-0908- xp ath.html adetails/j ava-0407.h tml lly/xml/jx slt/ch01_0 1.htm
http://www.ling.helsinki.f
http://www.javaworld.com/j
http://www.rgagnon.com/jav
http://docstore.mik.ua/ore
hope that helps!