473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with select statment on for-each

I am using the for-each below to build a table where the header is
a unique nonblank EQUIP_TYPE. This works well.

What I would like to do is not execute the for loop on on EQUIP_TYPE
unless one of the AUTOMATED tags equals YES.

I can change the data so that each row whould contain a tag that
shows if the EQUIP_TYPE has an AUTOMATED member but that seems wasteful.

<xsl:key name="tools-by-type" match="row" use="EQUIP_TYPE"/>
<xsl:template match="document">
<xsl:for-each select="row[count(. | key('tools-by-type', EQUIP_TYPE)[1])
= 1 and EQUIP_TYPE[string-length()>0 ] ">
sample of the XML

<document>
<row rowNumber="1">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ01ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ02ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
</document>

Jul 20 '05 #1
2 2328
Hi Bill,

I'm not absolutely sure what you want... but I think you are saying...

1) select the rows based on distinct <EQUIP_TYPE>
2) but only where the <EQUIP_TYPE> is not 'empty'
3) and where any one of the rows within that distinct <EQUIP_TYPE> value has
an <AUTOMATED> of 'YES'

If so, then perhaps you need something like...

<xsl:for-each select="row[EQUIP_TYPE/text()]
[generate-id() =
generate-id(key('tools-by-type',EQUIP_TYPE))]

[key('tools-by-type',EQUIP_TYPE)/AUTOMATED = 'YES']">

(nb. the predicates are respective to the numbered filter conditions above).

BTW, you are better to use the generate-id() version of the Muenchian
Technique as it generally performs better than the count() version of the
same technique.

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator

"Bill Sneddon" <bs******@yahoo.com> wrote in message
news:bd**********@ngspool-d02.news.aol.com...
I am using the for-each below to build a table where the header is
a unique nonblank EQUIP_TYPE. This works well.

What I would like to do is not execute the for loop on on EQUIP_TYPE
unless one of the AUTOMATED tags equals YES.

I can change the data so that each row whould contain a tag that
shows if the EQUIP_TYPE has an AUTOMATED member but that seems wasteful.

<xsl:key name="tools-by-type" match="row" use="EQUIP_TYPE"/>
<xsl:template match="document">
<xsl:for-each select="row[count(. | key('tools-by-type', EQUIP_TYPE)[1])
= 1 and EQUIP_TYPE[string-length()>0 ] ">
sample of the XML

<document>
<row rowNumber="1">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ01ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ02ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
</document>

Jul 20 '05 #2
Yes you understood what I wanted thank you for being so helpful.
It will be a little while before I can test this but will test again
when that time comes.
Marrow wrote:
Hi Bill,

I'm not absolutely sure what you want... but I think you are saying...

1) select the rows based on distinct <EQUIP_TYPE>
2) but only where the <EQUIP_TYPE> is not 'empty'
3) and where any one of the rows within that distinct <EQUIP_TYPE> value has
an <AUTOMATED> of 'YES'

If so, then perhaps you need something like...

<xsl:for-each select="row[EQUIP_TYPE/text()]
[generate-id() =
generate-id(key('tools-by-type',EQUIP_TYPE))]

[key('tools-by-type',EQUIP_TYPE)/AUTOMATED = 'YES']">

(nb. the predicates are respective to the numbered filter conditions above).

BTW, you are better to use the generate-id() version of the Muenchian
Technique as it generally performs better than the count() version of the
same technique.

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator

"Bill Sneddon" <bs******@yahoo.com> wrote in message
news:bd**********@ngspool-d02.news.aol.com...
I am using the for-each below to build a table where the header is
a unique nonblank EQUIP_TYPE. This works well.

What I would like to do is not execute the for loop on on EQUIP_TYPE
unless one of the AUTOMATED tags equals YES.

I can change the data so that each row whould contain a tag that
shows if the EQUIP_TYPE has an AUTOMATED member but that seems wasteful.

<xsl:key name="tools-by-type" match="row" use="EQUIP_TYPE"/>
<xsl:template match="document">
<xsl:for-each select="row[count(. | key('tools-by-type', EQUIP_TYPE)[1])
= 1 and EQUIP_TYPE[string-length()>0 ] ">
sample of the XML

<document>
<row rowNumber="1">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ01ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>ASH</EQUIP_TYPE>
<TOOL_NAME>ASHZ02ED</TOOL_NAME>
<AUTOMATED>YES</AUTOMATED>
</row>
</document>



Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kyle | last post by:
<?php echo "a href=\"index.php?alp=a\">A</a> ] " ."- " ."- "; if (isset($_GET)) { // Now what must i make the sql statment so that it will display all the names that starts with a $_GET...
1
by: Joe Saliba | last post by:
Hi, would like to know how to write a crosstable select statment in sql server2000 where having: - ItemNumber, ItemDescription, ItemColor, ItemSize as rows - Stores as columns - Qty * Netttc...
6
by: Jonathan LaRosa | last post by:
I am trying to open a recordset and I am getting an error and I can't figure out why. See code below. sqlString2 does not work. sqlString does. Clearly the problem is with the nested SELECT...
5
by: orencs | last post by:
Hello, I am using Microsoft.Practices.EnterpriseLibrary.Data. I am running the following sqlCommand = "SELECT var1 FROM table1 WHERE var2 IN (4,5,6) ; SELECT var3 FROM table2 WHERE var2 IN...
6
by: mabond | last post by:
Hi Is it possible to compare a vaule for a select case statement using a wildcard. e.g. somthing like Select case myValue case like "*ing" end select
5
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
3
by: Giorgio | last post by:
Can someone tell me options to do this statment because this one does not work! SELECT Name FROM tbl_J WHERE J_ID IN (SELECT J1, J2, J3, J4, J5, J6 FROM tbl_CJ WHERE CJ_ID =23515) ORDER BY...
2
by: gimme_this_gimme_that | last post by:
I use the following SQL statment to bring z_emp_id values to a employee table: update employee set z_emp_id = (select z.emp_id from z.employee z where z.login=employee.login) Upon executing...
2
by: Breana | last post by:
Ok, i am making a mail system so i can mail users, and i have the table all set up no errors as of yet. But my question is how do i make an else statment 2 times. So if there is mail it will show...
8
by: Trevor2007 | last post by:
I am trying to hard code the following select query into a select case statement ie (case1 <statment>, case 2 <statment>) but I getteing Compiler error: expected line number or label, or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.