[xslt] exslt:document cannot save to file names with spaces



The interaction between the URI escaping of the href attribute for the
{http://exslt.org/common}document element type and the actual filename
for output files seems buggy to me.  To summarize my problems, I have
not been able to serialize output into a directory with spaces in its
name, spaces in filenames do not seem to be properly unescaped, and some
directories are automatically created (those without spaces in their
names) while others are not (those with spaces in their names).

First, consider the following XSLT script:

spaces.xsl:
---
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:common="http://exslt.org/common";
                extension-element-prefixes="common">

  <xsl:param name="file_name">has spaces/test.xml</xsl:param>

  <xsl:template match="/">
    <common:document href="{$file_name}">
      <test/>
    </common:document>
  </xsl:template>
</xsl:stylesheet>
---

If I run this script in a directory with a "has spaces" subdirectory, I
get the following behavior:

---
$ xsltproc spaces.xsl spaces.xsl
I/O error : No such file or directory
runtime error: file spaces.xsl line 9 element document
xsltDocumentElem: unable to save to has%20spaces/test.xml
no result for spaces.xsl
---

I expected the file "text.xml" to have been created in the "has spaces"
directory.

Now, changing the file name parameter, we see that a relative file is
escaped but not unescaped upon serialization:

---
$ xsltproc --stringparam file_name "has spaces.xml" spaces.xsl \
spaces.xsl
$ ls
has spaces  has%20spaces.xml  spaces.xsl
---

I expected the file "has spaces.xml" to have been created.

Finally, changing the file name parameter again, we can see that
directories are automatically created as necessary when they do not have
spaces, but not when they do:

---
$ xsltproc --stringparam file_name "nospaces/test.xml" spaces.xsl \
spaces.xsl
$ ls nospaces
test.xml
$ xsltproc --stringparam file_name "more spaces/test.xml" spaces.xsl \
spaces.xsl
I/O error : No such file or directory
runtime error: file spaces.xsl line 9 element document
xsltDocumentElem: unable to save to more%20spaces/test.xml
no result for spaces.xsl
---

I expected both the "nospaces" and "more spaces" directories to be
created, each with the (same) test.xml file in it.

My versions of the various software pieces are as follows:

---
$ xsltproc --version
Using libxml 20617, libxslt 10112 and libexslt 810
xsltproc was compiled against libxml 20617, libxslt 10112 and libexslt
810
libxslt 10112 was compiled against libxml 20617
libexslt 810 was compiled against libxml 20617
---

Are my expectations with respect to the URI escaping/unescaping wrong,
or are there bugs here?  If the latter, I'd be happy to file one or more
bug reports.

Take care,

    John L. Clark

Attachment: pgpgdLrHHg3cJ.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]