xml - XPath expression to create text delimited string -


edit: appears software supports xpath 1.0. :(

i need create delimited string of following format:

stuff,things;a,1;b,2

from following xml data:

<table ss:expandedcolumncount="2" ss:expandedrowcount="3" x:fullcolumns="1" x:fullrows="1" ss:defaultrowheight="15">  <row>   <cell><data ss:type="string">stuff</data></cell>   <cell><data ss:type="string">things</data></cell>  </row>  <row>   <cell><data ss:type="string">a</data></cell>   <cell><data ss:type="number">1</data></cell>  </row>  <row>   <cell><data ss:type="string">b</data></cell>   <cell><data ss:type="number">2</data></cell>  </row> </table> 

columns denoted , , rows denoted ;. should create 2 dimensional array.

---------notes-----------

i have tried following expression against sample xml not work when applied using notepad++ xpatherizernpp:

eval(eval(row, 'concat(cell, ";")'), "..")

the above expression throws following erorr: xsltcontext needed query because of unknown function

the "eval" function typically works in ms infopath, possible xpatherizer not handle xpath in same way infopath does. possible don't understand context of statement , using inappropriately.

as sidenote, there web resources explain use of xpath eval? don't understand , cannot seem find explanations.

--------full xml--------

here full body of xml trying use. "xml spreadsheet" generated ms excel. not have ability create custom xml mapping not have rights install xml tools on system.

<?xml version="1.0"?> <?mso-application progid="excel.sheet"?> <workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"  xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:x="urn:schemas-microsoft-com:office:excel"  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"  xmlns:html="http://www.w3.org/tr/rec-html40">  <documentproperties xmlns="urn:schemas-microsoft-com:office:office">   <author>smith, robert;-</author>   <lastauthor>smith, robert;-</lastauthor>   <created>2013-08-27t16:29:45z</created>   <company>smithworks</company>   <version>14.00</version>  </documentproperties>  <excelworkbook xmlns="urn:schemas-microsoft-com:office:excel">   <windowheight>10035</windowheight>   <windowwidth>22035</windowwidth>   <windowtopx>240</windowtopx>   <windowtopy>90</windowtopy>   <protectstructure>false</protectstructure>   <protectwindows>false</protectwindows>  </excelworkbook>  <styles>   <style ss:id="default" ss:name="normal">    <alignment ss:vertical="bottom"/>    <borders/>    <font ss:fontname="calibri" x:family="swiss" ss:size="11" ss:color="#000000"/>    <interior/>    <numberformat/>    <protection/>   </style>  </styles>  <worksheet ss:name="sheet1">   <table ss:expandedcolumncount="2" ss:expandedrowcount="3" x:fullcolumns="1"    x:fullrows="1" ss:defaultrowheight="15">    <row>     <cell><data ss:type="string">stuff</data></cell>     <cell><data ss:type="string">things</data></cell>    </row>    <row>     <cell><data ss:type="string">a</data></cell>     <cell><data ss:type="number">1</data></cell>    </row>    <row>     <cell><data ss:type="string">b</data></cell>     <cell><data ss:type="number">2</data></cell>    </row>   </table>   <worksheetoptions xmlns="urn:schemas-microsoft-com:office:excel">    <pagesetup>     <header x:margin="0.3"/>     <footer x:margin="0.3"/>     <pagemargins x:bottom="0.75" x:left="0.7" x:right="0.7" x:top="0.75"/>    </pagesetup>    <selected/>    <panes>     <pane>      <number>3</number>      <activerow>3</activerow>      <activecol>1</activecol>     </pane>    </panes>    <protectobjects>false</protectobjects>    <protectscenarios>false</protectscenarios>   </worksheetoptions>  </worksheet>  <worksheet ss:name="sheet2">   <table ss:expandedcolumncount="1" ss:expandedrowcount="1" x:fullcolumns="1"    x:fullrows="1" ss:defaultrowheight="15">   </table>   <worksheetoptions xmlns="urn:schemas-microsoft-com:office:excel">    <pagesetup>     <header x:margin="0.3"/>     <footer x:margin="0.3"/>     <pagemargins x:bottom="0.75" x:left="0.7" x:right="0.7" x:top="0.75"/>    </pagesetup>    <protectobjects>false</protectobjects>    <protectscenarios>false</protectscenarios>   </worksheetoptions>  </worksheet>  <worksheet ss:name="sheet3">   <table ss:expandedcolumncount="1" ss:expandedrowcount="1" x:fullcolumns="1"    x:fullrows="1" ss:defaultrowheight="15">   </table>   <worksheetoptions xmlns="urn:schemas-microsoft-com:office:excel">    <pagesetup>     <header x:margin="0.3"/>     <footer x:margin="0.3"/>     <pagemargins x:bottom="0.75" x:left="0.7" x:right="0.7" x:top="0.75"/>    </pagesetup>    <protectobjects>false</protectobjects>    <protectscenarios>false</protectscenarios>   </worksheetoptions>  </worksheet> </workbook> 

it seems magic me tried

string-join((for $n in //row return string-join($n/cell, ',')), ';') 

and result need

stuff,things;a,1;b,2 

edit: forgot mention work in xpath 2.0


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -