[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: xhtml via xslt failure
Hi again, On Tue, Dec 17, 2013 at 2:02 PM, Martin Holmes <mholmes@xxxxxxx> wrote: > I think when you're getting started, it doesn't really help much to read the specifications; I'd do some > tutorials first. The specs are hard to grasp unless you're already fairly comfortable with basic XSLT. This is good advice. Learner: the tests for preceding or following sibling 'author' elements will only work within the context of children of 'book' elements, such as the 'author' elements. Evaluated in the context of the 'book', you never have 'author' element siblings at all (by design), so these tests always return false. Here is a working example. It makes assumptions that are not spelled out here. <xsl:template match="bookstore/book"> <!-- for the book, we want a paragraph, with only authors, no other details; document order is retained --> <p> <xsl:apply-templates select="author"/> </p> </xsl:template> <xsl:template match="author"> <!-- we punctuate according to rules of displaying a series of authors (adjust to requirements) --> <xsl:choose> <!-- XPath 1.0 casts node sets to Boolean values as preceding or sibling 'author' elements are found (or not) --> <xsl:when test="preceding-sibling::author and not(following-sibling::author)"> and </xsl:when> <xsl:when test="preceding-sibling::author">, </xsl:when> </xsl:choose> <!-- processing child nodes, values of text contents will be emitted by default --> <xsl:apply-templates/> </xsl:template> I hope that helps. Cheers, Wendell Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|