Re: [xsl] Multiple/conditional import problem

Subject: Re: [xsl] Multiple/conditional import problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 26 May 2011 14:19:26 +0100
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