473,322 Members | 1,699 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,322 software developers and data experts.

Display by category...


Hello I'm posting a new article about the category. The following XML
segment was posted by Li some days ago and I'm trying to do some more work:

<shop name="myshop">
<category>
<cd type="pop">Pop music</cd>
<cd type="rock">Rock</cd>
<cd type="classical">Classical music</cd>
</category>

<welcome>Welcome to myshop</welcome>

<content>
<headline>Music CD</headline>
<location name="Address">
<cdshelf>
<disc name="CCC" cg="pop"/>
<disc name="AAA" cg="pop"/>
<disc name="EEE" cg="rock"/>
<disc name="GGG" cg="pop"/>
</cdshelf>
</location>

<location name="AnotherAddress">
<cdshelf>
<disc name="BBB" cg="classical"/>
<disc name="DDD" cg="pop"/>
<disc name="FFF" cg="classical"/>
</cdshelf>
</location>

</content>
</shop>

The desired web output:

Welcome to myshop

Music CD

Location Address:

Pop music:
1. CCC
3. AAA
4. GGG

Rock:
1. EEE

Location AnotherAddress:

Classical music:
1. BBB
2. FFF

Pop music:
1. DDD
The XML file contains 2 locations, and each location has different kinds of CDs
available (some are unavailable, for example, classical CDs are absent at
location "Address"). And the correct CDs should appear according to
its location and the category should be listed in ascendent order. Is it
possible to do it? Thank you.
Jul 20 '05 #1
2 1239
Tempore 09:16:52, die Wednesday 02 March 2005 AD, hinc in foro {comp.text.xml} scripsit Zhou Lei <da*********@hotmail.com>:
The XML file contains 2 locations, and each location has different kinds of CDs
available (some are unavailable, for example, classical CDs are absent at
location "Address"). And the correct CDs should appear according to
its location and the category should be listed in ascendent order. Is it
possible to do it? Thank you.

Once again, no problem:)

here's one example, using xpath rather than keys.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />

<xsl:template match="category"/>

<xsl:template match="welcome | headline">
<xsl:element name="h{count(ancestor::*)}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="cdshelf">
<xsl:variable name="shelf" select="."/>
<xsl:for-each select="ancestor::shop/category/cd">
<xsl:sort/>
<xsl:if test="$shelf/disc[@cg=current()/@type]">
<h4><xsl:apply-templates/>:</h4>
<ol>
<xsl:apply-templates select="$shelf/disc[@cg=current()/@type]"/>
</ol>
</xsl:if>
</xsl:for-each>
</xsl:template>

<xsl:template match="location">
<h3>Location <xsl:value-of select="@name"/>:</h3>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="disc">
<li><xsl:value-of select="@name"/></li>
</xsl:template>

</xsl:stylesheet>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Spread the wiki (http://www.wikipedia.org)
Jul 20 '05 #2

Okay I got it. Thank you very much for your help now I can use XSLT better than
before :) And please help me when I have problems again...
Jul 20 '05 #3

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

Similar topics

1
by: Cleus | last post by:
Is there a way to display read only values in a drop down listbox? Below is an example of what I need displayed in the drop down list. The users should only be able to select Item 1-9. Category A-C...
2
by: Jerry M. Gartner | last post by:
Greetings: As evident from a previous post, I am a php noob. I would like to display MySQL query results in an html table with one of the row values as a category and the rest of the data...
1
by: vinayg | last post by:
how can i search subcategory wise for a particular category,i want to display items.suppose user selected a particular category.I want to display all items in that category + its subcategories. ...
24
by: Phil Latio | last post by:
Let's say I have a simple web application running with just two MySQL tables. The tables structure is as follows: Table: category category_id (PK) category_name parent_category (FK)...
3
by: JCCDEVEL | last post by:
Hello, I'm writing a basic query in Sql Server Mgmt Studio 2005. Basically, I'm trying to query a table to get all "issues" reported in a month by "Project Category". The query is working fine...
11
by: Jankie | last post by:
I need to dispaly a user's multiple images in one entry.Right now,say if a user uploads 3 images,three entries for the same id display to match 3 images. I only want 1 entry to display all of a...
2
by: DotNetNewbie | last post by:
Hello, I need to display a list of categories on the left side of a page, and I am confused how I would do this using a List Control (as appose to weaving my own HTML on the server side). My...
2
by: itpvision | last post by:
Hello, I have a link navigation of categories retrieved from the database, while I know how to display subcategories based on category link clicked with classical approach, I want to do this with...
0
by: AlDave | last post by:
What I'm trying display is after the user chooses the product (1st category) from a dropdown, then the dataview will display; The category any reports under that subcategory any...
5
by: fran7 | last post by:
Hi, If anyone has any pointer as to how to do this that would be great. This code gets me a list of categories only where they have artists listed in them. Instead of displaying the "category name"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.