<?xml version="1.0" encoding="UTF-8"?>
You might be missing the version attribute from one of the lines above.
Ed
Kevin O'Neill Stoll <kevinostoll@yahoo.com> wrote:
I'm having trouble with an xml transformation. I'm getting
an error when I attempt to create a new object using a
factory object, error is:
javax.xml.transform.TransformerException: stylesheet
requires attribute: version
Seemingly, you would suspect that I have failed to provide
the version attribute in the stylesheet but that is not the
case. I have spent some time on the web searching for
others with the same problem. Ironically enough, there are
lots of people with the same problem but there are not many
solutions.
Anyway, here is my code.
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import
javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import java.io.IOException;
import java.io.StringReader;
public class Transform {
private DocumentBuilder docbuilder;
private Document document;
public Transform() {
System.out.println( "Transform.Transform" );
DocumentBuilderFactory dbfactory =
DocumentBuilderFactory.newInstance();
try {
dbfactory.setNamespaceAware( false );
docbuilder = dbfactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
public void transform( String xmlDoc, String xslPath )
{
System.out.println( "Transform.transform" );
try {
document = docbuilder.parse( new InputSource(
new StringReader( xmlDoc ) ) );
Source style = new StreamSource( xslPath );
TransformerFactory transFactory =
TransformerFactory.newInstance();
//THE ERROR OCCURS HERE
Transformer transformer =
transFactory.newTransformer( style );
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
}
}
TIA,
=====
Kevin Stoll
http://kevinstoll.org
OpenSource Software...FREE!
Angering Bill Gates...priceless.
============================================================
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com