• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Whitespace Exception

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To me this seems to be a more generic XSLT question and is not specific to XML Cert exam. I am moving it to the XML & Related Technologies Forum.

Please continue the discussion in that forum. In future, please use the most appropriate forum.
Thanks.

- m
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic