[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: extend an xslt template defined elsewhere?

Subject: RE: extend an xslt template defined elsewhere?
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Date: Fri, 19 Oct 2007 16:48:59 -0500
RE:  extend an xslt template defined elsewhere?
> Looks reasonable if I can create this functionality, without modifying
> the existing glossdef template:
>
>     <dd xsl:use-attribute-sets="glossdef">
>          ... internal stuff here ...
>     </dd>

Like I said, you would have to add that and <xsl:attribute-set
name="glossdef"> to docbook.xsl. Then this would be your entire
stylesheet:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="docbook.xsl"/>
  <xsl:attribute-set name="glossdef">
    <xsl:attribute name="class">
      <xsl:value-of select="@role"/>
    </xsl:attribute>
  </xsl:attribute-set>
</xsl:stylesheet>

What you wrote (when used in an importing template) would give you the
same erratic behavior that you were seeing before, with two <dd>'s
created for each glossdef.



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

I didn't expect there to be attribute-sets in there; for some reason, I
rarely see them used, even in public extensible templates. I started
writing out the copy-plus-one-other-template stylesheet, and realized
that the value of @role would not be present after the docbook.xsl
transform, so that's not a viable option. See if you can shoehorn that
attribute-set into your local copy of docbook.xsl.


~ Scott


-----Original Message-----
From: ettinger@xxxxxxxxx [mailto:ettinger@xxxxxxxxx] On Behalf Of
Anthony Ettinger
Sent: Friday, October 19, 2007 4:33 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  extend an xslt template defined elsewhere?

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

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.