[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[no subject]

From: "Tuomas Korppoo" <tkorppoo@xxxxxxxxxxx>
Date: Tue, 23 Jul 2002 18:55:53 +0300
tuomas korppoo

Hi,
I've been trying to create an XSLT document that would calculate the average page count of books in an XML document. The problem is that I would like it to choose only some of the books, those with a category of XML. Below is a sample of the XML document.


<Catalog xmlns="http://www.tempuri.org/dsProducts.xsd">
	<Book>
		<Title>IE5 XML Programmer's Reference</Title>
		<Authors>
			<Author>Alex Homer</Author>
		</Authors>
		<Publisher>Wrox Press, Ltd.</Publisher>
		<PubDate>August 1999</PubDate>
		<Abstract>Reference of XML capabilities in IE5</Abstract>
		<Pages>480</Pages>
		<ISBN>1-861001-57-6</ISBN>
		<RecSubjCategories>
			<Category>XML</Category>
		</RecSubjCategories>
		<Price>9.99</Price>
	</Book>

As some of you might be guessing by now the issue is combining a variable statement, which selects only suitable "Book" elements with a namespace declaration. I have made feeble attempts at this. Below is a sample of the XSLT that would need to be improved.


<xsl:variable name="xml"
select="//RecSubjCategories[Category = 'XML']"/>
<xsl:variable name="asp" select="//RecSubjCategories[Category = 'ASP']"/>
<table bgcolor="Whitesmoke" title="Stylesheet Template" height="150" width="350" align="left" border="1">
<th>Avg Pages</th>
<th><xsl:value-of select="sum($xml/../Pages) div count($xml)"/></th>
<th><xsl:value-of select="sum($asp/../Pages) div count($asp)"/></th>


Sorry for the messiness of the code. Can't be helped.
So I would wish to somehow include the namespace declaration in the statement but so far I have had no success. I know how to use namespaces, just not with variables.


Cheers,

Tom









_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.