RE: [xsl] Is it possible to create xsl:sort from input parameters using XSLT 2.0 (Saxon)?

Subject: RE: [xsl] Is it possible to create xsl:sort from input parameters using XSLT 2.0 (Saxon)?
From: Nick Glenister <NGlenister@xxxxxxxxxxxxxxxx>
Date: Tue, 1 Aug 2006 11:50:59 +0100
Hi,

I look out for the book thanks.

I don't believe that generating the stylesheet is a good idea in this
instance because the transformation is being called from a web application
and the stylesheet is written so that it can be used to create one of
hundreds of pages depending on the XML data provided, each time one of these
pages is called the stylesheet would be rebuilt.

The stylesheet would also be rebuilt each time the web page is being posted
back and this can be frequently if the users is interacting with the page in
any way for example changing sorts, highlighting/hiding products, filtering
by alphabet, changing number of products per page and changing page. We do
this because of a restriction we have about using client side scripting. All
client side functionality has to be done via postbacks which means it all
has to be passed back into the stylesheet.

Each time the stylesheet gets built it will essentially remain the same, it
would only be the sorts that would change. The user interface is likely only
ever to allow them three possible depths of sorting anyway and even if we
did offer more they would probably be of little value. 

To me then it seems a bit overkill to build the stylesheet each time just
for the sorts and I'm quite happy with sticking to a maximum of three sorts.
Any increase in this and I'll modify the stylesheet to accept more. This is
mostly the reason for passing XML into the sort parameter of the stylesheet
as any application that is dependant on it needs only pass in another
element in this sorting XML in order to use it. No worrying about passing in
another four parameters for each new level of sorting.

Hope that explains.

Thanks

Nick


-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: 01 August 2006 11:02
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Is it possible to create xsl:sort from input
parameters using XSLT 2.0 (Saxon)?


A good guide to XML Schema is Priscilla Walmsley's book Definitive XML
Schema published by Prentice Hall. 

It's probably overkill to learn all about XML Schema just for this problem,
but I mentioned it because there are hundreds of errors that people make
with path expressions which would be diagnosed much more quickly if people
used schema-aware stylesheets and queries. Of course, you still need to
understand the XSLT/XPath rules to get things right.

I still think the right solution for this problem might be to generate the
stylesheet before running it. You said that wasn't possible, but you didn't
say why.

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: Nick Glenister [mailto:NGlenister@xxxxxxxxxxxxxxxx] 
> Sent: 01 August 2006 08:57
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE: [xsl] Is it possible to create xsl:sort from 
> input parameters using XSLT 2.0 (Saxon)?
> 
> Hi,
> 
> thanks for info, unfortunatly I don't know how to make a 
> schema... at the risk of being off topic does anyone have any 
> good references to get me started?
> 
> cheers
> 
> Nick
> 
> 
> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: 31 July 2006 17:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Is it possible to create xsl:sort from 
> input parameters using XSLT 2.0 (Saxon)?
> 
> 
> > <xsl:param name="sortField"/>
> > 
> > And into this param i pass the XML:
> > 
> > <SortFields>
> > 	<SortField>
> > 		<Sort>lendername</Sort>
> > 		<Order>ascending</Order>
> > 		<DataType>text</DataType>
> > 		<CaseOrder>lowercasefirst</CaseOrder>
> > 	</SortField>
> > </SortFields>
> > 
> > 
> > rather than use 12 parameters (four for each <xsl:sort/>), 
> I had hoped 
> > that using this XML I would be able to read the values out like so:
> > 
> > 	<xsl:sort select="$sortField/SortField[1]/Sort"
> > order="{$sortField/SortField[1]/Order}"/>
> 
> You want $sortField/SortFields/SortField[1]/Order
> > 
> > 
> > As far as I can tell the order attribute should read 
> "acsending" out 
> > of the XML but I've no real way of finding out what it is reading.
> 
> Take a look at the trace() function, or simply do 
> <xsl:copy-of select="$sortField"/>.
> 
> Better still, write a little schema for this XML document and 
> make your stylesheet schema-aware, and then the error will be 
> reported to you at compile time.
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 
> 
> This inbound message has been scanned for viruses by 
> MailControl for Moneyfacts Group plc.
> 
> 
> The Investment, Life & Pensions Annual Awards Lunch 2006 will 
> take place on Wednesday 20th September at The Brewery, 
> Chiswell Street, London. To book your table or for more 
> information, contact Miranda Siliprandi on 0870 2250 491 or 
> email msiliprandi@xxxxxxxxxxxxxxxx
> 
> The Moneyfacts 11th Annual Conference takes place on Tuesday 
> 7th November 2006 at the Shaw Centre, Novotel Euston London 
> in association with our Platinum Sponsors, CACI. For 
> sponsorship and general enquires please email Anne Joyce at 
> ajoyce@xxxxxxxxxxxxxxxx or to reserve your place, call our 
> ticket hotline on 0870 2250 100.
> 
> E-mail Disclaimer: This e-mail message contains confidential 
> information and is intended only for the individual entity or 
> organisation named. If you are not the named addressee you 
> should not disseminate, distribute, print or copy this e-mail 
> and/or attachments (either whole or partial). To do so may 
> constitute a breach of confidence and/or privilege. Please 
> notify the sender immediately by e-mail if you have received 
> this e-mail by mistake and delete this e-mail permanently 
> from your system. E-mail transmissions cannot be guaranteed 
> to be secure or error-free as information could be 
> intercepted, corrupted, lost, destroyed, maliciously altered, 
> arrive late or incomplete, or contain viruses. The sender 
> therefore does not accept liability for any errors or 
> omissions in the contents of this message, which arise as a 
> result of e-mail transmission. If verification is required 
> please request a hard-copy version. Please note that any 
> views or opinions presented in this e-mail are !
>  those of the author and do not necessarily represent those 
> of Moneyfacts Group plc or their affiliates. Whilst every 
> step is taken to ensure e-mails are virus free when they 
> leave Moneyfacts Group systems, we accept no liability for 
> any damage caused by any virus received.   This outbound 
> message has been scanned for viruses by MailControl for 
> Moneyfacts Group plc.  

Current Thread