473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>ASHZ 01ED</TOOL_NAME>
<AUTOMATED>YE S</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>ASH </EQUIP_TYPE>
<TOOL_NAME>ASHZ 02ED</TOOL_NAME>
<AUTOMATED>YE S</AUTOMATED>
</row>
</document>

Jul 20 '05 #1
2 2339
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_TYP E))]

[key('tools-by-type',EQUIP_TYP E)/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.co m...
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>ASHZ 01ED</TOOL_NAME>
<AUTOMATED>YE S</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>ASH </EQUIP_TYPE>
<TOOL_NAME>ASHZ 02ED</TOOL_NAME>
<AUTOMATED>YE S</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_TYP E))]

[key('tools-by-type',EQUIP_TYP E)/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.co m...
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:templa te 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>A SH</EQUIP_TYPE>
<TOOL_NAME>AS HZ01ED</TOOL_NAME>
<AUTOMATED>YE S</AUTOMATED>
</row>
<row rowNumber="2">
<EQUIP_TYPE>A SH</EQUIP_TYPE>
<TOOL_NAME>AS HZ02ED</TOOL_NAME>
<AUTOMATED>YE S</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
1278
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 ( a ) //
1
937
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 as value from Table sales
6
8528
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 statement. But when I copy sqlString2 into a new query it runs just fine. Futhermore, I have used a nested SELECT statement with the...
5
3097
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 (4,5,6)"; IDataReader dataReader = db.ExecuteReader(dbCommandWrapper); while
6
28709
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
3204
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 at conventions. I have a main form with two subforms. On the main form, there is a text box that displays the sum of total orders entered in the...
3
1906
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 Name
2
18072
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 this statement a warning appears (in AQT) saying all the rows in the table will be modified. Is this a benign message?
2
1295
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 it, if no mail "No messages found" and if there not logged in the { else } stament.. <? if (logincheck($uid, $upwd)) { echo ("<p...
8
4465
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 statement or end of statement on my select line , with and without the pertentheses at the end of my where clause. here is what I have, the query functions...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.