Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2003

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith Chadwick - 26 Nov 2003 01:57 GMT
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
Oleg Tkachenko - 26 Nov 2003 08:28 GMT
> Now here is the strange thing on loading the clnt.home.body.xslt file from
> within home.aspx
[quoted text clipped - 23 lines]
>
> 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.
Signature

Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Keith Chadwick - 26 Nov 2003 17:42 GMT
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

> > Now here is the strange thing on loading the clnt.home.body.xslt file from
> > within home.aspx
[quoted text clipped - 34 lines]
>   preserving its base URI (e.g. not from string or stream), otherwise
> obviously XSLT processor won't be able to resolve relative URI references.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.