xQuery XML tokenize a string -


i'm new xquery , can't seem following work:

<measinfo measinfoid="1542455297">   <meastypes>1542455297 1542455298 1542455299 1542455300 1542455301 1542455302 1542455303 1542455304 1542455305 1542455306 1542455307 1542460296 1542460297 </meastypes>   <measvalue measobjldn="lthab0113422/ethport:cabinet no.=0, subrack no.=1, slot no.=7, port no.=0, subboard type=base_board">     <measresults>116967973 585560 496041572 682500 0 12583680 72080 520454 46670568 73432 2205837 1000000 1000000 </measresults>   </measvalue>   <measvalue measobjldn="lthab0113422/ethport:cabinet no.=0, subrack no.=1, slot no.=7, port no.=1, subboard type=base_board">     <measresults>0 0 0 0 0 0 0 0 0 0 0 0 0 </measresults>   </measvalue> </measinfo> 

i'm using //measinfo/meastypes/fn:tokenize(text(),'\s+'). hoping return record each space delimited value, return same //measinfo/meastypes/text()

what doing wrong?

in xquery 3.0 (as implemented basex), does work:

declare context item := document { <measinfo measinfoid="1542455297"> <meastypes>1542455297 1542455298 1542455299 1542455300 1542455301 1542455302 1542455303 1542455304 1542455305 1542455306 1542455307 1542460296 1542460297 </meastypes> <measvalue measobjldn="lthab0113422/ethport:cabinet no.=0, subrack no.=1, slot no.=7, port no.=0, subboard type=base_board">     <measresults>116967973 585560 496041572 682500 0 12583680 72080 520454 46670568 73432 2205837 1000000 1000000 </measresults> </measvalue> <measvalue measobjldn="lthab0113422/ethport:cabinet no.=0, subrack no.=1, slot no.=7, port no.=1, subboard type=base_board">     <measresults>0 0 0 0 0 0 0 0 0 0 0 0 0 </measresults> </measvalue> </measinfo> };  $item in //measinfo/meastypes/fn:tokenize(text(),'\s+') return <item>{$item}</item> 

...returns...

<item>1542455297</item> <item>1542455298</item> <item>1542455299</item> <item>1542455300</item> <item>1542455301</item> <item>1542455302</item> <item>1542455303</item> <item>1542455304</item> <item>1542455305</item> <item>1542455306</item> <item>1542455307</item> <item>1542460296</item> <item>1542460297</item> <item/> 

putting <item> around each result ensures rendering of these results makes each item visually distinct -- otherwise, have each result rendered single line of text, , wouldn't obvious reader whether split multiple items fn:tokenize() or not.


another way inject literal newlines:

for $item in //measinfo/meastypes/fn:tokenize(text(),'\s+') return ($item, "&#10;") 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -