[oXygen-user] Problem with Saxon's EXPath/file:exists on Mac

George Cristian Bina george at oxygenxml.com
Sun Mar 23 05:44:32 CDT 2014


Hi Stefan,

In that case then I believe it is an issue that should be reported 
against Saxon. Let me know if you want to report the problem to 
Saxonica, otherwise we will report it.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 3/23/14, 11:31 AM, Stefan Krause wrote:
> Hi George,
>
> thanks for your quick response. It provides a useful workaround, but:
>
>> […] You pass an URI while that expects a file path. […]
>
>  From The EXpath-Spec [1]:
>
> »An implementation must accept absolute and relative UNIX/Linux and
> Windows paths as well as absolute file URIs.«
>
> So I think it is OK to provide an absolute URI for the parameter.
>
>
> BTW: My attempt to solve the issue in a more general way
> was file:path-to-native(), but it resolves the URI wrong.
> file:path-to-native("file:/Users/Stf/Documents/trash/file-exists.xsl")
> evaluates to »/Applications/oxygenXML
> 15.2/Users/Stf/Documents/trash/file-exists.xsl« (tested with the
> stylesheet [2]). Maybe this is the same problem as with file:exists().
>
> Best regards,
>
> Stefan
>
> [1] http://expath.org/spec/file#file-paths
>
> [2] Modified test stylesheet:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:file="http://expath.org/ns/file"
> version="2.0"
> exclude-result-prefixes="#all">
> <xsl:templatematch="/">
> <xsl:variablename="file"as="xs:string"select="string(document-uri(/))"/>
> <root>
> <test>
> <xsl:value-ofselect="$file"/>: <xsl:value-ofselect="file:exists($file)"/>
> </test>
> <xsl:variablename="file2"as="xs:string"select="substring-after($file,
> 'file:')"/>
> <test>
> <xsl:value-ofselect="$file2"/>: <xsl:value-ofselect="file:exists($file2)"/>
> </test>
> <xsl:variablename="file3"as="xs:string"select="file:path-to-native($file)"/>
> <test>
> <xsl:value-ofselect="$file3"/>: <xsl:value-ofselect="file:exists($file3)"/>
> </test>
> </root>
> </xsl:template>
> </xsl:stylesheet>
>
> Result:
>
> <root>
> <test>file:/Users/Stf/Documents/trash/file-exists.xsl: false</test>
> <test>/Users/Stf/Documents/trash/file-exists.xsl: true</test>
> <test>/Applications/oxygenXML
> 15.2/Users/Stf/Documents/trash/file-exists.xsl: false</test>
> </root>
>
> Am 23.03.2014 um 08:43 schrieb George Cristian Bina
> <george at oxygenxml.com <mailto:george at oxygenxml.com>>:
>
>> Hi Stefan,
>>
>> I think you are not passing the expected parameter to the file:exists
>> function. You pass an URI while that expects a file path. For example,
>> if I remove the "file:" part of the URI from the stylesheet then it
>> returns true on my Mac:
>>
>> <xsl:stylesheet
>>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>  xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>  xmlns:file="http://expath.org/ns/file"
>>  version="2.0"
>>  exclude-result-prefixes="#all">
>>  <xsl:template match="/">
>>    <xsl:variable name="file" as="xs:string"
>> select="string(document-uri(/))"/>
>>    <test>
>>      <xsl:value-of select="$file"/>: <xsl:value-of
>> select="file:exists(substring-after($file, 'file:'))"/>/<xsl:value-of
>> select="doc-available($file)"/>
>>    </test>
>>  </xsl:template>
>> </xsl:stylesheet>
>>
>> -->
>>
>> <test>file:/Users/george/test/test.xsl: true/true</test>
>>
>> Best Regards,
>> George
>> --
>> George Cristian Bina
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> On 3/22/14, 3:15 PM, Stefan Krause wrote:
>>> Hi all,
>>>
>>> I have the following stylesheet:
>>>
>>> <xsl:stylesheet
>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> xmlns:file="http://expath.org/ns/file"
>>> version="2.0"
>>> exclude-result-prefixes="#all">
>>> <xsl:templatematch="/">
>>> <xsl:variablename="file"as="xs:string"select="string(document-uri(/))"/>
>>> <test>
>>> <xsl:value-ofselect="$file"/>:
>>> <xsl:value-ofselect="file:exists($file)"/>/<xsl:value-ofselect="doc-available($file)"/>
>>> </test>
>>> </xsl:template>
>>> </xsl:stylesheet>
>>>
>>> I run it from OxygenXML with the stylesheet itself as the input document.
>>>
>>> I expected the result is
>>>
>>> <test>file:/Users/Stf/Documents/trash/file-exists.xsl: true/true</test>
>>>
>>> but actually it is
>>>
>>> <test>file:/Users/Stf/Documents/trash/file-exists.xsl: false/true</test>
>>>
>>> Since I get the expected result from Oxygen on Windows, I think there is
>>> something wrong with the Mac implementation.
>>>
>>> I use XML Editor 15.2, build 2014022718 on Mac OS X 10.9.2 (13C64) with
>>> java.version=1.6.0_65. The transformation scenario uses Saxon-PE, and
>>> Saxon’s »-ext«-option is checked. There are no errors during the
>>> transformation.
>>>
>>> Any hints to get the right result?
>>>
>>> Thank you,
>>>
>>> Stefan
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> oXygen-user mailing list
>>> oXygen-user at oxygenxml.com
>>> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>>>
>
>
>
> _______________________________________________
> oXygen-user mailing list
> oXygen-user at oxygenxml.com
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>


More information about the oXygen-user mailing list