[xsl] Relative/Absolute path queries?

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

I have an another question:


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

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"
<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
<xsl:template match="demo/stock"/>

Thank you


Current Thread