Re: Creating Styles for an Attribute

Bob Stayton <[email protected]> Sat, 11 Sep 2021 01:10:11 -0700
Newsgroups gmane.text.docbook.apps
Message-ID <[email protected]>
Hi Beth,

There is a technique that will conditionally add color to literal text 
regardless of its element.  Something like this:

<xsl:template match="text()[ancestor::*[@doc = 'FAT']]">
   <fo:inline color="red">
     <xsl:apply-imports/>
   </fo:inline>
</xsl:template>

and similar templates for other attribute values and colors.

This matches on any text() node if it has an ancestor element matching 
your attribute value, and wraps that text in an <fo:inline> to color 
it.  It does not interfere in how each element is otherwise handled 
because it only operates on text nodes.

It's main limitation is that it only is applied to text nodes in your 
XML document, and so would not color generated text (like "Note" or 
xrefs) or any rule lines.  If you can live with that limitation then 
this is a simple solution.

Bob Stayton
[email protected]

On 9/10/2021 12:19 PM, Beth Van Wie wrote:
>
> Hello,
>
> IÂ’m trying to customize the Docbook stylesheets so my profiling 
> attributes will produce colored text when I build the document without 
> profiling. I currently have stylesheets that pull out the profiled 
> information as needed, and I want to create a new stylesheet that uses 
> the same attributes, does not profile, and colors the profiled sections.
>
> I currently use the attribute doc=”” to profile my documents.
>
> For example:
>
> <para doc=”FAT”> </para>
>
> <step doc=”SAT”> </step>
>
> I commonly profile the following elements: para, row, step, procedure, 
> section, table, figure, lists (different kinds of lists), and others.
>
> I was able to write a stylesheet that would do this for a para 
> element, and for a para element inside a step element, but the way I 
> am doing it, I will have to write a new template for each element. Is 
> there a way I can write one template to cover every time I use doc=””?
>
> Thank you,
>
> Beth
>
> Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986>for Windows
>