473,799 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

count from XML

30 New Member
Ok,

I need to be able to count the # of items for each category and have it display.

So say i have a left menu that displays that category name for cat in the current issue.xml for instance en_print_200802 .xml which is called form a seperate .xml volissue.xml beside each name i want to display the # of items in each category.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <vol_issue vol_issue_id="200802">
  3.  <description>February</description>
  4.  <language>en</language>
  5.  <type>print</type>
  6.  <xmlfilename>en_print_200802.xml</xmlfilename>
  7.  <cdfilename>cd_en_print_200802.xml</cdfilename>
  8.  <category category_id="2">
  9.   <sort_order>2</sort_order>
  10.   <article article_id="48633"/>
  11.  </category>
  12.  <category category_id="1">
  13.   <sort_order>3</sort_order>
  14.   <article article_id="48105"/>
  15.   <article article_id="48104"/>
  16.   <article article_id="48103"/>
  17.   <article article_id="48102"/>
  18.   <article article_id="48101"/>
  19.  </category>
XSL

Expand|Select|Wrap|Line Numbers
  1. <xsl:variable name="category_lookup" select="document('../articles/categories.xml')"/>
  2.  
  3. <xsl:template match="vol_issue">
  4.     <xsl:choose>
  5.         <xsl:when test="$target = 'web'">
  6.             <div class="ln-text">
  7.             <xsl:for-each select="category">
  8.                 <xsl:sort select="sort_order" data-type="number" order="ascending" />
  9.                 <xsl:variable name="catid" select="@category_id"/>
  10.                 <xsl:variable name="classname">
  11.                   <xsl:choose>
  12.                   <xsl:when test="$catid = $selectedcat"><xsl:text>ln-slink</xsl:text></xsl:when>
  13.                   <xsl:otherwise><xsl:text>ln-alink</xsl:text></xsl:otherwise>
  14.                   </xsl:choose>
  15.                 </xsl:variable>    
  16.                 <xsl:text>•*</xsl:text><a href="{$strBaseURL}&amp;vol={/vol_issue/@vol_issue_id}&amp;cat={$catid}" id="{$catid}" class="{$classname}"><xsl:value-of 
  17.  
  18. select="$category_lookup/main/category[@category_id = $catid]/description"/>: <!-- <xsl:value-of select="document('vol_issue/@vol_issue_id.xml')//count(value)"/> -->
  19. </a><br/>
  20.                  </xsl:for-each>
  21.             </div>
  22.         </xsl:when>            
  23.     <xsl:otherwise>
  24.         <input type="hidden" name="lang" value="{language}"/>
  25.         <input type="hidden" name="type" value="{type}"/>
  26.         <input type="hidden" name="vol_issue_id" value="{@vol_issue_id}"/>
  27.         <xsl:for-each select="category">
  28.             <xsl:sort select="sort_order" data-type="number" order="ascending" />
  29.             <xsl:variable name="catid" select="@category_id"/>
  30.             <input type="checkbox" name="cat" value="{$catid}"><xsl:value-of select="$category_lookup/main/category[@category_id = $catid]/description"/></input><br/>    
  31.          </xsl:for-each>    
  32.     </xsl:otherwise>
  33.     </xsl:choose>
  34. </xsl:template>
  35.  
  36. </xsl:stylesheet>
Thanks,

B.
Jan 3 '08 #1
2 1468
jkmyoung
2,057 Recognized Expert Top Contributor
In your category for-each:
<xsl:value-of select="count(a rticle)"/>
Jan 3 '08 #2
googletired
30 New Member
Thanks,

Works well.

B.
Jan 4 '08 #3

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

Similar topics

22
61417
by: Ling Lee | last post by:
Hi all. I'm trying to write a program that: 1) Ask me what file I want to count number of lines in, and then counts the lines and writes the answear out. 2) I made the first part like this: in_file = raw_input("What is the name of the file you want to open: ") in_file = open("test.txt","r")
6
34478
by: Geetha | last post by:
I searched in the Oracle documents what count (1) meant and I could not find an answer. Can some one explain what Oracle does internally when use count (1) VS count (*). Thank you very much in advance! We use Oracle 9i.
1
3158
by: JD | last post by:
Hi guys I'm trying to write a program that counts the occurrences of HTML tags in a text file. This is what I have so far: #include <stdio.h> #include <stdlib.h> #include <string.h> #define MB 1048576
5
5919
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int Count { get { return 0; }
23
2905
by: Gary Wessle | last post by:
Hi I have a vector<charwhich looks like this (a d d d a d s g e d d d d d k) I need to get the biggest count of consecutive 'd'. 5 in this example I am toying with this method but not sure if it is optimal. thanks int k = 0;
1
4524
by: heckstein | last post by:
I am working in Access 2002 and trying to create a report from our company's learming management system. I am not a DBA and most of my SQL knowledge has been self taught through trial and error. I have created an access query to track the number of training hours for a training group. The query is working except for one piece of data and I hoping someone can help me. There is a field titled enrollment status, which presents an alpha character of...
22
12496
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
3
3116
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php, I use: $query2 = "SELECT id, order_no, price, count(item_no) as count from production where item_no = '27714";
7
2562
by: Chris | last post by:
I am trying to increase/decrease the value of $_SESSION by 1 after clicking on a link e.g index.php?gotoWk=nxtWk and index.php? gotoWk=lstWk. I'm sure you will get the drift if you look at the code below. However, this code seems to be unreliable. Is there a more robust way of achieving the same thing? Many thanks,
1
3621
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent via an email function. But just can't figure it out. <? //////////////////////////////////////////////////////////// //
0
9538
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
10249
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
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
9068
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
7563
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
6804
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
5461
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...
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2937
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.