473,626 Members | 3,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Include some records and exclude others

2 New Member
I'm trying to learn how/do two things here:
1) If the user searches for "Data" ($searchtext = "Data") the output should also include the fourth record because Field1 contains "all".
2) But the output of this same search should also exclude any records where Field1 contains "info" ($searchtext = "info"). You can see by the textsearch template that I have 3 case conversion variables that can be used to to include/exclude "All", "all", "ALL", "Info", "info", or "INFO"

A statement like this includes "all" but I can't figure out how to get it to also exclude "info"
<xsl:for-each select="record[*[name() = $searchfield][contains(., $ProperText) or contains(., $UCASETEXT) or contains(., $lcasetext) or ../Field1[contains(., 'ALL') or contains(., 'all') or contains(., 'All')]]]">

XML Data
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <data>
  3.   <record>
  4.     <Field1>Data1-1</Field1>
  5.     <Field2>Data1-2</Field2>
  6.     <dtmField>2008-01-28T01:01:00Z</dtmField>
  7.   </record>
  8.   <record>
  9.     <Field1>Info</Field1>
  10.     <Field2>Data2-2</Field2>
  11.     <dtmField>2008-01-28T02:02:00Z</dtmField>
  12.   </record>
  13.   <record>
  14.     <Field1>Data3-1</Field1>
  15.     <Field2>Data3-2</Field2>
  16.     <dtmField>2008-01-28T03:03:00Z</dtmField>
  17.   </record>
  18.   <record>
  19.     <Field1>all</Field1>
  20.     <Field2>Data4-2</Field2>
  21.     <dtmField>2008-01-28T04:04:00Z</dtmField>
  22.   </record>
  23.   <record>
  24.     <Field1>All</Field1>
  25.     <Field2>Data5-2</Field2>
  26.     <dtmField>2008-01-28T05:05:00Z</dtmField>
  27.   </record>
  28.   <record>
  29.     <Field1>info</Field1>
  30.     <Field2>Data6-2</Field2>
  31.     <dtmField>2008-01-28T06:06:00Z</dtmField>
  32.   </record>
  33. </data>
  34.  
<!-- Desired output -->
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <data>
  3.   <record>
  4.     <Field1>Data1-1</Field1>
  5.     <Field2>Data1-2</Field2>
  6.     <dtmField>2008-01-28T01:01:00Z</dtmField>
  7.   </record>
  8. Record 2 is excluded because "Field1" = Info
  9.   <record>
  10.     <Field1>Data3-1</Field1>
  11.     <Field2>Data3-2</Field2>
  12.     <dtmField>2008-01-28T03:03:00Z</dtmField>
  13.   </record>
  14.   <record>
  15.     <Field1>all</Field1>
  16.     <Field2>Data4-2</Field2>
  17.     <dtmField>2008-01-28T04:04:00Z</dtmField>
  18.   </record>
  19.   <record>
  20.     <Field1>All</Field1>
  21.     <Field2>Data5-2</Field2>
  22.     <dtmField>2008-01-28T05:05:00Z</dtmField>
  23.   </record>
  24. Record 6 is excluded because "Field1" = info (notice the case is different)
  25. </data>
  26.  
XSL Stylesheet
<!-- Include this just to show version and output method -->
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3.   <xsl:output method="html"/>
  4.  
  5. <!--
  6. The "selected" value of thes parameters are filled in for this example. Normally
  7. they are passed from an external ASP VBScript that processes inputs from another form where the values are input by the user.
  8. -->
  9.   <xsl:param name="searchfield" select="Field1"/> <!-- Field to search -->
  10.   <xsl:param name="searchtext" select="Data"/> <!-- Text to search for -->
  11.   <xsl:param name="sortbyfield" select="Field2"/> <!-- Field to sort output by -->
  12.   <xsl:param name="sortorder" select="Descending"/> <!-- Sort order ascending or descending -->
  13.  
  14.   <xsl:template name="textsearch">
  15.     <xsl:for-each select="record[*[name() = $searchfield][contains(., $ProperText) or contains(., $UCASETEXT) or contains(., $lcasetext)]]">
  16.       <xsl:sort select="*[name()=$sortbyfield]" order="{$sortorder}"/>
  17.       <xsl:call-template name="resulttable"/>
  18.     </xsl:for-each>
  19.   </xsl:template>
  20.  
