473,800 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selcting filtered node set based on variable

Question for the masses...

Lets say I have variable with the following contents
"aaaa bbbb ccccc dddd". The format is not specific and the space
delimiter could be changed to any other.

How would i count and/or select the nodes where a child nodes value is
not contained in this list. Or the reverse scenario would be sufficent
whereas I count the nodes whose child nodes value is contained.

A contrived example of my situation follows...thank s for the help.

<root>
<limbs>
<branch>
<name>a</name>
<flower>big</flower>
</branch>
<branch>
<name>b</name>
<flower>big</flower>
</branch>
<branch>
<name>c</name>
<flower>large </flower>
</branch>
<branch>
<name>d</name>
<flower>giant </flower>
</branch>
</limbs>
<root>

<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="ye s"/>
<xsl:variable name="Exclude">
<xsl:value-of select="big large"/>
</xsl:variable>
<xsl:template match="/">
<xsl:variable name="DomainCou nt">
<xsl:value-of select="count(//branch[contains($Exclu de,
flower)])"/>
</xsl:variable>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #1
2 1543
> Question for the masses...
Panem et circenses Lets say I have variable with the following contents
"aaaa bbbb ccccc dddd". The format is not specific and the space
delimiter could be changed to any other.

How would i count and/or select the nodes where a child nodes value is
not contained in this list. Or the reverse scenario would be sufficent
whereas I count the nodes whose child nodes value is contained.

A contrived example of my situation follows...thank s for the help.

<root>
<limbs>
<branch>
<name>a</name>
<flower>big</flower>
</branch>
<branch>
<name>b</name>
<flower>big</flower>
</branch>
<branch>
<name>c</name>
<flower>large </flower>
</branch>
<branch>
<name>d</name>
<flower>giant </flower>
</branch>
</limbs>
</root>


Hi,

In this situation, the following stylesheet might work:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="ye s"/>
<xsl:variable name="Exclude">
big large
</xsl:variable>

<xsl:template match="/">
<xsl:variable name="DomainCou nt">
<xsl:value-of select="count(//branch[not(contains($E xclude,flower))])"/>
</xsl:variable>
</xsl:template>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #2
<xsl:variable name="Exclude">
<xsl:value-of select="big large"/>
</xsl:variable>

note it's simpler and a lot more efficient to do

<xsl:variable name="Exclude" select="' big large '"/>

(and you'd omitted the quotes around the string 'big large'.)
I added a space at either end as well (used below)

<xsl:variable name="DomainCou nt">
<xsl:value-of select="count(//branch[contains($Exclu de,
flower)])"/>
</xsl:variable>

again that would be better as

<xsl:variable name="DomainCou nt" select="count(//branch[contains($Exclu de,
flower)])"/>
which works but to avoid the possibility of one name being a substring
of the other, you can append a space to either side:
<xsl:variable name="DomainCou nt" select="count(//branch[contains($Exclu de,
concat(' ',flower, ' '))])"/>

so:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" omit-xml-declaration="ye s"/>
<xsl:variable name="Exclude" select="' big large '"/>

<xsl:template match="/">

<xsl:variable name="DomainCou nt" select="count(//branch[contains($Exclu de,
concat(' ',flower, ' '))])"/>
[<xsl:value-of select="$Domain Count"/>]
</xsl:template>
</xsl:stylesheet>
<root>
<limbs>
<branch>
<name>a</name>
<flower>big</flower>
</branch>
<branch>
<name>b</name>
<flower>big</flower>
</branch>
<branch>
<name>c</name>
<flower>large </flower>
</branch>
<branch>
<name>d</name>
<flower>giant </flower>
</branch>
</limbs>
</root>
$ saxon flower.xml flower.xsl

[3]

3 nodes have flower= big or large
Jul 20 '05 #3

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

Similar topics

3
3150
by: Blaise Garant | last post by:
Hi I've made a stylesheet to transform my data into XSL-FO. This stylesheet used to work with MSXSL 4.0 but I've got some issues in ..NET. First, I changed removed all the "node-set()" function since they're not used anymore. But now, I used an <xsl:apply-templates/> and for some reason, it works in some situation but not in others. I didn't put the whole XSL file since it's quite big. Here's the part that bugs
6
9357
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is a checkbox with a control source named "MARK" (boolean) from customer table. I can check and uncheck individual records fine. Then I created 2 command buttons named "Select All" and "Deselect All". The Onclick property of these buttons runs code...
7
5475
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when looping through the GridView, it doesn't
1
5425
by: Ken | last post by:
I have a form that has a command button on it to open a report. The report is based on the forms data, if it's filtered the report is filtered, if the form is showing 100 records the report is showing the same 100 records, etc. I want to create another command button which exports to excel, in the same manner above. Whether the form is filtered or not, the same records should be exported. I played around with TransferSpreadsheet but I...
3
3464
by: melnhed | last post by:
---Report the current filtered records from a Form--- Hello All, I've seen this topic discussed before, but the solution described then doesn't work in my particular case. My Config: Access 2002 front-end using SQL Server 2000 (MSDE actually) via ADP/ADE Access Data Project.
2
1442
by: Stephen | last post by:
Hi Using: Visual Web Developer Express 2005 Could someone explain to me what the "node" does in a path - such as; <siteMapNode title="Hardware" url="Default.aspx?node=hardware"> Has it got something to do with PostBack?
0
3382
by: HP17 | last post by:
Hi all, I am a bit desperate already trying to display a XML file using XSLT. I create a table and use <xsl:for-each> to extract every element node. This is working fine. What I want now is so format every column with a color (e.g. red) if the element value is the same as the one in the next node. if the value changes if should change the color (e.g. to blue) and stay so long blue as the value is the same. With the next change, I should...
7
8763
by: Dag Sunde | last post by:
I want to use the format-number function to output a number with a specific number of decimals, based on the content of a node... Is there any smart way to generate differnet strings based on a node-value? if decimals = 0, I want "###,###" decimals = 1, I want "###,###.0" decimals = 2, I want "###,###.00" decimals = n, I want "###,###.000..n"
6
1959
by: Nettle | last post by:
Purpose: I am creating a mailing distribution list database. Users should be able to filter/search contacts and add them to distribution lists they have created. My problem? I can't add multiple, filtered contacts to the proper distribution list. I have two main forms, described below. These forms are based on three tables. Tables tbl_MainContact: Holds all contact information tbl_JoinContactToDistributionList: A join table
0
9691
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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
10507
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
10255
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,...
1
7582
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5473
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
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.