0

I have a xsl file in a jar. I also have a XML file named language.xml that is located next to the jar.

In the xsl, I want to load the XML document. This is how I am trying to achieve this:

<xsl:variable name="strs" select="document('../language.xml')/LanguageFile/Strings"/>

But the xml file is never loaded. Is it possible to have one file in a jar and the other outside or must they be both inside/outside the jar ??

Spotted
  • 4,021
  • 17
  • 33

1 Answers1

0

The call to the document function attempts to resolve the URI reference ../language.xml relative to the URI of the stylesheet itself. If the stylesheet is in a jar file, the stylesheet URI is probably of the form jar:file:/path/to/your.jar!/stylesheet.xsl.

You cannot get the reference to the jar file itself or its directory from such a URI by just resolving a relative reference; you would need to do it programmatically.

Probably the easiest way to refer to your XML file would be to just use a file URI instead.

If you know the full path of the file:

document('file:/path/to/language.xml')

Alternatively, if the full path is not known and fixed but you can control the current working directory, you could reference the file relative to the current working directory:

document('file:language.xml')
Community
  • 1
  • 1
Jukka Matilainen
  • 9,608
  • 1
  • 25
  • 19
  • What if the xml file's parent is a sibling of the jar's parent. Can I do something like `document('file:../lang/language.xml')` ? Or as you suggested, I must do it programmatically and give it to the XSL as a variable ? – Spotted Jul 21 '15 at 11:31