xsl-list
[Top] [All Lists]

Re: moving presentation logic from ASP script to XSL template

2004-11-06 08:41:35
Hi Gabriel,

Nobody answered this question as far as I can see. So let me try..

Yes, you could pass a parameter and use that in a certain template (for instance match="/") to decide for one or the other presentation logic. You can prevent conflicts with same matche rules by adding a mode to the templates. Note that you will have to add the same mode to all templates that belong together and will have to specify that mode in each apply-templates as well.

Basically it would look like:

<xsl:param name="presentation-mode" select="'pc'" />
<!-- default 'pc', to be overruled from outside the script -->

<xsl:template match="/">
  <xsl:choose>
    <xsl:when test="string($presentation-mode) = 'pocketpc'">
      <xsl:apply-templates select="." mode="pocketpc" />
    <xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="." mode="pc" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="/" mode="pc">
  <html>
    ...
      <xsl:apply-templates select="node()" mode="pc" />
    ...
  </html>
</xsl:template>

<xsl:template match="/" mode="pocketpc">
  <wap>
    ...
      <xsl:apply-templates select="node()" mode="pocketpc" />
    ...
  </wap>
</xsl:template>

Hope this helps, good luck!

Grtz,
Geert

Hello!
My question is illustrated at http://gabbah.no-ip.org/XSL_question.jpg

Currently, I let my asp script check what sort of client made the request, and then transform the XML retrieved from a COM object, with one of two possible XSL-files; pc-templates.xsl and pocketpc-templates.xsl. These xsl files include all of the templates needed. This is case one.

My goal is to have ALL presentation logic in XSL only, as you can see in case 2. How could I achive this?

(I guess I need to pass a parameter somehow, and use it in the XSL. However, the templates for PC have the same match criteria as the pocketpc have, so there would still be a match conflict for all the nodes in the XML...? )

Thanks in advance,
/Gabriel

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





--
Geert(_dot_)Josten(_at_)Daidalos(_dot_)nl
IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50


<Prev in Thread] Current Thread [Next in Thread>