Fetching the url from a xsl sheet(xpath)

T

Taare

I was thinking about a xsl sheet that could change template depending
on the url, sort of like using $_GET with PHP. I'v heard that XSLT 2.0
got the document() function, but I'v also heard that there is a trick
for doing this with XSLT 1.0, anybody know?
 
M

Martin Honnen

Taare said:
I was thinking about a xsl sheet that could change template depending
on the url, sort of like using $_GET with PHP. I'v heard that XSLT 2.0
got the document() function, but I'v also heard that there is a trick
for doing this with XSLT 1.0, anybody know?

XSLT (even 1.0) stylesheets take external parameters so you could pass
the URL as a parameter to the XSLT processor.
 
T

Taare

I'm trying to figure out this external parameter thing, maybe you could
show me a exsample? Also, I see that the document() function don't
bring up an "unknow function" error, but it doesn't print the url for
the element either, you got any thoughts about that?
 
M

Martin Honnen

Taare said:
I'm trying to figure out this external parameter thing, maybe you could
show me a exsample?

As far as XSLT goes you simply do
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:param name="parameterName" />

...
</xsl:styleshet>
to define the global external parameter. Then it depends on the XSLT
processor and the API it has on how to set the parameter to a value
before you run a transformation.
 
T

Taare

Yeah, I figured that out, as I searched through this group. Right now
I'm just testing stuff with the built in mozilla xslt
engine(TransforMiiX), and it seems to not work. Thanks for all the help
guys, and I'll be a good boy next time and search first then ask :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top