On Fri, Sep 30, 2011 at 1:11 AM, Peter Desjardins <
[email protected]> wrote:
>
> 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.
>
Yes, <xsl:comment> is really needed in this kind of scenarios. Further, It
is needed when specifying JavaScript files in the xsl sheet as well.
When processed a sheet with following <script> tag via Saxon,
xsl -
<script type="text/javascript" src="{$webhelp.common.dir}
jquery/jquery-1.4.2.min.js">
</script>
this gets transformed to xhtml as -
<script type="text/javascript" src="../common/jquery/jquery-1.4.2.min.js"*/>
*
Since there isn't any text content inside <script> tag, Saxon compress it in
to "/>". This makes the browser not detect the other scripts next to this.
So, I had to change it to following to make it work.
<script type="text/javascript" src="{$webhelp
.common.dir}jquery/jquery-1.4.2.min.js">
* <xsl:comment> </xsl:comment>*
</script>
This issue was with Saxon. xsltproc works as expected.
--Kasun
> 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 > 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 > 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
--
~~~*******'''''''''''''*******~~~
Kasun Gajasinghe,
University of Moratuwa,
Sri Lanka.
Blog: http://kasunbg.blogspot.com
Twitter: http://twitter.com/kasunbg