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: 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 ?




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