Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XSLForum: Main > XSL-XSD-XML and more

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-30-2008, 03:15 PM
Martin Honnen
 
Posts: n/a

Default Re: obtain element name, or attribute and value of the document nameitself, and some elemnts and attributes from an ancestor or the node itselfusing xquery



Jeff Kish wrote:

> xxx.xml
>
> segment speed="1"
> table1 relation="upper"
> table3 relation="upper"
>
> xxy.xml
> segment speed="2"
> table2 relation="lower"
>
>
> given this xml file set:
>
>
> document xxx.xml
>
> <area>
> <segment id="segment1" speed="1">
> <table id="table1" relation="upper" />
> <table id="table2" orientation="side" />
> <table id="table3" relation="upper" />
> </segment>
> </area>
>
>
>
>
> document xxy.xml
>
> <area>
> <segment id="segment1" speed="2">
> <table id="table1" orientation="bottom" />
> <table id="table2" relation="lower" />
> <table id="table3" orientation"top" />
> </segment>
> </area>


Here is an example XQuery,

string-join(
for $d in
collection('.?select=test20081030*.xml')[descendant::table[@relation]]
return
(tokenize(base-uri($d), '/')[last()], '',
concat('segment speed="',
$d//table[@relation]/ancestor::segment/@speed, '"'),
for $t in $d//table[@relation]
return concat($t/@id, ' relation="', $t/@relation, '"'), '')
, ' ')

that returns the described result when run with Saxon 9 in a working
directory that contains the input files as test20081030nn.xml
--

Martin Honnen
http://JavaScript.FAQTs.com/
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 03:40 PM.
Style Developed by Epic Designz