Feb 29 '08 #1
3 1708
jkmyoung
2,057 Recognized Expert Top Contributor
perhaps add the following:
[not (contains(.,'IN FO'))][not (contains(.,'In fo'))][not (contains(.,'in fo'))]
Feb 29 '08 #2
ITSimTech
2 New Member
It seems you understand what I'm trying to do but when I typed my initial posting I should have written it differently. I rewrote it so maybe it makes more sense:
This works:
1) If the user searches for "entry" ($searchtext = "entry") the output should also include the fourth and fifth record because Field1 contains "all", "All", or "ALL" even though the fourth record doesn't contain any case of "entry". Also the fifth record should only be output once even though it contains any case of "all" in Field1 and also any case of "entry" in Field2. I've managed to accomplish this using this statement:
<xsl:for-each select="record[*[name() = $searchfield][contains(., $ProperText) or contains(., $UCASETEXT) or contains(., $lcasetext) or ../Field1[contains(., 'ALL') or contains(., 'all') or contains(., 'All')]]]">

I can't make this work though:
2) But I want the output of this same search to ALSO exclude the second and sixth record because Field1 contains "info", "Info" or "INFO" even though Field2 contains "Entry", "entry", or "ENTRY". The info records won't be viewed using this stylesheet. The records where Field1 contains any case of "info" will only show up when you use a different stylesheet much like this one in which case it will be treated just like this stylesheet treats records where Field1 is "all".
XML Data
<?xml version="1.0"?>
<data>
<record>
<Field1>Data1-1</Field1>
<Field2>Entry 1-2</Field2>
<dtmField>200 8-01-28T01:01:00Z</dtmField>
</record>
<record>
<Field1>Info</Field1>
<Field2>This entry is not readable</Field2>
<dtmField>200 8-01-28T02:02:00Z</dtmField>
</record>
<record>
<Field1>Data3-1</Field1>
<Field2>Entry 3-2</Field2>
<dtmField>200 8-01-28T03:03:00Z</dtmField>
</record>
<record>
<Field1>all</Field1>
<Field2>This record is readable by everyone</Field2>
<dtmField>200 8-01-28T04:04:00Z</dtmField>
</record>
<record>
<Field1>All</Field1>
<Field2>This entry is also readable by everyone</Field2>
<dtmField>200 8-01-28T05:05:00Z</dtmField>
</record>
<record>
<Field1>info</Field1>
<Field2>This entry is also not readable</Field2>
<dtmField>200 8-01-28T06:06:00Z</dtmField>
</record>
</data>
<!-- Desired output -->
<record>
<Field1>Data1-1</Field1>
<Field2>Entry 1-2</Field2>
<dtmField>200 8-01-28T01:01:00Z</dtmField>
</record>
Record 2 is excluded because Field1 = "Info"
<record>
<Field1>Data3-1</Field1>
<Field2>Entry 3-2</Field2>
<dtmField>200 8-01-28T03:03:00Z</dtmField>
</record>
<record>
<Field1>all</Field1>
<Field2>This entry is readable by everyone</Field2>
<dtmField>200 8-01-28T04:04:00Z</dtmField>
</record>
Record 5 below is included only once even though Field2 contains "entry" AND Field1 contains "all"
<record>
<Field1>All</Field1>
<Field2>This entry is also readable by everyone</Field2>
<dtmField>200 8-01-28T05:05:00Z</dtmField>
</record>
Record 6 is excluded because "Field1" = info even though Field2 contains "entry"
XSL Stylesheet
<?xml version="1.0"?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:param name="searchfie ld" select="Field2"/>
<xsl:param name="searchtex t" select="entry"/>
<xsl:param name="sortbyfie ld" select="Field1"/>
<xsl:param name="sortorder " select="Descend ing"/>
<xsl:variable name="lowercase " select="'abcdef ghijklmnopqrstu vwxyz'"/>
<xsl:variable name="uppercase " select="'ABCDEF GHIJKLMNOPQRSTU VWXYZ'"/>
<xsl:variable name="lcasetext " select="transla te($searchtext, $uppercase, $lowercase)"/>
<xsl:variable name="UCASETEXT " select="transla te($searchtext, $lowercase, $uppercase)"/>
<xsl:variable name="ProperTex t" select="concat( translate(subst ring($searchtex t,1,1), $lowercase, $uppercase),tra nslate(substrin g($searchtext,2 ), $uppercase, $lowercase))"/>
<xsl:template match="data">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Search Results </title>
</head>
<body>
<p class="title"> Search Results </p>
<table>
<tr>
<th> Field1 </th>
<th> Field2 </th>
<th> Date &amp; Time</th>
</tr>
<xsl:for-each select="record[*[name() = $searchfield][contains(., $ProperText) or contains(., $UCASETEXT) or contains(., $lcasetext) or ../Field1[contains(., 'ALL') or contains(., 'all') or contains(., 'All')]]]">
<xsl:sort select="*[name()=$sortbyf ield]" order="{$sortor der}"/>
<tr>
<td>
<xsl:value-of select="Field1"/>
</td>
<td>
<xsl:value-of select="Field2"/>
</td>
<td>
<xsl:value-of select="dtmFiel d"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Mar 3 '08 #3
jkmyoung
2,057 Recognized Expert Top Contributor
Does tacking it on to the end not work?

