I understand, I'm adding multiple attributes to the same element.
Here's what I want to do: I want to return the value of the id attribute
and put that value in a new tag.
<results>
<item>
<id>{$docs/results/interface/@id}</id>
<descr>{$docs/results/interface/desciption}<descr>
</item>
</results>
> Date: Tue, 8 Dec 2009 09:30:58 -0500
> To: [email protected]
> From: [email protected]
> Subject: RE: [MarkLogic Dev General] Return Attribute Data
>
> At 2009-12-08 09:25 -0500, Tony Mariella wrote:
> >I just want to return all the id attributes in the interface tag.
>
> Then you'll have to create an element for each one because an XML
> element cannot have more than one attribute with the same name.
>
> Wait ... do you want the attributes or the attribute values?
>
> I'll continue assuming you want the attribute values:
>
> >If I run a Marklogic Query, I would like to return specific data from the
> >XML.
> >If the XML in the DB looks like this:
> >
> ><results>
> > <interface id="345">
> > <description>Test Interface A</description>
> > </interface>
> > <interface id="678">
> > <description>Test Interface A</description>
> > </interface>
> ></results>
> >
> >I would like to only return the id attribute and description of the
> >interface tag
>
> string-join(
> for $i in $docs/results/interface
> return concat( string($i/@id),"-",string($i/description) )
> ,"
" )
>
> >Any ideas how I get only return the id attribute ?
>
> The above will give you:
>
> 345-Test Interface A
> 678-Test Interface A
>
> I hope this helps.
>
> . . . . . . . . . . . Ken
>
> T:\ftemp>type tony.xml
> <results>
> <interface id="345">
> <description>Test Interface A</description>
> </interface>
> <interface id="678">
> <description>Test Interface A</description>
> </interface>
> </results>
>
> T:\ftemp>xquery tony.xq
> <?xml version="1.0" encoding="UTF-8"?>345-Test Interface A
> 678-Test Interface A
> T:\ftemp>type tony.xq
> for $docs in doc('tony.xml') return
> string-join(
> for $i in $docs/results/interface
> return concat( string($i/@id),"-",string($i/description) )
> ,"
" )
>
>
> T:\ftemp>
>
>
> --
> XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
> Vote for your XML training: http://www.CraneSoftwrights.com/q/i/
> Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/
> Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
> Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
> Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
> G. Ken Holman mailto:[email protected]
> Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/q/bc
> Legal business disclaimers: http://www.CraneSoftwrights.com/legal
>
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general