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

Relative/Absolute path queries?

Subject: Relative/Absolute path queries?
From: "peter verhaar" <peter.verhaar1@xxxxxxxxx>
Date: Thu, 11 Dec 2008 11:30:31 +0100
 Relative/Absolute path queries?
Hi,

I have an another question:

Assume:

<?xml version="1.0" encoding="UTF-8"?>
<demo>
	<library><books><book title="test" key="1"/></books></library>
	<stock><quantity key="1">50</quantity></stock>
</demo>

Questions (see my first try below):

1. How can I print the quantity of the book while looping books? Or better:
	- How do I print quantity by absolute path (below I assume filesystem
style '/demo/stock/@quantity[@key=...]')
	- How do I print quantity by relative path (e.g. filesystem style
while in Book: './../../stock/quantity[@key=...]')

2. I now need an empty template (see last line) demo/stock to suppress
output which doesn't match any template. How can I create 1 template
for all nodes which don't mach? This avoid me creating a lot of empty
templates for every not output generating node.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="demo/library/books">
	<xsl:for-each select="book">
	     Title: <xsl:value-of select="@title"/>
	     <xsl:variable name="keyCurrentBook" select="@key"/>
	     Quantity: <xsl:value-of
select="/demo/stock/@quantity[@key=$keyCurrentBook]"/>
	</xsl:for-each>
</xsl:template>
<xsl:template match="demo/stock"/>
</xsl:stylesheet>


Thank you

Peter

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.