[ https://issues.apache.org/jira/browse/FOR-1167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712538#action_12712538 ]
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="http://apache.org/forrest/templates/1.0" name="convey-body-class-attrib" inputFormat="xsl"> <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <forrest:content> <forrest:part xpath="/html/body"> <xsl:apply-templates select="//d...@id='content']/@*" mode="carry-body-attribs"/> </forrest:part> </forrest:content> </xsl:template> <xsl:template match="@id" mode="carry-body-attribs"> <!-- Ignore @id --> </xsl:template> <xsl:template match="@class" mode="carry-body-attribs"> <xsl:attribute name="class"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> </xsl:stylesheet> </forrest:template> 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 DispatcherTransformer.java 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="//d...@id='content']/@*" mode="carry-body-attribs"/> </forrest:part> ... <xsl:template match="@class" mode="carry-body-attribs"> <xsl:value-of select="."/> </xsl:template> 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. [1] http://markmail.org/message/zgispeyrmmwfej3e > class attribute of body element in XDocs source is not included in generated > HTML > --------------------------------------------------------------------------------- > > Key: FOR-1167 > URL: https://issues.apache.org/jira/browse/FOR-1167 > Project: Forrest > Issue Type: Bug > Components: Plugin: internal.dispatcher, Plugin: themes.core, Skins > (general issues) > 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 <http://thread.gmane.org/gmane.text.xml.forrest.devel/27106>. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.