This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[no subject]



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]