Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 28th, 2010, 07:49 AM
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default filter a nodeset based on multiple form values

Hi,

I need help to filter a nodeset based on multiple form values from a search form, using xslt.

The values might be null.

MY VALUES FROM QUERYSTRING
<xsl:variable name="CaseNo" select="umbraco.library:RequestForm('CaseNo')"/>
<xsl:variable name="Street" select="umbraco.library:RequestForm('Street')"/>
<xsl:variable name="Area" select="umbraco.library:RequestForm('Area')"/>
<xsl:variable name="HouseType" select="umbraco.library:RequestForm('HouseType')"/>
<xsl:variable name="PriceRange" select="umbraco.library:RequestForm('PriceRange')"/>
<xsl:variable name="SquareMeters" select="umbraco.library:RequestForm('SquareMeters' )"/>

HERE I LOAD MY XML FILE
<xsl:variable name="url" select="'http://URL to XML FILE"/>

<xsl:variable name="pagexml" select="umbraco.library:GetXmlDocumentByUrl($url)" />

HERE I NEED to FILTER THE NODESET, BASED ON THE VARIABLES ABOVE.
<xsl:variable name="sag" select="$pagexml/sager/sag"></xsl:variable>


LOAD THE FILTERED NODES
<xsl:for-each select="$sag">
</xsl:for-each>
 
Old May 28th, 2010, 08:05 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Let's assume that when you say a value might be "null", you mean it might contain an empty string.

Then you can write a predicate like this:

select="$pagexml/sager/sag[($CaseNo='' or $CaseNo=CaseNo) and ($Street='' or $Street=Street) and ($Area='' or $Area=Area) and ....]"
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert multiple elements based on values of others fixit XSLT 14 September 25th, 2009 05:36 AM
Filter a subform based on value entered mackoy Access 1 August 25th, 2006 12:27 PM
Multiple filter on a form chimp Access VBA 0 September 9th, 2004 02:59 AM
Adding multiple form field values to database cdenequolo Classic ASP Basics 1 August 17th, 2004 05:38 PM
Opening a Form based on two Values mikericc Access 1 May 10th, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.