Can any body help to sort out this problem, When I am trying to transform an XML to another XML using XSLT I am getting the following exception oracle.xml.parser.v2.XMLParserException: Whitespace Exception. My piece of codes are as below .
XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:quipmentGenerator="http://www.oracle.com/XSL/Transform/java/EquipmentGenerator xmlns:TypeGenerator="http://www.oracle.com/XSL/Transform/java/TypeGenerator xmlns:ShelfGenerator="http://www.oracle.com/XSL/Transform/java/ShelfGenerator">
....
</xsl:stylesheet>
JAVA :
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import oracle.xml.parser.v2.*;
public class Transformer
{
public static void main(
String args[]) throws Exception{
String fileName = "abc.xsl", XMLStr = "C:\\dev\\task2\\abc.xml";
XSLProcessor processor = new XSLProcessor();
// you can also use a standard HTTP URL instead of
// the file protocol shown below
// URL xslURL = new URL(fileName);
// instantiate a stylesheet
InputStream xslInput = new FileInputStream(fileName);
XSLStylesheet stylesheet = processor.newXSLStylesheet(xslInput);
DOMParser parser = new DOMParser();
URL xslURL = new URL("file://" + XMLStr);
parser.setPreserveWhitespace(true);
parser.parse(xslURL);
// Preparing the XML document
XMLDocument xml = parser.getDocument();
XMLDocumentFragment result;
result = processor.processXSL(stylesheet, xml);
// create an output document to hold the result
XMLDocument out = new XMLDocument();
// create a dummy document element for the
// output document
out.appendChild(result);
ByteArrayOutputStream outStream = new ByteArrayOutputStream( );
out.print(outStream);
String transformedXML = outStream.toString();
System.out.println(transformedXML);
}
}