docbook-apps

  • 1.  Empty div tag in XHTML partintro throws CSS off

    Posted 09-29-2011 19:42
    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

    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:

    class="partintro"
    title="My Title">

    This part is about...




    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">

    <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')">
    <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)">
    <xsl:copy-of select="$recto.content"/>

    </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')">
    <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)">
    <xsl:copy-of select="$verso.content"/>

    </xsl:if>
    <xsl:call-template name="partintro.titlepage.separator"/>
    <xsl:comment>I prevent XHTML output from writing an empty div
    tag.</xsl:comment>

    </xsl:template>

    Peter



  • 2.  Re: [docbook-apps] Empty div tag in XHTML partintro throws CSS off

    Posted 10-02-2011 07:13
    On Fri, Sep 30, 2011 at 1:11 AM, Peter Desjardins <
    peter.desjardins.us@gmail.com> 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

    > 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

    this gets transformed to xhtml as -


    This issue was with Saxon. xsltproc works as expected.

    --Kasun


    > The offending code:
    >
    >
    > class="partintro"
    > title="My Title">
    >

    >

    This part is
    about...


    >

    >
    > 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">
    >

    > <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')">
    > <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)">
    >
    <xsl:copy-of select="$recto.content"/>

    > </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')">
    > <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)">
    >
    <xsl:copy-of select="$verso.content"/>

    > </xsl:if>
    > <xsl:call-template name="partintro.titlepage.separator"/>
    > <xsl:comment>I prevent XHTML output from writing an empty div
    > tag.</xsl:comment>
    >

    > </xsl:template>
    >
    > Peter
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >



    --
    ~~~*******'''''''''''''*******~~~
    Kasun Gajasinghe,
    University of Moratuwa,
    Sri Lanka.
    Blog: http://kasunbg.blogspot.com
    Twitter: http://twitter.com/kasunbg



  • 3.  Re: [docbook-apps] Empty div tag in XHTML partintro throws CSS off

    Posted 10-02-2011 09:02
    On 2.10.2011 9:13, Kasun Gajasinghe wrote:

    > This issue was with Saxon. xsltproc works as expected.

    Might be my recollection is wrong, but shouldn't following settings
    produce correct output for empty elements like div and script in Saxon 6:

    <xsl:param name="chunker.output.method">saxon:xhtml</xsl:param>
    <xsl:param name="chunker.output.omit-xml-declaration">yes</xsl:param>


    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    ------------------------------------------------------------------




  • 4.  Re: [docbook-apps] Empty div tag in XHTML partintro throws CSS off

    Posted 10-02-2011 11:24
    On Sun, Oct 2, 2011 at 2:32 PM, Jirka Kosek <jirka@kosek.cz> wrote:

    > On 2.10.2011 9:13, Kasun Gajasinghe wrote:
    >
    > > This issue was with Saxon. xsltproc works as expected.
    >
    > Might be my recollection is wrong, but shouldn't following settings
    > produce correct output for empty elements like div and script in Saxon 6:
    >
    > <xsl:param name="chunker.output.method">saxon:xhtml</xsl:param>
    > <xsl:param name="chunker.output.omit-xml-declaration">yes</xsl:param>
    >
    >
    You are right. These two params did correct the output. Thanks, I wasn't
    aware of that.
    There's another issue now. Since chunker.output.method is set to
    "saxon:xhtml", will it support other xslt processors? In xsltproc with the
    said two params, the webhelp output generated the following errors.

    Writing docs/content/ch04.html for chapter
    runtime error: file ../xhtml/chunker.xsl line 143 element document
    xsltDocumentElem: unsupported method xhtml
    Writing docs/content/index.html for book
    runtime error: file ../xhtml/chunker.xsl line 143 element document
    xsltDocumentElem: unsupported method xhtml
    Writing docs/index.html
    Writing docs/content/search/l10n.js
    no result for docsrc/readme.xml
    make: *** [webhelp] Error 9

    So, does that the better way for this is to create another customization
    layer that imports webhelp.xsl, and add these params to it? May be there's
    better solutions out there.

    Thanks,
    --Kasun


    >
    > Jirka
    >
    > --
    > ------------------------------------------------------------------
    > Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    > ------------------------------------------------------------------
    > Professional XML consulting and training services
    > DocBook customization, custom XSLT/XSL-FO document processing
    > ------------------------------------------------------------------
    > OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    > ------------------------------------------------------------------
    >
    >


    --
    ~~~*******'''''''''''''*******~~~
    Kasun Gajasinghe,
    University of Moratuwa,
    Sri Lanka.
    Blog: http://kasunbg.blogspot.com
    Twitter: http://twitter.com/kasunbg



  • 5.  Re: [docbook-apps] Empty div tag in XHTML partintro throws CSS off

    Posted 10-02-2011 15:36
    On 2.10.2011 13:24, Kasun Gajasinghe wrote:

    > So, does that the better way for this is to create another customization
    > layer that imports webhelp.xsl, and add these params to it?

    Indeed, saxon:xhtml output method works only in Saxon so one have to put
    it into customization layer.

    Or it can be set conditionally in webhelp.xsl using something like:

    <xsl:param name="chunker.output.method">
    <xsl:choose>
    <xsl:when test="contains(system-property('xsl:vendor'), 'SAXON
    6')">saxon:xhtml</xsl:when>
    <xsl:otherwise>xml</xsl:otherwise>
    </xsl:choose>
    </xsl:param>

    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    ------------------------------------------------------------------




  • 6.  Re: [docbook-apps] Empty div tag in XHTML partintro throws CSS off

    Posted 10-03-2011 06:20
    On Sun, Oct 2, 2011 at 9:06 PM, Jirka Kosek <jirka@kosek.cz> wrote:
    >
    > On 2.10.2011 13:24, Kasun Gajasinghe wrote:
    >
    > > So, does that the better way for this is to create another customization
    > > layer that imports webhelp.xsl, and add these params to it?
    >
    > Indeed, saxon:xhtml output method works only in Saxon so one have to put
    > it into customization layer.
    >
    > Or it can be set conditionally in webhelp.xsl using something like:
    >
    > <xsl:param name="chunker.output.method">
    >  <xsl:choose>
    >    <xsl:when test="contains(system-property('xsl:vendor'), 'SAXON
    > 6')">saxon:xhtml</xsl:when>
    >    <xsl:otherwise>xml</xsl:otherwise>
    >  </xsl:choose>
    > </xsl:param>
    >

    Added to webhelp and committed. It should be "SAXON 6" (with a space)
    which you correctly added. But how it's displayed in text format has
    confused me a little at first. I've set html for "otherwise" which was
    the default in webhelp before.

    Thanks,
    --Kasun

    >
    >                                        Jirka
    >
    > --
    > ------------------------------------------------------------------
    >  Jirka Kosek      e-mail: jirka@kosek.cz      http://xmlguru.cz
    > ------------------------------------------------------------------
    >       Professional XML consulting and training services
    >  DocBook customization, custom XSLT/XSL-FO document processing
    > ------------------------------------------------------------------
    >  OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    > ------------------------------------------------------------------
    >



    --
    ~~~*******'''''''''''''*******~~~
    Kasun Gajasinghe,
    University of Moratuwa,
    Sri Lanka.
    Blog: http://kasunbg.blogspot.com
    Twitter: http://twitter.com/kasunbg