Re: [xsl] Multiple/conditional import problem

Subject: Re: [xsl] Multiple/conditional import problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 May 2011 15:19:08 +0100
On 26/05/2011 15:11, Martynas Jusevicius wrote:
Thanks Dave!

The properties will be usually grouped into some classes - and then
one stylesheet per class.

I think for now I'll just import those specific stylesheets I've
developed myself into default.xsl, ant figure out the pre-processing
step later.

Usually specific stylesheet (image.xsl) imports general one
(default.xsl), however in this case it would be the way around - but
it makes sense here?

Can you take a look at the pseudo-code below just to make sure I got it right:

default.xsl:

<xsl:imports href="image.xsl"/>

<xsl:template match="property">
   <dt>
     <xsl:value-of select="@name"/>
   </dt>
   <dd>
     <xsl:apply-templates select="value"/>
     <xsl:apply-imports/>
you don't want this as that would apply any imported templates that match <property>
   </dd>
<xsl:template>

<xsl:template match="property/value">
   <xsl:value-of select="."/>
</xsltemplate>

image.xsl:

<xsl:template match="property[@name = 'image']/value">
   <img src="{.}"/>
<xsl:template>

Do I need<xsl:apply-templates select="value"/>  in default.xsl or will
it be called automatically if<xsl:apply-imports/>  fails to find match
in image.xsl?


I think the simplest thing is just to have

<xsl:apply-templates select="value"/>

in your default template for property.

the only problem is that then your default template for property/vale will always win as import precedence trumps priority.
So use xsl:include rather than xsl:import


If you do want to use xsl:import keep your general framework in the top stylesheet but put your default templates such as
> <xsl:template match="property/value">
> <xsl:value-of select="."/>
> </xsltemplate>
>
into a subsidurary stylesheet that is imported last so has lower import precedence than your property-specific styles,


david


________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread