[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: HowTo get docbook <acronym> elements to be in html like a real html acronym
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. The only questionable point for me is: <!-- ###FIXME###: do I need this? <xsl:call-template name="anchor"/> <xsl:call-template name="simple.xlink"> ... --> Claus Klein
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]