This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Multiple requests with variable number of parameters


Hello,

I need to process servlet requests where the first parameter specifies a
command, and remaining ones - parameters for that command, each command
might have different number of parameters for example :
/servlet?cmd=showFile&fileID=1
/servlet?cmd=setPipLabel&pipID=1&text=BBC1

Stylesheet must convert these requests into a device-specific format, for
ex,
/servlet?cmd=showFile&fileID=1 shoud produce "Z_ShowFile 1\r>".

This is my solution ( input processing is shown only ):

device.xsl (the result of this transformation is processed by an
application ):
<xsl:stylesheet ...>
  <xsl:variable name="cmdRequest"/>
  <!-- other variables -->
  <xsl:template match="/">
    <cmd>
      <in>
          <xsl:value-of select="$cmdRequest">
          <!-- this is what all requests for this device end with -->
          <xsl:text>&#xA;&gt;</xsl:text>
      </in>
      <!-- other elements -->
    </cmd>
  </xsl:template>
 </xsl:stylesheet ...>

Each servlet request's cmd parameter is mapped to a stylesheet with the same
name
showFile.xsl :
<xsl:stylesheet ...>
  <xsl:import href="device.xsl"/>

   <xsl:variable name="fileID" select="1"/>
   <!-- thios defines a mapping-->
   <xsl:variable name="cmdRequest"
                       select="concat('Z_ShowFile ', $fileID)"/>
</xsl:stylesheet ...>

setPipLabel.xsl : similar to showFile.xsl;

What I don't like about this is that if 50 requests need to be processed,
than 50 command-specific stylesheets need to be created; I need to create 50
javax.transfrom.Templates, even though it is device.xsl which performs the
real job. Also it's quite fragile, in that each command must have a
corresponding file  named identically to its name.

Is there a better solution for this scenario ?
Thanks !
Siarhei Biarozkin


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]