Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Update xs:any element

 
   Database Help (Home) -> XML RSS
Next:  XQuery: Update multiple XML nodes  
Author Message
Leon Mayne

External


Since: Sep 02, 2008
Posts: 3



(Msg. 1) Posted: Tue Sep 02, 2008 2:27 pm
Post subject: Update xs:any element
Archived from groups: microsoft>public>sqlserver>xml (more info?)

I'm trying to do a simple 'replace value of' for an element in an XML
column whose XSD looks like:

[snip]
<xs:element name="body" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="1" maxOccurs="unbounded"
processContents="skip"/>
</xs:sequence>
</xs:complexType>
</xs:element>
[snip]

I've tried using various syntaxes:

xmlEmail.modify('replace value of (/email/body/text())[1] with "<p>Task
has been assigned</p>"')

gives:

XQuery [@tblTasks.xmlEmail.modify()]: Result of 'text()' expression is
statically 'empty' (SQL error = 2377)

xmlEmail.modify('replace value of (/email/body)[1] with
xs:string("<p>Task has been assigned</p>")')

gives:

XQuery [@tblTasks.xmlEmail.modify()]: The target of 'replace value of'
must be a non-metadata attribute or an element with simple typed
content, found 'element(body,#anonymous) ?' (SQL error = 2356)

Does anyone know how to update this element?

 >> Stay informed about: Update xs:any element 
Back to top
Login to vote
Martin Honnen

External


Since: Apr 20, 2007
Posts: 48



(Msg. 2) Posted: Tue Sep 02, 2008 3:41 pm
Post subject: Re: Update xs:any element [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Leon Mayne wrote:
> I'm trying to do a simple 'replace value of' for an element in an XML
> column whose XSD looks like:
>
> [snip]
> <xs:element name="body" minOccurs="1" maxOccurs="1">
> <xs:complexType>
> <xs:sequence>
> <xs:any minOccurs="1" maxOccurs="unbounded"
> processContents="skip"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> [snip]
>
> I've tried using various syntaxes:
>
> xmlEmail.modify('replace value of (/email/body/text())[1] with "<p>Task
> has been assigned</p>"')

You want to insert an element, not change the value. Try
xmlEmail.modify(
'insert <p>Task has been assigned</p> into (/email/body)[1]'
)
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

 >> Stay informed about: Update xs:any element 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Can't see Element in the Output Column - Hi , I have a peculier problem. I am having a requirement to Load XML file into database in the normalized form. When I am using following XSD for loading data. In the SSIS XML Source Editor -> Columns, I am unable to see folloing columns. These..

field values as element name - I am using SQL Server 2000 and need to generate an XML file from a database table. Basically I need to generate an XML file from two fields in a table called MyTable. I don't need to include all fields from this table. One field is ContentDescriptio...

XQuery - Check if element exist? - 30 minutes ago i found out that i needed to check if a element existed in one of our xml documents we store in the database. I thought it should be as easy as this .. SELECT * FROM [Info] WHERE [Info].[Xml].exist('/OrderAcknowledgement/Error') = 1 But....

XML Validation: Declaration not found for element - I am pulling my hair out over this issue. case is fine. the element is there, etc... whats up? XML Validation: Declaration not found for element 'http://t/transactionBlob/PreviousAccountsRequired.xsd:account'. Location: /*:account[1] i get that..

xml update - I have id and xml columns in mytable. I want to update an element called myelement with the following UPDATE MyTable SET xml.modify ('replace value of (/root/child/grandchild/myelement)[1] with xs:dateTime("2002-05-30T09:30:10Z")') WHE...
   Database Help (Home) -> XML All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]