[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Accessing Dynamic URL for Image Path

Subject: RE: Accessing Dynamic URL for Image Path
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Fri, 15 Oct 2004 17:59:11 -0500
dynamic url
Hi Joe,

> Is there a way to access the ASP variable image_path within the XSLT
transform?

Yes, of course. Are you using MSXML? Then use the method addParameter() on
the created XSL processor object. The parameter can be obtained dynamically
from your page by using J(ava)script. 

Obtain first your params, for example:

<%@ Language="JScript" %>
<% 
...
IdCd = new String(Request.QueryString("IdCd"));
Hora = getHora();
Fecha = getFecha();
...
%>

An example (Javascript-)function I used before demonstrates how to add the
params to the xsl processor object (i.e. IdCd, Fecha, and Hora):

<%
...
function transformDataS(srcDoc,xslProc,IdCd,Fecha,Hora) {
	// point to the compiled processor
  xslProc.input = srcDoc;
  // add the parameters used inside the stylesheet
  xslProc.addParameter("Hora", Hora, "");
  xslProc.addParameter("Fecha", Fecha, "");
  // xslProc.addParameter("IdCd", "MXNL0068", "");
  xslProc.addParameter("IdCd", IdCd.toString(), "");
  // perform the XSL Transformation
  xslProc.transform();
  // write result to browser
  Response.Write(xslProc.output);
  return true;
}
...
%>

In the stylesheet, you can access the params by:

...
<xsl:output method="html" indent="yes" omit-xml-declaration="yes" />

<xsl:param name="IdCd" />
<xsl:param name="Hora" />
<xsl:param name="Fecha" />
...
</xsl:stylesheet>
...

Let us know if you need more help. 

HTH,
<prs/>
 

-----Original Message-----
From: Joe Heidenreich [mailto:HeidenreichJ@xxxxxxxx] 
Sent: Friday, October 15, 2004 1:55 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Accessing Dynamic URL for Image Path

Accessing Dynamic URL for Image Path

I'm trying to get my images to appear in my XML to HTML transform. I'm
having trouble identifying and printing the URL to the image. This URL is
dynamic, depending on which file I am transforming. Basic directory
structure is:

/root: contains the stylesheet.xsl and the view.asp page
/article-number/: contains the article XML and image files

so:

stylesheet.xsl
view.asp
/article1/article1.xml
/article1/article1_figure1.jpg

The view page is passed the article number through the querystring:
view.asp?num=article1

It also sets up a variable image_path = /article1/

and that is the relative URL. I'm updating a previous transform which was
set up this way. It accessed the graphic files by opening them in a new
window and was able to access the image_path variable through a javascript
document.writeln() call. However, that was embedded in a javascript function
which was activated through a link and I'm using inline images now instead
of opening a new window so the old approach won't work. I may need to try an
entirely different approach.

My transform looks like this:

<xsl:template name="fig" match="fig">
<img src="/{@file_name}"/>
</xsl:template>

and I need to insert the URL here:

<img src="/URL/{@file_name}"/>

This seems to be a simple matter, but I've been unable to find out how to
insert it. I've read people suggesting to pass the value in as a hard coded
parameter but since the directory structure is dynamic that won't work. Is
there a way to access the ASP variable image_path within the XSLT transform?
Any other suggestion would also be appreciated. Thanks! And unfortunately,
the DTD we use requires XSLT v 1.0.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.