XSLT editor: how to create dynamic url for source xml file

Having trouble installing Oxygen? Got a bug to report? Post it all here.
helvdan
Posts: 4
Joined: Thu Oct 08, 2015 11:01 am

XSLT editor: how to create dynamic url for source xml file

Post by helvdan »

Hello!
I'd like to create one dynamic scenario for my xslt files based on directory, where they are stored. For example, I have xslt file located in
/home/helvdan/Desktop/my_project/folder/stylesheet.xsl
I want automatically generate url for source xml file. It should be something like this:
http://example.com/my_project/folder/stylesheet.xml

I tried the following

Code: Select all

${xpath_eval( concat('http://example.com/', substring(substring('${currentFileURL}', 23), 1, string-length(substring('${currentFileURL}', 23)) - 4 ), '.xml')} 
nothing happens - I assume it takes the current file

when I try something like this:

Code: Select all

${xpath_eval(substring("${currentFileURL}",28))}
it concatenates current file url with expression, result is
/home/helvdan/Desktop/my_project/folder/my_project/folder/stylesheet.xsl

What is the proper way to do such things?
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: XSLT editor: how to create dynamic url for source xml file

Post by adrian »

Hi,

In what context are you using ${xpath_eval()}? Is it in the XML URL field from the transformation scenario?
If the result of the XPath looks like a relative path ("my_project/folder/stylesheet.xsl") then it will be considered relative to the current folder. You need to make it absolute to avoid that.
Note that there are many other editor variables that could help, rather than using substring with absolute values.

BTW, you have a typo, a missing trailing parenthesis, ')', in the expression from your first example. It should end in '.xml'))}. If nothing worked there, that may be the cause.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
helvdan
Posts: 4
Joined: Thu Oct 08, 2015 11:01 am

Re: XSLT editor: how to create dynamic url for source xml file

Post by helvdan »

Thanks, that works for me.
Post Reply