Project

Profile

Help

Bug #2037

closed

EXPath file:path-to-native and file:exits() on Mac OS 10.9

Added by Stefan Krause about 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
EXSLT extensions
Sprint/Milestone:
-
Start date:
2014-03-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Saxon's file:path-to-native() from the EXpath File module resolves absolute URIs wrong on Mac. Given the 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:template match="/">

	<xsl:variable name="file" as="xs:string" select="string(document-uri(/))"/>

	<root>

		<test>

			<xsl:text>document-uri(/): </xsl:text><xsl:value-of select="$file"/>: <xsl:value-of select="file:exists($file)"/>

		</test>

		<xsl:variable name="file2" as="xs:string" select="substring-after($file, 'file:')"/>

		<test>

			<xsl:text>native path: </xsl:text><xsl:value-of select="$file2"/>: <xsl:value-of select="file:exists($file2)"/>

		</test>

		<xsl:variable name="file3" as="xs:string" select="file:path-to-native($file)"/>

		<test>

			<xsl:text>file:path-to-native(): </xsl:text><xsl:value-of select="$file3"/>: <xsl:value-of select="f($file3)"/>

		</test>

	</root>

</xsl:template>

</xsl:stylesheet>

the result is:

<test>document-uri(/): file:/Users/Stf/Documents/trash/file-exists.xsl: false</test>

<test>native path: /Users/Stf/Documents/trash/file-exists.xsl: true</test>

<test>file:path-to-native(): /Users/Stf/Documents/trash/Users/Stf/Documents/trash/file-exists.xsl: false</test>

Command line:

java -classpath saxon9ee.jar net.sf.saxon.Transform -s:file-exists.xsl -xsl:file-exists.xsl -o:trash-cl.xml

System information:

Saxon-EE 9.5.1.4J

java version "1.7.0_11"

Java(TM) SE Runtime Environment (build 1.7.0_11-b21)

Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

running on Mac OS X 10.9.2 (13C64)

I suppose that the wrong results of file:exists() are the result of some internal problems with resolving the path as shown by file:path-to-native().

On Windows the results are OK.


Files

file-exists.xsl (989 Bytes) file-exists.xsl Stefan Krause, 2014-03-23 17:43
trash-cl.xml (329 Bytes) trash-cl.xml Stefan Krause, 2014-03-23 17:43
Actions #1

Updated by Michael Kay about 10 years ago

  • Category set to EXSLT extensions
  • Assignee set to John Lumley
  • Priority changed from Low to Normal
Actions #2

Updated by John Lumley about 10 years ago

  • Status changed from New to In Progress

The issue arose from removal of the 'file:/' or 'file:///' prefix on Unixen, the resulting path being detected as relative (no leading '/') and then resolved against 'current directory'. (On Windows the '[A-Za-z]:' prefix remaining meant the path was recognised as absolute.) Altered to check if the path is i) a valid filesystem path (e.g. '/Users' or 'C:/Users'), ii) a valid absolute URI (i.e. 'file:/....'), when the File is constructed via the URI, or iii) if relative, constructed relative to the working directory as before.

Patches applied to the 9.5 and 9.6 branches. Possible test cases will be added to the EXPath file tests on GitHub

Actions #3

Updated by O'Neil Delpratt over 9 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100
  • Found in version changed from Saxon-EE 9.5.1.4J to 9.5
  • Fixed in version set to 9.5.1.5

Bug fixed and applied in the maintenance release 9.5.1.5.

Please register to edit this issue

Also available in: Atom PDF