xsl-list
[Top] [All Lists]

RE: Filtering using list of params (Subtree creation?)

2003-11-19 07:40:35
From:     Chris Ward <cward(_at_)horizon-asset(_dot_)co(_dot_)uk>

I want to know if there is a preferred method of filtering out multiple
parts of a large XML using some form of parameter list/document.

I suggest two possible approaches, neither of which is what you describe:

1) Create a stylesheet for each view and select the appropriate one based on 
values from the query string of the submitting page.

2) Create a "view" parameter in single stylesheet with a large <xsl:choose> 
section. Then create individual named templates to be called based on the value 
of the view parameter as determined in the <xsl:choose>. Like this:

  <xsl:param name="view" />
  
  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$view = 'global'>
        <xsl:call-template name="global" />
      </xsl:when>
      <xsl:when test="$view = 'euro'>
        <xsl:call-template name="euro" />
      </xsl:when>
      <xsl:when test="$view = 'london'>
        <xsl:call-template name="london" />
      </xsl:when>
      <xsl:when test="$view = 'new york'>
        <xsl:call-template name="new-york" />
      </xsl:when>
      <xsl:when test="$view = 'paris'>
        <xsl:call-template name="paris" />
      </xsl:when>
      <xsl:when test="$view = 'madrid'>
        <xsl:call-template name="madrid" />
      </xsl:when>
      <xsl:when test="$view = 'tokyo'>
        <xsl:call-template name="tokyo" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="not-authorized" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email


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