Description: Very Simple Java XSLT Transformation
IDE: Eclipse
JARs:
serializer.jar
xalan.jar
xercesImpl.jar
xml-apis.jar
xsltc.jar
XSLT File:
<xsl:variable name="BRM40Mapping"><BRM40Root> <PackageType> <Old>TY123</Old> <New>er45</New> </PackageType></BRM40Root></xsl:variable>
<xsl:template match="wshi"> <xsl:variable name="OldValue"><xsl:value-of select="."/></xsl:variable> <wshi>I found it:<xsl:value-of select="."/><Old><xsl:value-of select="."/></Old> <NewNode> <xsl:value-of select="exsl:node-set($BRM40Mapping)/BRM40Root/PackageType[Old=$OldValue]/New"/> </NewNode> </wshi></xsl:template>
SimpleTransform.java
String sXML ="
String sOutput;
StringWriter objStringWriter = new StringWriter();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(filename));
transformer.transform(new StreamSource(new StringReader(sXML)), new StreamResult(objStringWriter));
sOutput = objStringWriter.toString();System.out.println("************* StringWriter *************" + sOutput);
No comments:
Post a Comment