[xquery-talk] separating attribute name from its value

John Snelson jsnelson at sleepycat.com
Fri Mar 3 09:41:22 PST 2006


Try this:

let $j := <book>
   <author firstname='joe' lastname='carlon'/>
</book>
for $attr in $j//@*
return (
   <attr_name>{name($attr)}</attr_name>,
   <attr_value>{string($attr)}</attr_value>
)

John

fatma helmy wrote:
> suppose i have the following xquery
> let $j := <book> 
> <author firstname='joe' lastname='carlon'>
> <author>
> </book>
> for $attr in $j//@*
> return
> <attribute>
> {$attr}
> </attribute>
> 
> i will get
> all attribute names with their values
> 
> i want to get attribue name in a node and its value in
> another node
> example of the output i need is
> <attr_name>
> firstname
> <attrvalue>
> joe
> </attrvalue>
> </attr_name>
> <attr_name>
> 
> <attr_name>
> lastname
> <attrvalue>
> carlon
> </attrvalue>
> </attr_name>
> <attr_name>
> i need to separate the attribute name from its value
> in the output
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk


-- 
John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc
http://www.sleepycat.com

Contracted to Sleepycat through Parthenon Computing Ltd
http://blog.parthcomp.com/dbxml


More information about the talk mailing list