<xsl:for-each select="record[*[name() = $searchfield][contains(., $ProperText) or contains(., $UCASETEXT) or contains(., $lcasetext) or ../Field1[contains(., 'ALL') or contains(., 'all') or contains(., 'All')]]][not (contains(.,'IN FO'))][not (contains(.,'In fo'))][not (contains(.,'in fo'))]">
Mar 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4977
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a blank. I've tried; > >DateDiff("y",-4,DateIn) and get errors > >Please any assistance would be greatly appreciated. >
2
1512
by: Rolan | last post by:
Can one set limits on html imported records in Access 97? For example, would like to prohibit importing records or a group of records whose ReferenceID number is not within an acceptable number range. Can this be done by modifying the wizard code. If so, where and how? A second, less desirable option, would be an OnOpen form message that states there are recent records imported that are not within the acceptable range and must be deleted...
1
2888
by: Mark Rae | last post by:
Hi, Am currently in the process of migrating a whole heap of v1.1 ASP.NET solutions to v2.0, and would be interested to know what others are doing about excluding web.config from projects. In v1.1, it was quite usual to exclude web.config from the project so that it wouldn't get deployed to the live site along with the rest of the aspx etc files and the bin folder. Typically (for me, anyway!) this was because the web.config would...
5
2547
by: redstamp | last post by:
Try as I might I cannot find a way to write an access query to return a result set with the records from my database WITHOUT a certain set of values within a field. To explain, I have a table of customers linked to a table of customer contacts. The contact table has a field called 'type of contact'. Contact types can be numeric 1 to 40 and show the different types of contact I have with my customers (e.g. 1 - initial contact, 2 -...
3
3637
by: KJ | last post by:
Hello All, Can someone please explain what these .exclude/.include files are? They only show up in some web site projects, and it seems to be related to deleting. Any ideas?
1
1435
by: uniko | last post by:
Hello, I have a table with multiple fields, which describe several products.I want to exclude all the records of a specific product when it appears at the beginning or at the end of the table. Let's say, that the table is similar to the following, I want to exclude all products A from the beginning and the end. I have been told that I should use cursors but i am not very sure how to do it. thank you all in advance for your answers. e.g. A ...
16
2374
by: Chris Shearer Cooper | last post by:
In our Visual Studio 2005 application, we have several of our application's H files that are #included into stdafx.h. What is odd, is that when we change those application H files, VS2005 doesn't trigger a rebuild of the entire app (or of anything, for that matter). Is this a setting somewhere? Thanks!
3
6031
by: Cindy | last post by:
I'm trying to use the NEWID function in dynamic SQL and get an error message Incorrect syntax near the keyword 'ORDER'. Looks like I can't do an insert with an Order by clause. Here's the code: SELECT @SQLString = N'INSERT INTO TMP_UR_Randoms(Admit_DOCID, Client_ID, SelectDate, SelectType,RecordChosen)' SELECT @SQLString = @SQLString + N'(SELECT TOP ' + @RequFilesST + ' Admit_DOCID, Client_ID, SelectDate, SelectType, RecordChosen...
2
2038
by: nickvans | last post by:
Hello everyone! I have a question that should be rather simple, but I haven't been able to figure out a way to do it. I have a table which has assembly numbers, and another table with parts that go to these assemblies (1 to many relationship on field AssyNum), as well as a form with several text boxes for the user to input part numbers. If a value is input into a text box, a list on the form shows all AssyNum's that include that part. ...
0
8203
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7203
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
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
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.