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

RE: alphabetic counters

Subject: RE: alphabetic counters
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 10 May 2004 18:30:00 +0200
xslt value of cdata
> -----Original Message-----
> From: Nicholas Shanks [mailto:contact@xxxxxxxxxxxxxx]
>
>
> What my problem is, is that references like the above are supposed to
> be suffixed by a lower case alphabetic character ('a', 'b', etc.) after
> the year if there are multiple 'citation' elements with identical
> values for 'author' and 'year'. I have no idea how to go about doing
> this. Can anyone suggest how to do this?
>

Hi,

I think you can use xsl:number to achieve this (?)

Also, this XSLT fragment:

<xsl:for-each select="reference">
   <xsl:text disable-output-escaping="yes"><![CDATA[<a
href="#]]></xsl:text><xsl:value-of select="@cite"/><xsl:text
disable-output-escaping="yes"><![CDATA[">]]></xsl:text>
   <xsl:value-of select="id(@cite)/@author" />
   <xsl:if test="id(@cite)/@year != ''"><xsl:text>
</xsl:text><xsl:value-of select="id(@cite)/@year" /></xsl:if>
   <xsl:text disable-output-escaping="yes"><![CDATA[</a>]]></xsl:text>
   <xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:for-each>

Is the same as:

<xsl:for-each select="reference">
  <a href="{concat('#',@cite)}">
    <xsl:value-of select="id(@cite)/@author" />
    <xsl:if test="id(@cite)/@year != ''">
      <xsl:text> </xsl:text>
      <xsl:value-of select="id(@cite)/@year" />
    </xsl:if>
  </a>
  <xsl:if test="position() != last()">
    <xsl:text>, </xsl:text>
  </xsl:if>
</xsl:for-each>

Remember: with XSLT you're outputting nodes rather than tags --IOW default
output is XML, while text output needs to be explicitly set.
So, generally speaking, you won't need to use <![CDATA[...]]> unless it is
*absolutely* necessary. A combination of CDATA and disable-output-escaping
is hinting that they're both superfluous (i.e. they serve no purpose in this
case but to make your code less readable --Hey, some developers like it that
way, as a form of long-term job-protection ;-)
Another purpose they serve is to trick the XSL processor into thinking that
it is *not* outputting XML while it actually is...

Starting from the above, a possible solution would look like:

<xsl:for-each select="reference">
  <a>
    <xsl:attribute name="href">
      <xsl:value-of select="concat('#',@cite)" />
      <xsl:number count="/catalogue/citation[
                    @author=id(@cite)/@author and
                    @year=id(@cite)/@year]"
                  format="a"/>
    </xsl:attribute>
    <xsl:value-of select="id(@cite)/@author" />
    <xsl:if test="id(@cite)/@year != ''">
      <xsl:text> </xsl:text>
      <xsl:value-of select="id(@cite)/@year" />
    </xsl:if>
  </a>
  <xsl:if test="position() != last()">
    <xsl:text>, </xsl:text>
  </xsl:if>
</xsl:for-each>

HTH!

Greetz,

Andreas

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.