By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

Odd behavior on xsl:include / xsl:import - Figure this one out?

P: n/a
I have been running some tests with regards to xsl:include and xsl:import
with the same results on both and I am wondering if someone can explain this
behavior to me!

First off the xslt file is being loaded as in

dim myXSLT as new XslTransform()
myXSLT.load("scripts/clnt.home.body.xslt")

The load craps out when I change the xsl:include, tried all of the following
is xsl:import as well. The file contains a href to a file called
clnt.cmn.xslt. It contains some standard templates with names that render
particular html that is common to the site. The file is stored in a physical
directory, C:\allianceShared\xslt\clnt.cmn.xslt.

The directory allianceShared is a virtual directory in the web site called
shared and resides at the root. The transform file I am loading is off the
root within a directory called scripts. Here is the structure laid out

c:\allianceShared
xslt\
clnt.cmn.xslt

c:\AllianceNet (Website root, domain name
http://allianceNet)
shared\ (Virtual directory pointing at
c:\allianceShared)
scripts\
clnt.home.body.xslt (transformation file being loaded)
home.aspx (file making the call )

Now here is the strange thing on loading the clnt.home.body.xslt file from
within home.aspx

example 1 : works
<xsl:import href="c:\allianceShared\xslt\clnt.cmn.xslt"/> - works

example 2: works, surprise!
<xsl:import href="http://allianceNet/shared/xslt/clnt.cmn.xslt"/>

example 3: fails
<xsl:import href="../shared/xslt/clnt.cmn.xslt"/>
Now thinking that '..' usually means something else in the xslt world I
created the same virtual directory 'shared' under the scripts directory,
hence the next example/

example 4: fails
<xsl:import href="shared/xslt/clnt.cmn.xslt"/>

Now what is interesting is, example 1 works even though you are supposed to
be supplying an href? If example 2 works, meaning that it does recognize the
virtual directory 'shared' why would example 3 or 4 fail?

Of note I have other xslt files that have xsl:import statements with the
href="../somefile.xslt" and they work, but only if they are dealing with
physical directories in the web site not virtual ones.

Any thought on this?

Looking forward to seeing if Oleg can explain this one :-)

Cheers
Keith
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Keith Chadwick wrote:
Now here is the strange thing on loading the clnt.home.body.xslt file from
within home.aspx

example 1 : works
<xsl:import href="c:\allianceShared\xslt\clnt.cmn.xslt"/> - works

example 2: works, surprise!
<xsl:import href="http://allianceNet/shared/xslt/clnt.cmn.xslt"/>

example 3: fails
<xsl:import href="../shared/xslt/clnt.cmn.xslt"/>
Now thinking that '..' usually means something else in the xslt world I
created the same virtual directory 'shared' under the scripts directory,
hence the next example/

example 4: fails
<xsl:import href="shared/xslt/clnt.cmn.xslt"/>

Now what is interesting is, example 1 works even though you are supposed to
be supplying an href? If example 2 works, meaning that it does recognize the
virtual directory 'shared' why would example 3 or 4 fail?

Of note I have other xslt files that have xsl:import statements with the
href="../somefile.xslt" and they work, but only if they are dealing with
physical directories in the web site not virtual ones.

Any thought on this?


Well, actually relative URI references in xsl:import instruction (ones
who don't work for you) are resolved relatively to base URI of the
xsl:import element node itself (hence base URI of the master stylesheet
clnt.home.body.xslt in your case).
So if both stylesheets are in the same dir, try
<xsl:import href="clnt.cmn.xslt"/>

Another issue - make sure you are loading clnt.home.body.xslt stylesheet
preserving its base URI (e.g. not from string or stream), otherwise
obviously XSLT processor won't be able to resolve relative URI references.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #2

P: n/a
Thanks Oleg you twigged my brain regarding the load of the file. I was
using server.mappath("url") instead of a fully qualified URI. Everything
works fine now.

Cheers
Keith

"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:Oq**************@TK2MSFTNGP11.phx.gbl...
Keith Chadwick wrote:
Now here is the strange thing on loading the clnt.home.body.xslt file from within home.aspx

example 1 : works
<xsl:import href="c:\allianceShared\xslt\clnt.cmn.xslt"/> - works

example 2: works, surprise!
<xsl:import href="http://allianceNet/shared/xslt/clnt.cmn.xslt"/>

example 3: fails
<xsl:import href="../shared/xslt/clnt.cmn.xslt"/>
Now thinking that '..' usually means something else in the xslt world I
created the same virtual directory 'shared' under the scripts directory,
hence the next example/

example 4: fails
<xsl:import href="shared/xslt/clnt.cmn.xslt"/>

Now what is interesting is, example 1 works even though you are supposed to be supplying an href? If example 2 works, meaning that it does recognize the virtual directory 'shared' why would example 3 or 4 fail?

Of note I have other xslt files that have xsl:import statements with the
href="../somefile.xslt" and they work, but only if they are dealing with
physical directories in the web site not virtual ones.

Any thought on this?


Well, actually relative URI references in xsl:import instruction (ones
who don't work for you) are resolved relatively to base URI of the
xsl:import element node itself (hence base URI of the master stylesheet
clnt.home.body.xslt in your case).
So if both stylesheets are in the same dir, try
<xsl:import href="clnt.cmn.xslt"/>

Another issue - make sure you are loading clnt.home.body.xslt stylesheet
preserving its base URI (e.g. not from string or stream), otherwise
obviously XSLT processor won't be able to resolve relative URI references.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.