OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: DOCBOOK-APPS: Escaping quotes on generated HtmlHelp .hhc .hhk files


Just a brief description of what I'm currently tryng
to do: I'm
trying to generate Microsoft Compiled HTML Help (CHM)
and DevHelp
(which is also a online help system for GNOME)
electronic books from the 
GNU utils using the DocBook XML stylesheets. The GNU
tools are in Texinfo 
format, and I've already produced these documents
using adapted versions 
of the texi2html script but the results start to be
very poor as this 
script got deprecated. So I decided to use DocBook XML
as intermediate 
format - makeinfo has now a DocBook XML backend - as
investements in XML 
seemed much more rewarding in the long run.

DevHelp specs files are XML files themselves, so the
stylesheet I use for it
is actually a trimmed down version of
htmlhelp-common.xsl.

The problem (to both systems) is that some of the GNU
manuals have nasty 
stuff on the titles (such as quotes and backslashes,
i.e., " ' \ ) and that 
breaks the generated .HHC/HHK and Devhelp specs. To be
more specific
that generates invalid XML in the DevHelp case, but
Microsoft HTML Help
compiler still reads the .HHC/HHK but the titles get
all wrong in some
cases.

The only solution I got so far from googling around is
to use recursive 
template based on
http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20005847.html
and call it from everywhere:

<xsl:template name="escape.attribute">
  <xsl:param name="text" />
  <xsl:if test="string-length($text &gt; 0)">
     <xsl:variable name="char"
select="substring($text,1,1)"/>
     <xsl:choose>
        <xsl:when test="$char =
'&#x22;'"><![CDATA[&#x22;]]></xsl:when>
        <xsl:when test="$char =
'&#x26;'"><![CDATA[&#x26;]]></xsl:when>
        <xsl:when test='$char =
"&#x27;"'><![CDATA[&#x27;]]></xsl:when>
        <xsl:when test="$char =
'&#x5c;'"><![CDATA[&#x5c;]]></xsl:when>
        <xsl:otherwise><xsl:value-of
select="$char"/></xsl:otherwise>
     </xsl:choose>
     <xsl:if test="string-length($text) &gt; 1">
        <xsl:call-template name="escape.attribute">
           <xsl:with-param name="text"
select="substring($text,2)"/>
        </xsl:call-template>
     </xsl:if>
  </xsl:if>
</xsl:template>

I saw a more efficient way one on
http://www.biglist.com/lists/xsl-list/archives/200103/msg00227.html
,
but is also recursive (not yet tested):

<xsl:template name="escape.attribute">
  <xsl:param name="text" />
  <xsl:choose>
    <xsl:when test="contains($text, '&#x22;')">
      <xsl:value-of select="substring-before($text,
'&#x22;')" />
      <![CDATA[&#x22;]]>
      <xsl:call-template name="escape.attribute">
        <xsl:with-param name="text"
select="substring-after($text, '&#x22;')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="contains($text, '&#x26;')">
      <xsl:value-of select="substring-before($text,
'&#x26;')" />
      <![CDATA[&#x26;]]>
      <xsl:call-template name="escape.attribute">
        <xsl:with-param name="text"
select="substring-after($text, '&#x26;')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:when test='contains($text, "&#x27"')'>
      <xsl:value-of select='substring-before($text,
"&#x27;")' />
      <![CDATA[&#x27;]]>
      <xsl:call-template name="escape.attribute">
        <xsl:with-param name="text"
select='substring-after($text, "&#x27;")' />
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="contains($text, '&#x5c;')">
      <xsl:value-of select="substring-before($text,
'&#x5c;')" />
      <![CDATA[&#x5c;]]>
      <xsl:call-template name="escape.attribute">
        <xsl:with-param name="text"
select="substring-after($text, '&#x5c;')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$text" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

My primary question is if is there any other [more
efficient] way to do 
this?

My secondary question is if you are interested in fix
this on the
docbook-xsl distribution too.

Thanks in advance,

Jose Fonseca

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC