Connecting Tech Pros Worldwide Help | Site Map

Get page name via XSLT?

Newbie
 
Join Date: Dec 2008
Posts: 10
#1: Dec 31 '08
I there a way to get the current page's name using XSLT and store it in a variable?

Something like:

<xsl:variable name="myVariable" select="PageName"/>
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,622
#2: Jan 1 '09

re: Get page name via XSLT?


generally speaking, XSL can get everything contained in the source XML. If page name means the file name, then no (this requires file system functions).

regards
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#3: Jan 5 '09

re: Get page name via XSLT?


XSLT was not designed to do this (eg, be Environment aware). Some possibilities, depending on how you are running this transformation:

1. Have the containing code (which calls the XSLT) pass in a parameter of the filename to the XSLT processor.
2. Have the XSLT reference a static lookup file. Before running the transformation, update the file with the lookup file filename.
Newbie
 
Join Date: Dec 2008
Posts: 10
#4: Jan 5 '09

re: Get page name via XSLT?


In my case, I assume the 'containing code (which calls the XSLT)' would be the ASP code I use to call both the XML and XSLT (see code below). Is that correct? If so, any idea how to do that?


Expand|Select|Wrap|Line Numbers
  1. <asp:Xml runat="server" documentSource="xml/sample.xml" transformSource="xml/sample.xsl" id="sample"  />
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#5: Jan 5 '09

re: Get page name via XSLT?


Use the Xml::TransformArgumentList property
Xml.TransformArgumentList Property (System.Web.UI.WebControls)

Adding parameters to the Argument list:
XSLT Parameters
Reply