Page 1 of 1
Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 12:36 pm
by gary.crawford
I have a stylesheet that imports/includes (we dont use relative paths) some library stylesheets.
When we run, using java, the library stylesheets are found on the classpath.
When I'm running with Oxygen, the library stylesheets are not found unless I put them all in the same directory as the stylesheet I'm testing.
Is there anyway to add the "classpath" to Oxygen when I configure a transformation?
TIA
Gary
Re: Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 2:05 pm
by sorin_ristache
Hello,
The path that is specified in the
href attribute is used for reading the content of the imported stylesheet
as required for xsl:import elements. What do you mean you don't use relative paths? Do you use an absolute path? Can you give an example of
xsl:import element, the file path of the stylesheet that contains the
xsl:import element and the file path of the stylesheet that should be imported?
Regards,
Sorin
Re: Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 3:16 pm
by gary.crawford
Hi Sorin,
When I said I don't use relative paths, I meant stuff like "../my.xsl"
an example of how I include is simply <xsl:include href="common.xsl"/>
now my Java class has the classpath setup to search for common.xsl so it doesn't have to be in the same directory.
I was looking for something similar in oxygen so I dont have to copy all the files into the same directory.
regards
Gary
Re: Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 3:30 pm
by sorin_ristache
gary.crawford wrote:an example of how I include is simply <xsl:include href="common.xsl"/>
That
is a relative path.
gary.crawford wrote:now my Java class has the classpath setup to search for common.xsl so it doesn't have to be in the same directory.
The Java class path of the Java application that runs the transformation has no connection with resolving the relative paths of imported stylesheets. A relative path is first expanded to an absolute path based on the absolute path of the XSLT stylesheet that contains the
xsl:import or
xsl:include element and after that the XSLT processor tries to read the content of the included/imported stylesheet from the obtained absolute path. In your example that means the stylesheet
common.xsl located in the same folder as the stylesheet that contains the
xsl:include element. Of course it is possible to redirect that absolute path to other URI using an XML catalog but you did not mention that you used any XML catalog for resolving the path of an included/imported stylesheet.
Regards,
Sorin
Re: Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 3:53 pm
by gary.crawford
Hi Sorin,
My Java class is overriding the URI resolver so it will search the classpath to resolve imports...
Not sure what XML Catalogs are but it doesn't look like something that I could use without changing source so I'll just copy everything into a dir for testing thru Oxygen I guess....
Thanks
Gary
Re: Classpath for XSLT include and import
Posted: Tue Oct 20, 2009 4:09 pm
by sorin_ristache
gary.crawford wrote:My Java class is overriding the URI resolver so it will search the classpath to resolve imports...
In that case you have two options:
- set the fully qualified name of your Java URI resolver for Saxon 9
in the Preferences;
- map the absolute path that results from resolving the relative path specified in
xsl:include/@href or in
xsl:import/@href to the location that you want using an
XML catalog added to
the XML catalogs list from your Oxygen preferences. The Oxygen URI resolver uses the mappings from the XML catalog entries of type
uri for resolving the URIs specified in the XSLT stylesheets.
Regards,
Sorin
Re: Classpath for XSLT include and import
Posted: Wed Oct 21, 2009 6:30 pm
by gary.crawford
Hi Sorin,
Used the XML catalog and it worked perfectly. The template for the catalog helped a lot.
For reference, my catalog file looked like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "
http://www.oasis-open.org/committees/en ... atalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uriSuffix uriSuffix="common.xsl" uri="b:/bdsldev1/mgcommon/xml/common.xsl"/>
</catalog>
Thank you very much for your help!
Cheers
Gary