[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xslt 2.0 challenge
> 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 ------------------------------------------------------------------------
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|