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] | [List Home]


Subject: Empty div tag in XHTML partintro throws CSS off


Hi. I'm using DocBook 5.0, stylesheets docbook-xsl-ns-1.76.1, and the
webhelp output which generates XHTML.

I noticed a CSS problem with the first XHTML chunk for a part. My book
is divided into parts. The parts have partintro elements but there are
no titles for the partintros. Nor anything else that might go into the
titlepage.

So I discovered that my CSS was being thrown off by the empty <div />
tag in the div for my partintro. The browser ended up thinking that
the header and navigation divs were children of the content div.
Hijinks ensue.

The offending code:

<div xmlns="" xmlns:d="http://docbook.org/ns/docbook";
    class="partintro"
    title="My Title">
  <div />
  <p xmlns="http://www.w3.org/1999/xhtml"; class="body">This part is about...</p>
</div>

I added a comment at the end of the partintro:titlepage template to
prevent XHTML from writing the empty div element. I guess I could have
turned off the call to this template if it's not needed. But I don't
know all the situations in which it's needed.

This seems to work (I had to declare the exsl namespace in my
customization stylesheet).

<xsl:template name="partintro.titlepage">
  <div>
    <xsl:variable name="recto.content">
      <xsl:call-template name="partintro.titlepage.before.recto"/>
      <xsl:call-template name="partintro.titlepage.recto"/>
    </xsl:variable>
    <xsl:variable name="recto.elements.count">
      <xsl:choose>
        <xsl:when
test="function-available('exsl:node-set')"><xsl:value-of
select="count(exsl:node-set($recto.content)/*)"/></xsl:when>
        <xsl:when test="contains(system-property('xsl:vendor'),
'Apache Software Foundation')">
          <!--Xalan quirk--><xsl:value-of
select="count(exsl:node-set($recto.content)/*)"/></xsl:when>
        <xsl:otherwise>1</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:if test="(normalize-space($recto.content) != '') or
($recto.elements.count &gt; 0)">
      <div><xsl:copy-of select="$recto.content"/></div>
    </xsl:if>
    <xsl:variable name="verso.content">
      <xsl:call-template name="partintro.titlepage.before.verso"/>
      <xsl:call-template name="partintro.titlepage.verso"/>
    </xsl:variable>
    <xsl:variable name="verso.elements.count">
      <xsl:choose>
        <xsl:when
test="function-available('exsl:node-set')"><xsl:value-of
select="count(exsl:node-set($verso.content)/*)"/></xsl:when>
        <xsl:when test="contains(system-property('xsl:vendor'),
'Apache Software Foundation')">
          <!--Xalan quirk--><xsl:value-of
select="count(exsl:node-set($verso.content)/*)"/></xsl:when>
        <xsl:otherwise>1</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:if test="(normalize-space($verso.content) != '') or
($verso.elements.count &gt; 0)">
      <div><xsl:copy-of select="$verso.content"/></div>
    </xsl:if>
    <xsl:call-template name="partintro.titlepage.separator"/>
    <xsl:comment>I prevent XHTML output from writing an empty div
tag.</xsl:comment>
  </div>
</xsl:template>

Peter


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