Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

<xsl:include href="xsl-file in different folder" />

2,051 views
Skip to first unread message

Maurice Hulsman

unread,
Apr 25, 2001, 10:58:51 AM4/25/01
to
Hidihoo,

I have a problem with the xsl:include element

I used to include my templates.xsl the following way
<xsl:include href="templates.xsl" />

Now i'd like to move my templates.xsl to a common directory while my other
stylesheets remain on their spot
In other words:

is it possible to use a virtual path ("/common/templates.xsl") from the root
of my webserver
or 'maybe' a relative path ("../templates.xsl") to it.

The following attamps didn't work
<xsl:include href="/common/templates.xsl" />
<xsl:include href="../templates.xsl" />
<xsl:include href="http://"my virtual site name"/common/templates.xsl" />
<xsl:include href="file://common/templates.xsl" />

plz help!


Marrow

unread,
Apr 25, 2001, 12:51:42 PM4/25/01
to
Maurice,

How are you loading the stylesheet that calls this included stylesheet?
That may be the root of your problem.

Marrow

Maurice Hulsman wrote in message ...

Maurice Hulsman

unread,
Apr 26, 2001, 3:32:33 AM4/26/01
to
Marrow,

This is how i do it:
there's an ASP page in the root of my server which gets a xsl passed in it's
querystring:
like so "/index.asp?xsl=/xsl/index.xsl"
this asp generates xml (builds it in a DOM) and uses the stylesheet to
transform the generated output

this main.xsl holds the refered <xsl:include href="templates.xsl"> to the
templates stylesheet which is in the same directory (/xsl/templates.xsl)

What i'd like
what i'd like to do is to put the index.xsl next to the index.asp and store
the templates.xsl in a common directory.

This is where my problems arise.
you get my drift?

Kind regards (and many thanks up front), maurice

<Marrow> schreef in bericht news:e7IxPiazAHA.1396@tkmsftngp05...

Maurice Hulsman

unread,
Apr 26, 2001, 3:35:08 AM4/26/01
to
Marrow,

I forgot to mention that the building of the xml i generate is done by a
"Msxml2.FreeThreadedDOMDocument"

(don't know if that's really important to this issue but you never can tell)

Maurice


<Marrow> schreef in bericht news:e7IxPiazAHA.1396@tkmsftngp05...

Marrow

unread,
Apr 26, 2001, 6:33:26 AM4/26/01
to
Maurice,

I'm still not absolutely sure how you are loading the main stylesheet? But
the problem you may be encountering is if you use .loadXML() to load the XSL
into the DOM from a string then the DOM has no idea of the path - so even if
you have includes that are path relative they cannot be found because the
DOM doesn't know what the starting path is.

If you use .load() to load the XSL into the DOM then you shouldn't have a
problem - just make sure any hrefs in <xsl:import>/<xsl:include> are
relative to the path of the original stylesheet file or are absolute paths
that the server has permissions for or is a valid URL.

>this main.xsl holds the refered <xsl:include href="templates.xsl"> to the
>templates stylesheet which is in the same directory (/xsl/templates.xsl)

If you miss out the leading / then the path is relative - so try...

<xsl:include href="xsl/templates.xsl">

Hope this works

Maurice Hulsman

unread,
Apr 26, 2001, 8:05:35 AM4/26/01
to
Marrow,

You won't believe it, but it's true... the following snippet loads the
stylesheet:

Set objXSL = objIAsp("Server").CreateObject("Msxml2.DOMDocument.3.0")
objXSL.ASync = false
objXSL.Load(strPhysicalXsl)
If objXSL.parseError.errorCode = 0 Then
strReplyList = objReplyList.transformNode(objXsl)
Set objReplyList = get_objWebBone().createNode(strReplyList)
End If
Set objXSL = Nothing

so i already use .load()
I'd like this to word
"/common/templates.xsl" holds standard templates
"/index.xsl" likes to use templates.xsl
"/flurp/something.xsl" likes to use templates.xsl
"/flurp/something.xsl" likes to use templates.xsl

You still got a clue?

<Marrow> schreef in bericht news:OALjhzjzAHA.1400@tkmsftngp05...

Marrow

unread,
Apr 26, 2001, 12:24:06 PM4/26/01
to
Maurice,

> You still got a clue?

Not really - but we may be getting there.

Firstly, I don't know what the variable strPhysicalXsl contains - so I
assume you've assigned a value using something like...

set strPhysicalXsl = server.MapPath("flurp\something.xsl"))

So, let's assume that the resulting value is say...

"C:\InetPub\wwwroot\mysite\flurp\something.xsl"

and you have directory structure like...

C:
INetPub
wwwroot
mysite
flurp
common

and in that common sub-dir you have a file "templates.xsl"

So, to include that "templates.xsl" into your "something.xsl" then you
should use...

<xsl:include href="../common/templates.xsl"/>

If that doesn't solve it then you have lost me.

Marrow

Maurice Hulsman

unread,
May 1, 2001, 5:15:01 AM5/1/01
to
Best Marrow,

[I feel so f**king stupid]

Yes, yes, works fine indeed,

BIG LESSON FOR ALL YOU FINE PEOPLE
XSL:INCLUDE "releative file path"

I probably forgot to check this because we hate to use relative paths
Company policy is to use absolute virtual "/flurp/somefolder" instead of
"../somefolder"
But new techniques require different approaches

Thanks, thanks, many thanks to marrow,

I owe you [stupid me...],

Maurice.
<Marrow> schreef in bericht news:uSwRe3mzAHA.1808@tkmsftngp05...

0 new messages