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

RE: Assigning a dynamic value of href in a stylesheet

Subject: RE: Assigning a dynamic value of href in a stylesheet PI
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 25 Jul 2002 17:34:11 +0100
xml stylesheet href
You can use <xsl:value-of> inside <xsl:processing-instruction>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Roger L. Costello
> Sent: 25 July 2002 17:07
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; Costello,Roger L.
> Subject:  Assigning a dynamic value of href in a stylesheet PI
> 
> 
> Hi Folks,
> 
> I have a stylesheet which outputs an XML document, containing 
> a stylesheet processing instruction (PI).  I would like for 
> the PI to be customized to the client.  (I have a different 
> stylesheet for each
> client.) 
> 
> For example, if the client is Internet Explorer, then the PI 
> should be:
> 
> <?xml-stylesheet href="MSIE-parts-styler.xsl" type="text/xsl"?>
> 
> If the client is Netscape, then the PI should be:
> 
> <?xml-stylesheet href="Netscape-parts-styler.xsl" type="text/xsl"?>
> 
> And so forth.
> 
> I pass into my stylesheet a parameter, client, which 
> indicates who the client is.  Since the list of clients will 
> grow over time I don't want to have to hard code into the 
> stylesheet all the clients.  That is, I don't want to do this:
> 
> <xsl:template match="/">
>     <xsl:choose>
>         <xsl:when test="$client='MSIE'">
>             <xsl:processing-instruction name="xml-stylesheet">
>                     <xsl:text>
>                        href="MSIE-part-styler.xsl" type="text/xsl"
>                     </xsl:text>
>             </xsl:processing-instruction>
>         </xsl:when>
>         <xsl:when test="$client='Netscape'">
>             <xsl:processing-instruction name="xml-stylesheet">
>                     <xsl:text>
>                        href="Netscape-part-styler.xsl" type="text/xsl"
>                    </xsl:text>
>             </xsl:processing-instruction>
>         </xsl:when>
>     </xsl:choose>
> </xsl:template>
> 
> Ideally, I would like to do this:
> 
> <xsl:template match="/">
>     <xsl:processing-instruction name="xml-stylesheet">
>          href="{concat($client, "-part-styler.xsl")} type="text/xsl"
>     </xsl:processing-instruction>
> </xsl:template>
> 
> Where client is the name of the parameter that is passed into 
> the stylesheet.
> 
> Alas, this later approach is not possible (because the 
> contents of xsl:processing-instruction must be text).
> 
> Does anyone have a good solution for this?  That is, one that 
> doesn't force me to add a new xsl:when clause every time a 
> new type of client comes in.
> 
> OFFTOPIC: Does anyone know how a HTTP header indicates that 
> the client is Netscape (as opposed to IE)?  The HTTP 
> user-agent header field contains MSIE if the client is IE.  
> If the client is Netscape there doesn't seem to be any way of 
> identifying that the client is Netscape. 
> Any ideas?
> 
> Thanks!  /Roger
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.