Subject: Re: [xsl] Problem with parameter processing From: Mike Brown <mike@xxxxxxxx> Date: Fri, 17 Jan 2003 16:07:30 -0700 (MST) |
Jaywanth wrote: > I have an array in a java program that has elements [1,3] , i need a way to > pass this array to XSL and filter the transactions whose "id" attribute > match the values in the array . XSLT processors accept external parameters that are passed into the stylesheet via the xsl:param element. It is usually easiest to pass them in as strings. Although a node-set would be easier to work with in the stylesheet, constructing one is usually more trouble than it is worth. The mechanism for passing in parameters varies from processor to processor. If you are using JAXP interfaces, look for documentation on the setParameter method on the Transformer object. I would make a String like ",1,3," (make sure there's a comma on both sides of each number), and pass this in as a parameter named "ids". My stylesheet would look like this (untested): <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="ids"/> <xsl:output method="xml" indent="yes"/> <!-- identity transform (recursive copy-through) for all nodes --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- do nothing for transaction elements if their @id is not in $ids --> <xsl:template match="transaction[not(contains($ids,concat(',',@id,',')))]"/> </xsl:stylesheet> Mike -- Mike J. Brown | http://skew.org/~mike/resume/ Denver, CO, USA | http://skew.org/xml/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Problem with parameter proces, Jaywanth | Thread | RE: [xsl] Problem with parameter pr, Avula, Raj |
[xsl] Imbedding a document in an el, Peter Van de Water | Date | [xsl] Problem with parameter proces, Jaywanth |
Month |