[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

solutions to an Excel XML processing problem

David Carlisle davidc at nag.co.uk
Thu Aug 24 01:51:12 PDT 2006


xml excel
I just saw Mike posted a solution to this, but here's one using a
recursive function


declare function local:f ($c,$n){
if (exists($c/@i)) then
((for $x in (1 to xs:integer($c/@i - $n -1)) return (<c/>)),
<c>{$c/node()}</c>,$c/following-sibling::c[1]/local:f(.,$c/@i))
else 
(<c>{$c/node()}</c>,$c/following-sibling::c[1]/local:f(.,$n + 1))
};
for $r in row
return
<row>
{$r/@*,local:f($r/c[1],0)}
</row>

again it uses one of the attributes that is optional in xquery, if your
xquery engine doesn't support it then complain to the vendor (why on
earth these are optional, one can only guess:-)

David

$ saxon8q -s cells.xml cells.xq
<?xml version="1.0" encoding="UTF-8"?>
<row cnt="30">
   <c/>
   <c/>
   <c>third</c>
   <c>fouth</c>
   <c>fifth</c>
   <c/>
   <c/>
   <c/>
   <c/>
   <c>tenth</c>
   <c>eleventh</c>
   <c/>
   <c/>
   <c/>
   <c/>
   <c/>
   <c/>
   <c/>
   <c/>
   <c>twentieth</c>
   <c>twenty-one</c>
   <c>twenty-two</c>
   <c>twenty-three</c>
</row>


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-2007 All Rights Reserved.