This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Multiple requests with variable number of parameters
- From: "Siarhei Biarozkin" <sberyozkin at zandar dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 2 May 2002 10:59:10 +0100
- Subject: [xsl] Multiple requests with variable number of parameters
- References: <000001c1f098$76c2aed0$936ab818@COM>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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>
></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