Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@daliboris
Copy link

Fixes issues on Windows machine, where $currentDirectory variable contains path in Windows format, for example C:\Data\Works.

This type of path occurs, for example, in the oXygen XML Editor, where the path is passed to ANT in the inputFile parameter as the editor variable ${cf}.

In Windows, this led to the following error:

ransformation failed. 
Fatal error during transformation using C:\Users\Boris\AppData\Roaming\com.oxygenxml\extensions\v27.1\frameworks\tei\tei\xml\tei\stylesheet\odds\odd2odd.xsl: Relative URI {C:\Data\Works...} is invalid: Illegal character in opaque part at index 2: C:\Data\Works\odd/sample.odd; SystemID: file:/C:/Users/Boris/AppData/Roaming/com.oxygenxml/extensions/v27.1/frameworks/tei/tei/xml/tei/stylesheet/odds/odd2odd.xsl; Line#: 247; Column#: 25

@sydb
Copy link
Member

sydb commented Oct 9, 2025

Hi @daliboris — good to see you in Kraków!

Hmmm … my oXygen (27.1) does not list ${cf} when I try to set up a new transformation scenario and click on the little “Insert Editor Variables” button (a yellow ellipsis under a green down-arrow). And both the field names¹ and the descriptions² of the variables I do see suggest that the values here are URLs, not filepaths. Since URLs use ‘/’ not ‘\’, this would seem like it might be a bug in oXygen. But if they do have a variable correctly returning a path (and your error msg sure makes it look that way) I think such a fix is quite reasonable.

Does it work? I do not have any way to test it. I worry that the string-join(), because it is sticking a slash in between each member of the sequence, will return a string that starts with file://// instead of the desired file:/ or file:///. (I am not sure it would make a difference on a Windows system, though.)

notes
¹ “XML URL” and “XSL URL”.
² E.g. “cfdu = The path of the current file directory (URL)” and “CurrentFileURL = The path of the currently edited file (URL)”.

@sydb sydb self-assigned this Oct 9, 2025
@sydb sydb self-requested a review October 9, 2025 22:26
@sydb sydb added this to the Release 7.60.0 milestone Oct 9, 2025
@sydb sydb added the type: bug A bug report. label Oct 9, 2025
@sydb
Copy link
Member

sydb commented Oct 9, 2025

I have assigned this to myself, and given it a BUG label, but not a CONFIRMED label because I do not have a Windows system and thus cannot reproduce the error. But I do not plan on merging this until somebody who is not @daliboris reviews and verifies that it works properly on Windows. I haven’t assigned any other reviewers, though, because (in general) I do not know who has easy access to a Windows system to test.

@daliboris
Copy link
Author

Hi @daliboris — good to see you in Kraków!

I'm glad I was part of this nice event.

Hmmm … my oXygen (27.1) does not list ${cf} when I try to set up a new transformation scenario and click on the little “Insert Editor Variables” button (a yellow ellipsis under a green down-arrow).

Here are screenshots from my laptop copy of existing transformation scenario without any modifications:

oxygen27 1_2025-10-10T00-40-16 oxygen27 1_2025-10-10T00-40-19 oxygen27 1_2025-10-10T00-40-39

Here is list of all available variables.

Does it work? I do not have any way to test it. I worry that the string-join(), because it is sticking a slash in between each member of the sequence, will return a string that starts with file://// instead of the desired file:/ or file:///. (I am not sure it would make a difference on a Windows system, though.)

You are right, it's my fault: the code adds extra slashes, but surprisingly local paths on my PC works also with these "extra" slashes.

This version returns the correct file URI:

<xsl:value-of select="string-join(('file://', if(matches($currentDirectory, '^[A-Z]:\\$')) 
              then  translate($currentDirectory, '\', '') else translate($currentDirectory, '\', '/'), $loc), '/')"/>

notes ¹ “XML URL” and “XSL URL”. ² E.g. “cfdu = The path of the current file directory (URL)” and “CurrentFileURL = The path of the currently edited file (URL)”.

@sydb
Copy link
Member

sydb commented Oct 10, 2025

Oh! So it is a parameter — and look at that, it is documented as a path, not a URL. I learned something new, thank you.

Do you want to commit the extra-slash-that-is-technically-incorrect-but-seems-to-work fix? If not, I think gitHub will actually let me commit something to your branch, but I am not 100% on that.

@daliboris
Copy link
Author

Windows path to URI functionality has now been fixed.

Thank you for your prompt cooperation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A bug report.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants