This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] HowTo get docbook <acronym> elements to be in html like a real html acronym
- From: Bob Stayton <bobs at sco dot com>
- To: Claus Klein <claus dot klein at arcormail dot de>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Sun, 30 Nov 2003 18:24:19 -0800
- Subject: Re: [docbook-apps] HowTo get docbook <acronym> elements to be in html like a real html acronym
- References: <200311302257.06779.claus.klein@arcormail.de>
On Sun, Nov 30, 2003 at 10:57:06PM +0100, Claus Klein wrote:
> Hello!
>
> As I was reading the article on
> http://diveintoaccessibility.org/day_17_defining_acronyms.html
> for me the question was:
> How can I get automatically <acronym> elements to be in HTML like a real HTML acronym,
> e.g. <acronym title="Document Object Model">DOM</acronym> ?
>
> Based on an acronym list like that:
>
> HTML
> DOM
> ..
> RFC
> XML
> XSL
> XSLT
>
> I create with a perl script a docbook glossary from a foldoc dictionary server
> (dict.org or my local dictd) like this:
>
> <glossentry>
> <glossterm><anchor id="glossterm-XML"/>XML</glossterm>
> <glossdef>
> <para>
> <glossterm>Extensible Markup Language</glossterm>
> </para>
> </glossdef>
> </glossentry>
> <glossentry>
> <glossterm><anchor id="glossterm-XSL"/>XSL</glossterm>
> <glossdef>
> <para>
> <glossterm>Extensible Stylesheet Language</glossterm>
> </para>
> </glossdef>
> </glossentry>
> <glossentry>
> <glossterm><anchor id="glossterm-XSLT"/>XSLT</glossterm>
> <glossdef>
> <para>
> <glossterm>Extensible Stylesheet Language Transformations</glossterm>
> </para>
> </glossdef>
> </glossentry>
>
> and in my customization stylesheet I added this:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
> <!--
> or href="http://docbook.sourceforge.net/release/website/current/xsl/website.xsl"
> -->
>
> <xsl:param name="generate.acronym.link" select="'1'"/>
> <xsl:variable name="acronym.database"
> select="document('acronym.xml')//glossary"/>
> <xsl:key name="glossary-glossentry" match="//glossentry" use="glossterm" />
>
> <!-- ==================================================================== -->
> <xsl:template match="acronym">
> <xsl:choose>
> <xsl:when test="$generate.acronym.link != '0'">
> <xsl:call-template name="generate.acronym.link"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:call-template name="inline.charseq"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> <!-- ==================================================================== -->
> <xsl:template name="generate.acronym.link">
> <xsl:param name="acronym">
> <xsl:apply-templates/>
> <!-- ###FIXME###: do I need this?
> <xsl:call-template name="anchor"/>
> <xsl:call-template name="simple.xlink">
> <xsl:with-param name="content">
> <xsl:apply-templates/>
> </xsl:with-param>
> </xsl:call-template>
> -->
> </xsl:param>
> <!--
> We use for-each to change context to the database document because key()
> only locates elements in the same document as the context node!
> -->
> <xsl:param name="value" >
> <xsl:for-each select="$acronym.database">
> <xsl:value-of select="key('glossary-glossentry', $acronym)/glossdef/para/glossterm[1]" />
> </xsl:for-each>
> </xsl:param>
> <xsl:choose>
> <xsl:when test="$value=''">
> <!-- debug -->
> <xsl:message>
> In mystyle.xsl: For acronym (<xsl:value-of select="$acronym"/>) no value found!
> </xsl:message>
> <a>
> <xsl:attribute name="href">
> <xsl:text>http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=</xsl:text>
> <xsl:value-of select="$acronym"/>
> </xsl:attribute>
> <xsl:call-template name="inline.charseq"/>
> </a>
> </xsl:when>
> <xsl:otherwise>
> <!-- found -->
> <acronym>
> <xsl:attribute name="title">
> <xsl:value-of select="$value"/>
> </xsl:attribute>
> <xsl:call-template name="inline.charseq"/>
> </acronym>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> </xsl:stylesheet>
>
> This works for a docbook website too and the glossary is 100% docbook, so I can reuse it as it is!
>
> The only thing I have to do is to mark the acronyms in my docbook xml sources
> .. <acronym>XSLT</acronym> ...
> to get the acronym explained in my HTML documents.
Hi Claus,
This looks very interesting. Are you proposing that
this feature be added to the stylesheet distribution?
> The only questionable point for me is:
>
> <!-- ###FIXME###: do I need this?
> <xsl:call-template name="anchor"/>
> <xsl:call-template name="simple.xlink">
> ..
> -->
Only if you want your acronyms to be processed in
a manner consistent with other inlines. The
'anchor' template outputs a <a name="$id"/>
if the inline has an id attribute, and the
simple.xlink template outputs an xlink if
the inline has a xlink:href attribute. If
you don't use those, then you don't need them.
If your code is added to the stylesheet distribution,
it will need them.
--
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
The SCO Group fax: (831) 429-1887
email: bobs@sco.com
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.