The rejected URI (or rather, non-URI)  is
C:\Documents and Settings\JG\Desktop\try\my.xml.xf
and since you are constructing the URI for the result file by adding ".xf" to something, my guess is that its the result URI that it's complaining about.
Try something like
new StreamResult(x_i .toURI().toString() + ".xf")


Michael Kay

 2009 18:39
Subject: [saxon] Trouble getting file naming syntax correct


I've built a little Java application that let's the user browse to an XML file, select it, then the XML file is transformed via a static XSL file. Everything has been working fine, until I needed to use XSLT 2.0. So I had to switch to Saxon 9, instead of the *standard* TransformerFactory XSLT processor. (Assuming my classpath is all good) It seems like Saxon does not care for my file naming syntax. Here's the portion that has the trouble:

--snip --
  if(result == JFileChooser.APPROVE_OPTION) {

    String xml_Input_File = (jfilechooser.getSelectedFile().getPath());

      File InputFile = new File(xml_Input_File);
      File xfXSLTfile = new File("xml2xf.xsl");
      // just added this extra step 'x_i' to try to correct the
      // '' - it seemed to do no harm, nor help
      File x_i = new File(InputFile.toURI());
      Source xmlIn = new StreamSource(x_i);
      Source xfRoundTripXSL = new StreamSource(xfXSLTfile);


      TransformerFactory transFact =

      try { 
            Transformer trans = transFact.newTransformer(xfRoundTripXSL);
            trans.transform(xmlIn, new StreamResult(x_i + ".xf"));
   catch(Exception ioe) { 
    System.err.println("Could not transform; malformed? ..." + x_i);

--/snip --

I ran it in verbose mode, and got some telling errors (I'm just not experienced enough to know exactly what they are telling me). It clearly finds the files (making reference to actual elements in the source, "processing /rooty/p[1]" and actual code in the XSLT, "  at xsl:apply-templates (file:/C:/presentations/D-Europe-2009/presentation-and-demo/newD-XF-rt/xml2xf.xsl#11)"):

--snip --
Error at xsl:copy on line 10 of xml2xf.xsl: Illegal character in opaque part at index 2: C:\D
ocuments and

[Loaded net.sf.saxon.trace.ContextStackIterator from file:/C:/presentations/D
[Loaded net.sf.saxon.trace.ContextStackFrame from file:/C:/presentations/D-Eu
[Loaded net.sf.saxon.trace.ContextStackFrame$ApplyTemplates from file:/C:/presen

  at xsl:apply-templates (file:/C:/presentations/D-Europe-2009/presentation-a

[Loaded net.sf.saxon.tinytree.PrecedingSiblingEnumeration from file:/C:/presenta

     processing /rooty/p[1]

[Loaded net.sf.saxon.trace.ContextStackFrame$BuiltInTemplateRule from file:/C:/p

  in built-in template rule

[Loaded net.sf.saxon.trace.ContextStackFrame$CallingApplication from file:/C:/pr

Could not transform; malformed? ...C:\Documents and Settings\JG\Desktop\try\
--/snip --

I'll skip the plea of "couldn't find it in the FAQ" and "forgive me for being a newby," and just ask if anyone can tell what causes this misfire.