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] modular customization layer with imports.


Hi,
Your current setup outputs the <formatting:*> elements to the output, and 
your templates that match on formatting:* are looking for such elements from 
the input.  The output stream is not automatically processed again by 
templates reading the input.

You need to save your generated <formatting:*> elements into a variable, 
then use exslt:node-set() to turn it into a node set, and then apply 
templates to it.  Something like this:

<xsl:template match="programlisting">
  <xsl:variable name="temp">
     <formatting:INDENT>
        <formatting:TAG>
    etc.
  </xsl:variable>

  <xsl:apply-templates select="exslt:node-set($temp/*)"/>

And you need to add the exslt namespace declaration to your customization 
layer.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


----- Original Message ----- 
From: "Mansour" <mansour77@yahoo.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Monday, January 28, 2008 2:27 PM
Subject: [docbook-apps] modular customization layer with imports.


>I am trying to override progrmalisting in docbook with a code that will 
>provide indentation for included XML code. I need to be able to generate 
>pdf and html. So I divided my xslt into 3 files. One off them has the 
>common templates, and the rest has the formating templates.
> The one that has the common templates can be called "common.xsl". My 
> question will deal with the html version only and I will figre out the FO 
> version later.
>
> The common.xsl has a template that mathes programlisting.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>    xmlns:formatting="http://indentation.for.the.source.code";>
>    <xsl:import href="/opt/docbook/xhtml/docbook.xsl" />
>    <xsl:strip-space elements="*" />
>    <xsl:template match="programlisting">
>        <xsl:choose>
>            <xsl:when test="self::*">
>                <formatting:INDENT>
>                    <formatting:TAG>
>                        <xsl:text>&lt;</xsl:text>
>                        <formatting:TAGNAME>
>                            <xsl:value-of select="name(.)" />
>                        </formatting:TAGNAME>
>                        <xsl:for-each select="@*">
>                            <formatting:ATTRIBUTENAME>
>                                <xsl:value-of
>                                    select="concat(' ',name(.))" />
>                            </formatting:ATTRIBUTENAME>
>                            <xsl:text>=</xsl:text>
>                            <formatting:ATTRIBUTEVALUE>
>                                <xsl:value-of
>                                    select="concat('&quot;',.,'&quot;')" />
>                            </formatting:ATTRIBUTEVALUE>
>                        </xsl:for-each>
>                        <xsl:text>&gt;</xsl:text>
>                    </formatting:TAG>
>                    <xsl:apply-templates />
>                    <formatting:TAG>
>                        <xsl:text>&lt;/</xsl:text>
>                        <formatting:TAGNAME>
>                            <xsl:value-of select="name(.)" />
>                        </formatting:TAGNAME>
>                        <xsl:text>&gt;</xsl:text>
>                    </formatting:TAG>
>                </formatting:INDENT>
>            </xsl:when>
>        </xsl:choose>
>    </xsl:template>
> </xsl:stylesheet>
>
> The html one formats the added tags:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>    xmlns:formatting="http://indentation.for.the.source.code";>
>    <xsl:strip-space elements="*" />
>    <xsl:template match="/">
>        <xsl:apply-templates />
>    </xsl:template>
>    <xsl:template match="formatting:INDENT" mode="phase-2">
>        <div style="margin:0 0 0 15pt;color:green;">
>            <xsl:apply-templates />
>        </div>
>    </xsl:template>
>    <xsl:template match="formatting:TAGNAME">
>        <span style="color:#00AA88;vertical-align:top;">
>            <xsl:apply-templates />
>        </span>
>    </xsl:template>
>    <xsl:template match="formatting:ATTRIBUTENAME">
>        <span style="color:purple;">
>            <xsl:apply-templates />
>        </span>
>    </xsl:template>
>    <xsl:template match="formatting:ATTRIBUTEVALUE">
>        <span style="color:blue; font-weight:900;margin:0px;">
>            <xsl:apply-templates />
>        </span>
>    </xsl:template>
>    <xsl:template match="formatting:TAG">
>        <span style="color:gray;border-spacing:0;">
>            <xsl:apply-templates />
>        </span>
>    </xsl:template>
>    <xsl:template match="formatting:CONTENTS">
>        <span style="background-color:red;padding:0px;">
>            <xsl:apply-templates />
>        </span>
>    </xsl:template>
> </xsl:stylesheet>
>
>
> I am not able to find anyway to combine these two and get the correct 
> output. I tried to use import in the html sheet and inport the common.xsl, 
> but that did not help.  Can anyone suggest a solution ?
>
>
>
> ---------------------------------------------------------------------
> 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]