[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] passing attributes from an ARTICLE element to an HTML element
Hi Robert,
To insert an id attribute in the <html> element, you'll need to customize the template
named 'chunk-element-content' in xhtml/chunk-common.xsl. That is where the <html>
element is generated. You could add a template call after the opening <html> to
insert any attributes. Since that template is used for all chunks, I would suggest
using a mode to just change article:
[in customized chunk-element-content]
<html>
<xsl:apply-templates select="." mode="html.root.attributes"/>
...
where mode="html.root.attributes" is new for your purposes. You would create a
general template that does nothing, and a special one for article:
<!-- for all other elements do nothing -->
<xsl:template match="*" mode="html.root.attributes"/>
<!-- for article, add two attributes -->
<xsl:template match="d:article" mode="html.root.attributes">
<xsl:attribute name="id">
<xsl:call-template name="object.id"/>
</xsl:attribute>
<xsl:attribute name="lang">
<xsl:call-template name="l10n.language"/>
</xsl:attribute>
</xsl:template>
To avoid the duplicate id on the div, you need to customize the template that matches
on d:article in xhtml/component.xsl. After the opening <div> tag, it calls a template
named 'common.html.attributes', and then generates the id attribute. Delete the id
part and that should do it.
When you customize the d:article template, be aware that you must follow the
guidelines for customizing chunked output, and put it in a separate customization
layer that imports docbook.xsl. That's because the template in component.xsl is not a
chunking template, it is a template for element formatting. If you don't separate
them, you probably won't get output for your article. See this reference for details:
http://www.sagehill.net/docbookxsl/ChunkingCustomization.html
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net
----- Original Message -----
From: "Robert Pasternak" <rp.info@gmail.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Friday, February 25, 2011 12:57 AM
Subject: [docbook-apps] passing attributes from an ARTICLE element to an HTML element
> Hi
>
> My Docbook based project has a modular structure, where each xml file
> starts with an article element. Each article element specifies two
> attributes: xml:id and xml:lang. For HTML output I use the
> xhtml/profile-chunk.xsl transformation, and each article is
> transformed into a standalone html file. The two attributes are added
> to the div element containing the contents of the article, however I
> would like these two attributes to be added to the enclosing html
> element. And so, the first question is how to do that, and the second
> is how to remove the xml:id attribute from the div element, so there
> are no duplicated ids within the single html file.
>
> Thanks,
> Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>
>
>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]