Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xquery >Thread Next - Re: obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xquery Re: obtain element name, or attribute and value of the document name itself, and some elemnts and attributes from an ancestor or the node itself using xqueryTo: NULL Date: 10/30/2008 10:43:00 AM On Oct 30, 11:29=A0am, kishjeff <jk...@us.ibm.com> wrote: > On Oct 30, 8:53=A0am, Martin Honnen <mahotr...@yahoo.de> wrote: > > > > > Jeff Kish wrote: > > > xxx.xml > > > > segment speed=3D"1" > > > table1 relation=3D"upper" > > > table3 relation=3D"upper" > > > > xxy.xml > > > segment speed=3D"2" > > > table2 relation=3D"lower" > > > > given this xml file set: > > > > document xxx.xml > > > > <area> > > > <segment id=3D"segment1" speed=3D"1"> > > > <table id=3D"table1" =A0relation=3D"upper" =A0 =A0/> > > > <table id=3D"table2" =A0orientation=3D"side" /> > > > <table id=3D"table3" =A0relation=3D"upper" =A0 /> > > > </segment> > > > </area> > > > > document xxy.xml > > > > <area> > > > <segment id=3D"segment1" speed=3D"2"> > > > <table id=3D"table1" =A0orientation=3D"bottom" =A0 =A0/> > > > <table id=3D"table2" =A0relation=3D"lower" /> > > > <table id=3D"table3" =A0orientation"top" =A0 /> > > > </segment> > > > </area> > > > Here is an example XQuery, > > > string-join( > > for $d in > > collection('.?select=3Dtest20081030*.xml')[descendant::table[@relation]= ] > > return > > =A0 =A0(tokenize(base-uri($d), '/')[last()], '', > > =A0 =A0concat('segment speed=3D"', > > $d//table[@relation]/ancestor::segment/@speed, '"'), > > =A0 =A0for $t in $d//table[@relation] > > =A0 =A0return concat($t/@id, ' relation=3D"', $t/@relation, '"'), '') > > , ' ') > > > that returns the described result when run with Saxon 9 in a working > > directory that contains the input files as test20081030nn.xml > > -- > > > =A0 =A0 =A0 =A0 Martin Honnen > > =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/ > > Thanks. I'm using IPSI XQuery Interpreter v.1.3.4 which may be a bit > long in the tooth (I don't think it is complete as I could not get > starts-with to work) - let me give this a fly. > > thanks much Martin. > > Jeff This was soooo helpful, thanks. I have a related question.. I tried using this for fun (notice the extra base-uri($d) in the beginning of the last return statement): string-join( for $d in collection('.?select=3Dtest20081030*.xml')[descendant::table[@relation]] return base-uri($d),(tokenize(base-uri($d), '/')[last()], '', concat('segment speed=3D"', $d//table[@relation]/ancestor::segment/@speed, '"'), for $t in $d//table[@relation] return concat($t/@id, ' relation=3D"', $t/@relation, '"'), '') , ' ') I noticed that when I use this instead, I get the error: XPST0008: XQuery static error in #...ri($d),(tokenize(base- uri($d),#: Variable $d has not been declared Static error(s) in query | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
