[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with parameter processing

Subject: Re: Problem with parameter processing
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 17 Jan 2003 16:07:30 -0700 (MST)
pass xml element setparameter problem
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.