XalanJ2
  1. XalanJ2
  2. XALANJ-2386

tranforming a StreamResult constructed with a File object for a path containing namespaces fails

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.7
    • Fix Version/s: 2.5
    • Component/s: XSLTC
    • Labels:
      None
    • Environment:
      Windows XP, Sun J2SE 5 or Harmony 533500

      Description

      hi,

      The behaviour of the code snippet below is different depending on whether you use XalanJ 2.7.0 or the inbuilt equivalent in Sun Java 5.

      If you construct a StreamResult with a java.io.File containing spaces in the name, then a wrapped FileNotFoundException is thrown because it looks for a filename with the spaces encoded as "%20"

      We hit this as part of the Eclipse CDT 4.0 project:
      https://bugs.eclipse.org/bugs/show_bug.cgi?id=194359

      thanks,
      Andrew

      ------------- Snippet

      import java.io.File;

      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.transform.TransformerException;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.dom.DOMSource;
      import javax.xml.transform.stream.StreamResult;

      import org.w3c.dom.Document;

      public class Main {
      public static void main(String[] args) throws Exception {
      try

      { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); DOMSource domSource = new DOMSource(d); StreamResult res = new StreamResult(new File("C:/A B/test.xml")); TransformerFactory.newInstance().newTransformer().transform(domSource, res); }

      catch(TransformerException te) {
      if(te.getMessage().indexOf("%20")!=-1)

      { System.out.println("XalanJ 2.7.0"); }

      else

      { System.out.println("Ok"); // assuming "C:/A B/" does not exist }

      }
      }
      }

        Issue Links

          Activity

          Andrew Ferguson created issue -
          Henry Zongaro made changes -
          Field Original Value New Value
          Resolution Cannot Reproduce [ 5 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Andrew Ferguson made changes -
          Status Resolved [ 5 ] Reopened [ 4 ]
          Resolution Cannot Reproduce [ 5 ]
          Alexey Petrenko made changes -
          Link This issue blocks HARMONY-4297 [ HARMONY-4297 ]
          Mark Thomas made changes -
          Workflow jira [ 12407215 ] Default workflow, editable Closed status [ 12570629 ]
          Mark Thomas made changes -
          Workflow Default workflow, editable Closed status [ 12570629 ] jira [ 12593838 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Andrew Ferguson
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:

                Development