XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
First LastSubject: XQuery Replace
Author: First Last
Date: 16 Sep 2005 03:08 PM
I'm trying to create an xQuery that will let me replace a node (or nodes) that may or may not exist in an xml document. The purpose being I just want to know that they are there (not what it's in it for now).

Here's the xml:
<stuff>
<object id="1">
<option att="a">A</option>
<option att="b">B</option>
</object>
<object id="2"/>
</stuff>

Here's what I want returned from the xquery:
<stuff>
<object id="1">
<option/>
<option/>
</object>
<object id="2"/>
</stuff>

Much appreciation to anyone that can help me with this xQuery.

Posttop
(Deleted User) Subject: XQuery Replace
Author: (Deleted User)
Date: 19 Sep 2005 03:51 AM
Hi Joel,
this simple query will work, assuming the structure of the input file is the one of your sample (i.e. "option" is the only node that can appear under "object"):

for $node in /stuff/object
return
<object id="{$node/@id}">
{
for $option in $node/option
return <option/>
}
</object>

Hope this helps,
Alberto

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.