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

RE: XML criterias

Subject: RE: XML criterias
From: "Chen, Gin" <Gin_Chen@xxxxxxxxxxxxx>
Date: Wed, 3 Jul 2002 14:11:00 -0400
re gin 100
Hey Michael,

	Thank you so much! Didnt even occur to me to use a recursive
template.
And thanx for the correction on criteria as well. My excuse is that the SATs
is a distant memory. :-P

-Tim

-----Original Message-----
From: Michael Kay [mailto:michael.h.kay@xxxxxxxxxxxx]
Sent: Wednesday, July 03, 2002 10:36 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  XML criterias


I think you need a recursive template that applies a filter for one
criterion on each iteration.

<xsl:template name="filter">
  <xsl:param name="nodes"/>
  <xsl:param name="criteria"/>
  <xsl:choose>
  <xsl:when test="$criteria">
    <xsl:variable name="criterion" select="$criteria[1]"/>
    <xsl:call-template name="filter">
      <xsl:with param name="criteria" select="criteria[position()>1]"/>
      <xsl:with param name="nodes" 
        select="$nodes[@*[name()=$criterion/@name and
.=$criterion/c:value]"/>
    </
  </xsl:when>
  <xsl:otherwise>
      <xsl:copy-of select="$nodes"/>
  </
  </xsl:choose>
</

(PS, just saw your title. Call me old-fashioned, but in my dictionary
you have one criterion, two criteria)

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Chen, Gin
> Sent: 02 July 2002 20:29
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  XML criterias
> 
> 
> Hi all,
> 	I have an XML document that I need to parse out certain 
> information. The information that I'm looking for is in a 
> separate XML generated with my XSL. So an example would be 
> (simplified): //in my xml <?xml version="1.0" 
> encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" 
> href="C:\NAlert\test.xsl"?> <datarows>
> 	<rowset id="100" value="100" blah="A"/>
> 	<rowset id="200" value="200" blah="B"/>
> 	<rowset id="300" value="100" blah="C"/>
> </datarows>
> 
> //inside my xsl
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 	xmlns:fo="http://www.w3.org/1999/XSL/Format"
> 	xmlns:c="http://tempuri/criteria">
> 
> <xsl:output method="html"/>
> 
> <xsl:variable name="para" 
> select="document('')/*/c:criteria/c:parameter"/>
> 
> <xsl:template match="//datarows/rowset">
> 	<xsl:copy-of select="@*[name()=$para/@name and 
> .=$para/c:value]/parent::*"/> </xsl:template>
> 
> <c:criteria>
> 	<c:parameter name="id">
> 		<c:value>100</c:value>
> 		<c:value>200</c:value>
> 	</c:parameter>
> 	<c:parameter name="value">
> 		<c:value>100</c:value>
> 	</c:parameter>
> </c:criteria>
> 
> </xsl:stylesheet>
> 
> so i'm basically saying that i want to get all 
> datarows/rowsets that have ids of either 100 or 200 AND value 
> of 100 the problem is that I'm getting back all rows because 
> its returning true if any parameter name/value matches. I 
> dont want to hardcode all the parameter names in to the 
> select because there could be alot of attributes to check. Is 
> there a better way to do this but still keeping it generic? 
> Thanks, -Tim
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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

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


Current Thread
  • XML criterias
    • Chen, Gin - Tue, 2 Jul 2002 15:32:50 -0400 (EDT)
      • <Possible follow-ups>
      • Chen, Gin - Wed, 3 Jul 2002 14:11:03 -0400 (EDT) <=

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.