OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: RE: [docbook-apps] Adding processing based on an attribute value


There is a way to achieve something similar to what you
want, if you don't mind pre-processing the document.

The method involves wrapping the elements in the source
document that should be oulined, so that when the real
FO transformation occurs, the wrappers trigger an FO
instruction to change color.

Step 1

The first step is this XSL:

<xsl:template match="*">
		<xsl:copy-of select="@*"/>

<xsl:template match="db:para[@someAttr='someValue']|
			<xsl:copy-of select="@*"/>

<xsl:template match="db:phrase[@someAttr='someValue']">
			<xsl:copy-of select="@*"/>

The first template simply copies all elements that
are not to be touched; the second and third template
are identical but one deals with block elements and
the other with inline elements, since they should
receive a different treatment in the resulting FO.

One could of course write match="*[@someAttr='someValue']"
and then have ifs and whens inside the template, but
I find the multi-template approach clearer.

Step 2

The resulting document has all its para elements
with attribute someAttr=someValue wrapped into
a 'myBlockWrapper' element. (It is of course not
DocBook valid, but it is only a temporary document).

Then all is left is to add these two templates in
your customization layer:

<xsl:template match="myBlockWrapper">
	<fo:block color="red">

<xsl:template match="myInlineWrapper">
	<fo:inline color="red">

The result is a valid FO document that has all the
wrapped elements in red.

Now, to find which and how each element should be
wrapped, it is proably necessary to proceed by trial
and error, since not all elements may support the
same wrapping method in the resulting FO.

For example, you can't simpy wrap a listitem element,
(because there is no template match="listitem" in the
stylesheets) but you can either wrap what's inside, or
wrap a parent itemizedlist for example (which makes
sense, since if a listitem has been modified it is
probably better to proof read the whole list).

Also, if the document has component elements that
should be outlined (such as chapters, etc.) a slightly
different method could be necessary (ie change the
page setup, etc.)



> -----Original Message-----
> From: Jeff Hooker [mailto:Jeff_Hooker@pmc-sierra.com]
> Sent: Thursday, March 20, 2008 10:10 PM
> To: docbook-apps@lists.oasis-open.org
> Subject: [docbook-apps] Adding processing based on an attribute value
> Hi all,
> I'm using Docbook XSL 1.73.2 and FOP 0.93.
> Is there any straightforward way of checking to see if every
> element in a document has a specific attribute attached, and if,
> so adding some additional attributes to its block or inline
> element in the FO output, and doing this without having to
> rewrite vast stretches of the stylesheets?
> The basic need is that in my current PDF output, my reviewers
> have no way of knowing if the content they're viewing is aimed at
> a specific audience (small parts of many documents are specific
> to certain suppliers or customers), so I'd like to cycle through
> every element and add some styling to the block or inline element
> (i.e. make it red) in the event that it is audience-specific. So
> far I can't find any way of doing this that doesn't involve a
> mass of element-level modifications, to the point where my
> modification layer basically contains most of the FO stylesheets.
> Am I overcomplicating this? Any advice on a more intelligent
> approach would be appreciated.
> Regards,
> Jeff.
> ---------------------------------------------------------------------
> 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]