Subject:XQuery Format of XML code snippet Author:Michael Nevins Date:27 May 2010 01:53 PM
I do not seem to be able to return the same order I start with, can you please advise.
I need the <ForceData> element between the
<Data> element
**here** and the
<Data Format="Decorated"/>
I attached the xml file I started with and here is the query I am using?
*******************************************
<Connections>
{ /Connections/text() }
<Connection>
{ /Connections/Connection/text() }
<OutputTag>
{ /Connections/Connection/OutputTag/text() }
{
for $Data in /Connections/Connection/OutputTag/Data
return
if($Data/@Format = "Decorated") then
<Data Format="{ $Data/@Format }">
{ $Data/text() }
</Data>
else
<Data>
{ $Data/text() }
</Data>
}
<ForceData>
{ /Connections/Connection/OutputTag/ForceData/text() }
</ForceData>
</OutputTag>
</Connection>
</Connections>
******************************************************
Michael A. Nevins
Northrop Grumman
Electronic Systems
Subject:XQuery Format of XML code snippet Author:Minollo I. Date:27 May 2010 02:17 PM
I can see your attachment.
This is one way of doing what you are looking for; whether that's correct or not it depends on what the structure of the source and target XML documents are in general (and not just in this particular case):