[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Assigning a dynamic value of href in a stylesheet PI
Subject: RE: [xsl] 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 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Assigning a dynamic value, G. Ken Holman | Thread | RE: [xsl] Assigning a dynamic value, bryan |
Re: [xsl] Assigning a dynamic value, G. Ken Holman | Date | [xsl] need help on stylesheet effic, Malia Zaheer |
Month |
Keywords