473,799 Members | 3,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

collecting with XSLT!

I have the following xml data available:
-----------------------------------------------------------------------
<LinkCategory Name="Hardware" >
<Link LinkName="hardw arelink1" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="hardw arelink2" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="hardw arelink3" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="hardw arelink4" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="hardw arelink5" LinkUrl="www.ms n.com"
PlusLink="True"/>
</LinkCategory>
<LinkCategory Name="Software" >
<Link LinkName="Softw arelink1" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink2" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="Softw arelink3" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink4" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink5" LinkUrl="www.ms n.com"
PlusLink="True"/>
</LinkCategory>
-----------------------------------------------------------------------

And i want to use some kind of Select/test thats collets the links
with the "PlusLink" set to "True".

I need the output to look like this:
-----------------------------------------------------------------------
David's Plus hardware links:
hardwarelink2
hardwarelink3
hardwarelink5

Other Hardware links:
hardwarelink1
hardwarelink4

David's Plus software links:
Softwarelink2
Softwarelink5

Other software links:
Softwarelink1
Softwarelink3
Softwarelink4
-----------------------------------------------------------------------

Please help me!
Jul 20 '05 #1
1 1271


Gunne wrote:
I have the following xml data available:
-----------------------------------------------------------------------
<LinkCategory Name="Hardware" >
<Link LinkName="hardw arelink1" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="hardw arelink2" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="hardw arelink3" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="hardw arelink4" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="hardw arelink5" LinkUrl="www.ms n.com"
PlusLink="True"/>
</LinkCategory>
<LinkCategory Name="Software" >
<Link LinkName="Softw arelink1" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink2" LinkUrl="www.ms n.com"
PlusLink="True"/>
<Link LinkName="Softw arelink3" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink4" LinkUrl="www.ms n.com"
PlusLink="False "/>
<Link LinkName="Softw arelink5" LinkUrl="www.ms n.com"
PlusLink="True"/>
</LinkCategory>
-----------------------------------------------------------------------

And i want to use some kind of Select/test thats collets the links
with the "PlusLink" set to "True".

I need the output to look like this:
-----------------------------------------------------------------------
David's Plus hardware links:
hardwarelink2
hardwarelink3
hardwarelink5

Other Hardware links:
hardwarelink1
hardwarelink4

David's Plus software links:
Softwarelink2
Softwarelink5

Other software links:
Softwarelink1
Softwarelink3
Softwarelink4


If you want text output then you need
<xsl:output method="text" />
then it is not difficult to write xsl:for-each loops to output the stuff:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="text" />

<xsl:template match="/">
<xsl:text>David 's Plus hardware links:
</xsl:text>
<xsl:for-each select="Links/LinkCategory[@Name =
'Hardware']/Link[@PlusLink = 'True']">
<xsl:value-of select="@LinkNa me" />
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:text>Oth er Hardware links:
</xsl:text>
<xsl:for-each select="Links/LinkCategory[@Name =
'Hardware']/Link[@PlusLink != 'True']">
<xsl:value-of select="@LinkNa me" />
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:text>David 's Plus software links:
</xsl:text>
<xsl:for-each select="Links/LinkCategory[@Name =
'Software']/Link[@PlusLink = 'True']">
<xsl:value-of select="@LinkNa me" />
<xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:text>Oth er software links:
</xsl:text>
<xsl:for-each select="Links/LinkCategory[@Name =
'Software']/Link[@PlusLink != 'True']">
<xsl:value-of select="@LinkNa me" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Note that I have assumed there to be a root element named <Links> as the
parent element of the <LinkCategory > elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

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

Similar topics

2
3907
by: ted | last post by:
Was wondering if XSLT alone is appropriate for the following situation. From XML, I'm creating a small website (around 50 pages) with pages that link to each other through a nav menu and a "crumb-trail" of links. I'm transforming the XML with XSLT through Saxon. The nav menu and "crumb-trail" show the user where they are within the site and is made by reflecting the XML tree structure. My problem now is that when I want to generate...
2
2794
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now wondering if I am better of learning XQuery instead? Any thought and opinions would be appreciated. Cheers - Tom. The Architect: "Hope, it is the quintessential human delusion,
2
3387
by: yurick | last post by:
Hello everybody, I'm quit newbie to XML/XSLT, would appreciate any help. There is XML like this: <person name="adam"/> <person name="eve"/> <person name="cain"> <parent name="adam"/>
1
3605
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by version 2 of XSLT processor based on some condition. Q) How and where shall I write logic or import desirable XSLT on the Fly ? Q) When we call AAA.XSLT then it will be processed by XSLT Processor 1
3
2197
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about the development environment or recommend me some other that you know. XML IDE's - http://xslt-process.sourceforge.net - http://www.mentattech.com/themes/mentat/alchemist/index.html Regards,
3
3095
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION> <OPTION>3<OPTION> </FIELD>
17
5104
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also identifying memory leaks. The application in question is the Mozilla Web Browser. I also have had similar tasks before in the compiler construction area. And it is easy to come up with many more examples, where such kind of statistics can be very...
1
2420
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT stylesheets, that generates .NET assemblies) 2. Performance improvements in the XslCompiledTransform
12
11603
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I don't want to have to use some external program or script to parse the csv first if possible
2
22780
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values in the attribute of an element. Instead of using the <xsl:attribute> element, you can simply place the xpath in the attribute itself. The most common usage of this is in creating hyperlinks.
0
9546
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
10491
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...
0
10031
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
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...
1
7571
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
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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...
1
4146
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
3
2941
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.