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

Re: Multiple/conditional import problem

Subject: Re: Multiple/conditional import problem
From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx>
Date: Thu, 26 May 2011 16:11:47 +0200
Re:  Multiple/conditional import problem
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/>
  </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?

On Thu, May 26, 2011 at 3:19 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
> On 26/05/2011 13:57, Martynas Jusevicius wrote:
>>
>> Therefore in general I cannot manually include the references in
>> default.xsl. Unless I pre-process it when a new specific stylesheet
>> arrives...
>
> OK then yes.
>
> However it depends on how much customisation you want.
> If you allow each property to have its own stylesheet then that's a lot of
> power, it could reformat the entire document, and to get that power you'd
> need to do as you say and arrange a processing step that builds the
> stylesheet as required.
>
> however if you want to constrain things more then you could customise
things
> based on included input documents rather than stylesheets, eg using the
> collection() function to pull in all xml files in a directory them...
>
> make a heading green unless a customisation sets a different color
>
> <xsl:variable name="custom">
>  <xsl:copy-of select="collection(....)"/>
> </xsl:variable>
> <xsl:key name="custom" match="c" use="@x"/>
>
> <xsl:template match="property">
> <dt style="color:{
> (key($custom,concat(.':color'),$custom),'green')[1]}"
>>
> <xsl:value-of select="."/>
> </dt>
>
>
> then
>
> <property>foo</property>
>
> will come out as
> <dt style="color:green">foo</dt>
>
> unless somewhere in an xml file pulled in by the collection() function
there
> is an element of the form
>
> <c x="foo:color">red</c>
>
> in which case
>
> <property>foo</property>
>
> would come out as
>
> <dt style="color:red">foo</dt>
>
> this can work well for simple customisation, but if you start to need
> conditional logic etc, it's probably simpler to go back to allowing full
> xslt, whiich gets you back to where you started.
>
>
> 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

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.