This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: xhtml transform problems


Jirka Kosek <jirka@kosek.cz> writes:

> Eric Richardson wrote:
> 
> > [...]
> > This piece of xhtml won't validate as only inline and special
> > block(map, applet etc.) are allowed inside of <p> whereas <pre> is
> > block, from what I can gather from the DTD and the nsgmls
> > validation error.
> 
> DocBook allows elements like screen inside para. Stylesheet only
> converts DocBook <para>s to HTML <p>s and <screen>s to <pre>s. If you
> want to get correct HTML output, write screens on same level as paras:

I was going to say the same thing, but I reckon Eric's got a reason
for marking it up as he did-- there's a value in using para as the
same container for both the intro text and the <screen>.

> Cleaner solution would be to modify stylesheet to handle your code in
> proper way. This is doable in theory, but it would make stylesheet much
> more complicated and complex.

Well, I can think of one easy stylesheet tweak: change the "para"
template to generate <div class="para"> instead of <p>. Maybe a case
of a cure worse than the disease, because it'll change globally. But
not that big of a deal for anybody already using CSS to style pages.

I don't think it's a long-term solution, but until a better one comes
along... this one's not complicated, at least-- just change two lines
in one template, drop it into a customization file:


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
		xmlns:doc="http://nwalsh.com/xsl/documentation/1.0";
		exclude-result-prefixes="doc"
		version='1.0'>

<xsl:import
  href="/usr/lib/sgml/stylesheet/xsl/docbook/nwalsh/xhtml/docbook.xsl"/>

<!-- ********************************************************************
     Simple DocBook stylesheet customization to generate <div class="para">
     in place of <p> (globally); prevents invalid instances where HTML
     block elements end up inside <p>, e.g. <p><pre></pre></p> 
     (<p> in HTML can only contain inline elements)

     Will need to use CSS to style div.para (e.g. margin-top & -bottom)

     ******************************************************************** -->

<xsl:template match="para">
  <div class="para">
    <xsl:if test="position() = 1 and parent::listitem">
      <a>
        <xsl:attribute name="name">
          <xsl:call-template name="object.id">
            <xsl:with-param name="object" select="parent::listitem"/>
          </xsl:call-template>
        </xsl:attribute>
      </a>
    </xsl:if>

    <xsl:if test="@id">
      <a name="{@id}"/>
    </xsl:if>
    <xsl:apply-templates/>
  </div>
</xsl:template>

</xsl:stylesheet>




------------------------------------------------------------------
To unsubscribe from this elist send a message with the single word
"unsubscribe" in the body to: docbook-apps-request@lists.oasis-open.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]