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

RE: xslt 2.0 challenge

Subject: RE: xslt 2.0 challenge
From: "Willink, Ed" <Ed.Willink@xxxxxxxxxxxxxxx>
Date: Thu, 8 Apr 2004 14:58:04 +0100
xslt following sibling colspec
> After all that has been said about xpath 2.0, I'm not sure 
> which is more
> readable...

Using <http://nicexsl.sourceforge.net> resolves the quotes and brackets
levels of readability:
(After automated XSLT to NiceXSL translation, I had to manually prettify the
XPaths,
since whitespace is preserved in converted XPaths.)

stylesheet version="2.0" {
    match(/) {
        variable spanspec := /table/tgroup/spanspec;
        <!-- constucts a sequence of the two colspecs, note the 'as' -->
        variable first : element()+ {
            sequence (/table//colspec[(preceding-sibling::colspan[@colname =
$spanspec/@namest]
                                       and
following-sibling::colspan[@colname = $spanspec/@nameend])
                                       or @colname = $spanspec/@namest
                                       or @colname = $spanspec/@nameend]);
        }
        <!-- sums the columns specified by the start and end column
         by the total number of columns, and then
         formats it to two decimal places
         and concats on a percentage symbol -->
        value-of (concat(string(format-number(
           (sum(for $x in $first/@colwidth return
number(translate($x,'m','')))
            div sum(for $x in $first/../colspec/@colwidth return
number(translate($x,'m','')))) * 100,
           '00.00')),'%'));
    }
} 

A more plausible implementation should factor the XPaths using intermediate
vatriables
or stylesheet functions, so that each XPath line is naturally one reasonable
length line.
This will raise the line count slightly but give some nice names to the
intermediates.

	Regards
			
		Ed Willink

------------------------------------------------------------------------
E.D.Willink,                             Email: mailto:EdWillink@xxxxxxx
Thales Research and Technology (UK) Ltd, Tel:  +44 118 923 8278 (direct)
Worton Drive,                            or  +44 118 986 8601 (ext 8278)
Worton Grange Business Park,             Fax:  +44 118 923 8399
Reading,   RG2 0SB
ENGLAND          http://www.computing.surrey.ac.uk/personal/pg/E.Willink
------------------------------------------------------------------------

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.