Re: [xsl] extend an xslt template defined elsewhere?

Subject: Re: [xsl] extend an xslt template defined elsewhere?
From: "Anthony Ettinger" <anthony@xxxxxxxxx>
Date: Fri, 19 Oct 2007 14:32:53 -0700
On 10/19/07, Scott Trenda <Scott.Trenda@xxxxxxxx> wrote:
> Since the attribute has to go at the top of the template, you're stuck
> doing another "copy-except-for-glossdef" transformation on the
> docbook-transformed data, UNLESS the following is true for your purposes
> in this case:
>

I don't see any attribute-sets in docbook.xsl (version 4.4)
How do I do a "copy-except-for-glossdef" routine?



> - Your docbook.xsl stylesheet gives glossdef's output dd an
> attribute-set, like the following: (NOTE: this would be defined in
> docbook.xsl)
>   <xsl:attribute-set name="glossdef">
>     <xsl:attribute name="attr1">attribute one</xsl:attribute>
>     <xsl:attribute name="attr2">attribute two</xsl:attribute>
>   </xsl:attribute-set>
>   <xsl:template match="glossentry/glossdef">
>     <dd xsl:use-attribute-sets="glossdef">
>       ... internal stuff here ...
>     </dd>
>   </xsl:template>
>
> - Your output would be valid if the glossdef-dd's class attribute was
> either empty (or had a different value) in the case that the
> glossdef/@role attribute was empty in the input.
>   (e.g. <glossdef role=""/> => <dd class=""/>)
>
> If this IS the case, you can do this:
>
> <xsl:import href="docbook.xsl"/>
> <xsl:attribute-set name="glossdef">
>   <xsl:attribute name="class">
>     <xsl:value-of select="@role"/>
>   </xsl:attribute>
> </xsl:attribute-set>
>

Looks reasonable if I can create this functionality, without modifying
the existing glossdef template:

    <dd xsl:use-attribute-sets="glossdef">
         ... internal stuff here ...
    </dd>

> Attribute-sets with the same name are allowed to be declared in an
> imported stylesheet and the importing stylesheet at the same time; when
> this happens, the two are merged, and if any attributes with the same
> name declared in both, the one with the highest import precedence (the
> importing stylesheet's one, in this case) will win.
>
> It's a bit of a fringe case here, but definitely a good example of why
> <xsl:attribute-set/> is useful. If you have control over docbook.xsl and
> frequently import it into other stylesheets, I'd recommend declaring
> attribute-sets to correspond to the output elements in the main
> templates, for reasons like this one. It allows you more control over
> exactly what can be extended later.
>
>
> ~ Scott
>
>
>
>
> -----Original Message-----
> From: ettinger@xxxxxxxxx [mailto:ettinger@xxxxxxxxx] On Behalf Of
> Anthony Ettinger
> Sent: Friday, October 19, 2007 12:34 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] extend an xslt template defined elsewhere?
>
> On 10/17/07, Scott Trenda <Scott.Trenda@xxxxxxxx> wrote:
> > <xsl:import href="docbook.xsl"/>
> > <xsl:template match="orderedlist">
> >   <xsl:if test="@role = 'html class real code goes here'">
> >     <xsl:apply-imports/>
> >   </xsl:if>
> > </xsl:template>
> >
> > ~ Scott
> >
> >
>
>
> I'm seeing a problem with my rule:
>
> <xsl:template match="glossentry/glossdef">
>     <dd>
>         <xsl:if test="@role != ''">
>             <xsl:attribute name="class">
>                 <xsl:value-of select="@role"/>
>             </xsl:attribute>
>         </xsl:if>
>         <xsl:apply-imports />
>     </dd>
> </xsl:template>
>
>
>
> The apply-imports is creating another level of <dd> nesting in the
> output...is there a way to avoid this? I still need to process the
> exisiting docbook glossdef template though.
>
>
>
>
> --
> Anthony Ettinger
> Ph: 408-656-2473
> var (bonita, farley) = new Dog;
> farley.barks("very loud");
> bonita.barks("at strangers");
>
> http://chovy.dyndns.org/resume/
> http://utuxia.com/consulting
>
>


-- 
Anthony Ettinger
Ph: 408-656-2473
var (bonita, farley) = new Dog;
farley.barks("very loud");
bonita.barks("at strangers");

http://chovy.dyndns.org/resume/
http://utuxia.com/consulting

Current Thread