I've got an XML file that contains sections that start with a filename:
<madcapfile filename="C:\1\Outputpath\The 7% solution.xlf">
Each section must be saved to an individual file. This is my XSLT:
<xsl:template match="madcapfile">
<xsl:variable name="file1" select="concat('file:///',@filename)"/>
<xsl:variable name="file2" select="encode-for-uri($file1)"/>
<xsl:variable name="file3" select="concat('file:///',replace(@filename,'%','%25'))"/>
<xsl:result-document method="xml" href="{$file2}">
<xsl:apply-templates select="node()"/>
</xsl:result-document>
</xsl:template>
The variables file1, file2, file3 are my attempts so far.
Variable file1 creates files in the correct locations for all files except those with a % in the filename.
Variable file3 creates files in the correct locations for all files, so this is a working solution.
Using variable file2 gives an error: the XSLT processor (Saxon 9.7) tries to write files to
C:\Path-to-XSLT\C:\1\Outputpath\The 7% solution.xlf
i.e. it looks like encode-for-uri treats its input as a relative path even though it starts with "C:\"
I've also tried adding "file:///" to the start of the path, that does not change the behavior of encode-for-uri.
Is there a way to force encode-for-uri to treat its input as an absolute path?