forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sina K. Heshmati (JIRA)" <>
Subject [jira] Commented: (FOR-1167) class attribute of body element in XDocs source is not included in generated HTML
Date Sun, 24 May 2009 10:30:45 GMT


Sina K. Heshmati commented on FOR-1167:

@class is properly handled in xhtml2_to_html.xsl. Now, the questions is whether this stylesheet
is used somewhere in the process of generating the final output. There's a pipeline that transforms
XDoc into XHTML2 (i.e. internal.**.*) but no other pipeline seems to be calling it.

document-to-html.xsl still helps us copy <html:body> attributes to e.g. <div id="content">
making them available in **.body.xml, which we could pass as data to a contract as follows:

<forrest:contract name="convey-body-class-attrib" dataURI="cocoon://#{$getRequest}.body.xml"/>

Here's the contract itself:

  <forrest:template xmlns:forrest=""
    name="convey-body-class-attrib" inputFormat="xsl">
    <xsl:stylesheet version="1.1" xmlns:xsl="">
      <xsl:template match="/">
          <forrest:part xpath="/html/body">
            <xsl:apply-templates select="//div[@id='content']/@*" mode="carry-body-attribs"/>
      <xsl:template match="@id" mode="carry-body-attribs">
        <!-- Ignore @id -->
      <xsl:template match="@class" mode="carry-body-attribs">
        <xsl:attribute name="class">
          <xsl:value-of select="."/>

The above contract tries to insert @class but *to which node* (?) We can be sure that this
contract is called right after the body element by calling it right after /html/head contracts
but it still doesn't add the attribute to the <body>. This is consistent with my earlier
guess suggesting that <body> is not generated by XSLT stylesheets.

<html:body> is generated by org.apache.forrest.dispatcher.transformation.DispatcherTransformer.

private void contractProcessingEnd() throws SAXException {
  else {
    xpathNode = createXpathNode(location);
    appendChildToResultIterator(root, finalContent, xpathNode);

The above solution didn't work because we were trying to add *just an attribute* to a node.
It would have worked if we had to add an element. So one possible fix is to hack
so that nodes that only consist of attributes are also added to the result document.

A more elegant solution is to make good use of @xpath e.g.:

<forrest:part xpath="/html/body/@class">
  <xsl:apply-templates select="//div[@id='content']/@*" mode="carry-body-attribs"/>
<xsl:template match="@class" mode="carry-body-attribs">
  <xsl:value-of select="."/>

This won't work either because @xpath is limited to simple expressions such as /html/body
and does not support more complex XPath expressions. This issue has already been discussed
[1] with Thorsten. I think this is a feature worth implementing.

So the idea is for a contract to choose where to add the content it generates. The target
node is selected using @xpath and it shouldn't matter how complex the XPath expression is
as long as the move is valid and there are no conflicts between nodes.


> class attribute of body element in XDocs source is not included in generated HTML
> ---------------------------------------------------------------------------------
>                 Key: FOR-1167
>                 URL:
>             Project: Forrest
>          Issue Type: Bug
>          Components: Plugin: internal.dispatcher, Plugin: themes.core, Skins (general
>    Affects Versions: 0.9-dev
>            Reporter: Brolin Empey
>             Fix For: 0.9-dev
>         Attachments: FOR-1167-skins.patch
> Here is the body element of my XDocs source file:
> <body class="product_heading">
> The generated HTML does not include the class attribute.
> See <>.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message