You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Christopher Hull <ch...@mediagate.com> on 2001/03/01 21:43:34 UTC
Counting StyleSheep [was XalanJ200 Stylesheet requires attribute: version]
I've got some more detail on this bug. Turns out it only happens when
you create a Transformer from a SourceDOM.
Here's the code, taken from the DOM2DOM sample.
public static void main(String[] args)
throws TransformerException, TransformerConfigurationException,
FileNotFoundException,
ParserConfigurationException, SAXException, IOException
{
TransformerFactory tFactory = TransformerFactory.newInstance();
if(tFactory.getFeature(DOMSource.FEATURE) &&
tFactory.getFeature(DOMResult.FEATURE))
{
//Instantiate a DocumentBuilderFactory.
DocumentBuilderFactory dFactory =
DocumentBuilderFactory.newInstance();
//Use the DocumentBuilderFactory to create a DocumentBuilder.
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
// Process the stylesheet StreamSource and generate a Transformer.
// Transformer transformer = tFactory.newTransformer(new
StreamSource("birds.xsl"));
// This will throw a misleading exception.
Document xslDoc = dBuilder.parse("birds.xsl");
System.out.println("\n\n!!!!!!!!! About to throw a vast Exception
!!!!!!!!!!!!!!\n\n");
Transformer transformer = tFactory.newTransformer(new DOMSource(xslDoc) );
//Use the DocumentBuilder to parse the XML input.
Document doc = dBuilder.parse("birds.xml");
// Use the DOM Document to define a DOMSource object.
DOMSource domSource = new DOMSource(doc);
// Set the base URI for the DOMSource so any relative URIs it
contains can
// be resolved.
domSource.setSystemId("birds.xml");
// Create an empty DOMResult for the Result.
DOMResult domResult = new DOMResult();
// Perform the transformation, placing the output in the DOMResult.
transformer.transform(domSource, domResult);
//Instantiate an XML serializer and use it to serialize the output
DOM to System.out
// using a default output format.
Serializer serializer = SerializerFactory.getSerializer
(OutputProperties.getDefaultMethodProperties("xml"));
serializer.setOutputStream(System.out);
serializer.asDOMSerializer().serialize(domResult.getNode());
}
else
{
throw new org.xml.sax.SAXNotSupportedException("DOM node
processing not supported!");
}
}
file:///W:\xalan-j_2_0_0\samples\DOM2DOM\javax.xml.transform.dom.DOMSource;
Line
0; Column 0; Exception in thread "main"
javax.xml.transform.TransformerConfigur
ationException: stylesheet requires attribute: version
at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Tran
sformerFactoryImpl.java:650)
at
com.mediagate.jini.accessor.xsl.XSLAccessor.main(XSLAccessor.java:637
)
---------
javax.xml.transform.TransformerConfigurationException: stylesheet
requires attri
bute: version
at
org.apache.xalan.processor.TransformerFactoryImpl.processFromNode(Tra
nsformerFactoryImpl.java:217)
at
org.apache.xalan.processor.TransformerFactoryImpl.processFromNode(Tra
nsformerFactoryImpl.java:266)
at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(Transf
ormerFactoryImpl.java:735)
at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Tran
sformerFactoryImpl.java:635)
at
com.mediagate.jini.accessor.xsl.XSLAccessor.main(XSLAccessor.java:637
)
---------
(Exception repeats for several pages)
Paul_Dick@lotus.com wrote:
> Chris,
>
> The stylesheep *has* a version attribute.
> <?xml version="1.0"?>
> <xsl:styleshet xmlns:xsl="http/blah/1999.." version="1.0">
>
> Just make sure that your stylesheep, is not a styleshet, but a stylesheet,
> with the
> appropriate attributes e.g.
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
> ="1.0">
>
> Paul
--
Christopher Hull
Engineering Group Manager, Senior Software Architect
Mediagate Inc.
iPost Card http://web.mediagate.com/chris.hull
iPost Voice 408 261 7201
email chris.hull@mediagate.com