Richard Jones wrote:
Hi Folks,

I'm encountering some strange behaviour with file paths when trying to use Xalan (first time user, so perhaps newbie mistake), and I wonder if someone can enlighten me.

I have the following code:

--
TransformerFactory tFactory = TransformerFactory.newInstance();
Reader reader = new FileReader
("/home/richard/workspace/dspace-trunk/ore4j/src/main/resources/rdfxml2rdfa.xsl");
StreamSource xslt = new StreamSource(reader);

Transformer transformer = tFactory.newTransformer(xslt);

String serialisation = rmd.getSerialisation(); serialisation = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + serialisation;

StreamSource rdfxml = new StreamSource(serialisation);
The StreamSource constructor that takes a String argument considers the argument to be a systemID, which is a URL.

ByteArrayOutputStream baos = new ByteArrayOutputStream();
          StreamResult result = new StreamResult(baos);
transformer.transform(rdfxml, result);
--

When I run this I get the following error on the final line (full stack trace at the end of the email):

ERROR: '/home/richard/workspace/dspace-trunk/< (No such file or directory)' ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: /home/richard/workspace/dspace-trunk/< (No such file or directory)'

My stylesheet contains no reference to that path /home/richard/workspace/dspace-trunk; the only place it is referenced in my code at all is in the FileInputStream constructor. Then there is what looks like an errant "<" in the path; I can't see where that might be coming from. The directory /home/richard/workspace/dspace-trunk does exist, as does the xsl file I referenced. I have been able to perform this crosswalk from the command line with xalan, so I know there's no problem there.
The errant "<" is the first byte of the variable "serialization."


Any ideas what I might be doing wrong?  I am using xalan 2.7.0.
I think you need to wrap the String in a StringBufferInputStream.

Dave

Reply via email to