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

Re: Re: xhtml via xslt failure

Subject: Re: Re: xhtml via xslt failure
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxx>
Date: Tue, 17 Dec 2013 14:42:49 -0500
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_^

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.