1
votes

I'm trying to convert a csv file into a xml file with Saxon 9. But I have a problem when I try to check existence and read a csv file with the xslt functions: unparsed-text-available(), unparsed-text()

They work fine with a local file, but when I pass a remote file as parameter, unparsed-text-available() return false.

For example, when I pass "D:\test\test.csv", it works. when I pass "\\remote-computer\test\test.csv", it cannot find it.

Here is a part of my xsl file:

<xsl:template match="/" name="main">
  <xsl:choose>
    <xsl:when test="unparsed-text-available($pathToCSV)">
        <xsl:variable name="csv" select="unparsed-text($pathToCSV)"/>                    
            ....
    </xsl:when>
    <xsl:otherwise>
        <xsl:text>Cannot locate : </xsl:text><xsl:value-of select="$pathToCSV"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

It seems that document() can read remote file, but only for xml files.

Do you know some other functions that I can use for this case? In xslt or saxon?

1
Would it be an option to just map the network share as a drive?Jukka Matilainen
Thanks for your reply, the file path is generated automatically with two backslash by someone else. I will consider this if there is no other solutions.houghstc

1 Answers

0
votes

You'll have to turn that path into a valid URI.

Something like:

unparsed-text(concat('file://',translate($pathToCSV,'\','/')))