[jdom-interest] TransformerException: stylesheet requires attribute: version

Malachi de AElfweald malachi at tremerechantry.com
Fri Oct 11 04:10:25 PDT 2002


Thanks to everyone. I seem to have it fixed.

As a side note, very odd thing happened.
When I point Opera at my xml file:
	http://localhost/myfile.xml
it comes back as garbage
doing View:Source, and it all looks OK

change it to
	http://localhost/myfile.xml=myfile.html
and it looks file

I think it must be sending text/xml instead of text/html after doing the conversion...
not sure...

But, thanks to everyone who helped me get my conversions correct.

For posterity, a few of my routines mixed together...
this is pretty much doing an XSL conversion for the local
Document, and then preparing it for Non-Blocking I/O use.
It could be condensed, but left open for ease of reading.

	public ByteBuffer transform(InputStream stylesheet)
	throws JDOMException
	{
		try{
			SAXBuilder builder = new SAXBuilder();
			Document styleDoc = builder.build(stylesheet);
			JDOMSource source = new JDOMSource(styleDoc);
			Transformer transformer = TransformerFactory.newInstance().newTransformer(source);
			JDOMResult result = new JDOMResult();
			transformer.transform(new JDOMSource(doc), result);
			CharArrayWriter writer = new CharArrayWriter();
			XMLOutputter xout = new XMLOutputter();
			xout.output(result.getDocument(), writer);
			writer.flush();
			char[] content=writer.toCharArray();
			CharBuffer chars = CharBuffer.allocate(content.length);
			chars.put(content);
			chars.flip();
			Charset isolatin = Charset.forName("ISO-8859-1");
			ByteBuffer buffer = isolatin.newEncoder().encode(chars);
			ByteBuffer directBuffer = ByteBuffer.allocateDirect(buffer.limit());
			directBuffer.put(buffer);
			return directBuffer;
	    }catch (Exception e) {
	    	throw new JDOMException("XSLT Transformation failed", e);
	    }
	}






More information about the jdom-interest mailing list