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

Re: Determining Web server address in xslt doc

Subject: Re: Determining Web server address in xslt doc
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 26 Jan 2009 15:53:13 -0500
Re:  Determining Web server address in xslt doc
On Jan 26, 2009, at 3:35 PM, Lee Surma wrote:

FYI I am a newbie who has been tasked with maintaining

some existing XSLT. I would like to make some XSLT dynamic
across environments using a choose statement.

Is there a way I can determine the root of the Web server
where the XSLT document is so I can hard code URL
addresses etc based on if I'm in Dev vs Production?
Example:
dev.imanewbiefool.com Vs
uat.imanewbiefool.com or
www..imanewbiefool.com

In HTML you can use the CGI REMOTE_HOST variable.


Anyway, you can't get it with XSL alone. You probably want to vary on parameters or some non-source-controlled XML lookup that you pull in with the document function.

Another way would be to wrap the source xml instance with the host information. For example:

<dev.imanewbiefool.com>
  ... the wrapped xml...
</dev.imanewbiefool.com>

and

<www.imanewbiefool.com>
  ... the wrapped xml...
</www.imanewbiefool.com>

Then, instead of using a possibly huge choose, you can just match the root element:

<xsl:import href="hosts.xsl"/>

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

and in hosts.xsl you could either import your individual hosts statically or generate your hosts based of a directory containing however many unique host xsls. Or just match them there:

<xsl:template match="dev.imanewbiefool.com">
... do whatev...
</xsl:template>

<xsl:template match="www.imanewbiefool.com">
... do whatev...
</xsl:template>


-Rob





Lee

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.