Subject: [xsl] Relative/Absolute path queries? From: "peter verhaar" <peter.verhaar1@xxxxxxxxx> Date: Thu, 11 Dec 2008 11:30:31 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] removing trailing space f, Michael Kay | Thread | Re: [xsl] Relative/Absolute path qu, David Carlisle |
Re: [xsl] removing trailing space f, George Cristian Bina | Date | RE: [xsl] removing trailing space f, Michael Kay |
Month |