Ask a questionAsk a question
 

AnswerXQuery Help

  • Thursday, September 07, 2006 8:30 PMC_Geek Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have this xml on a table:

    <BookData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <DataVersion>

    <Name>ABC</Name>

    <Data xsi:type="xsd:string">DEF</Data>

    </DataVersion>

    </BookData>'

    I want to modified the xml with this xquery:

    UPDATE LibraryOverride SET XMLConfig.modify(

    'declare namespace ns="http://www.w3.org/2001/XMLSchema-instance";

    'replace value of (//ns:BookData/DataVersion/Data)[1] with "TEST"')

    Where PropertyOverrideID = 1

    I am getting this error:

    XQuery [LibraryOverride.XMLConfig.modify()]: The target of 'replace value of' must be a non-metadata attribute or an element with simple typed content, found 'element(Data,xdt:untyped) ?'

Answers

  • Tuesday, September 12, 2006 2:02 PMDeclan Bright Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    For untyped xml I know you can specify that its the text of the element that you want to modify:

    'replace value of (//ns:BookData/DataVersion/Data/text())[1] with "TEST"')

    For typed xml you can specify the type like so:

    'replace value of (//ns:BookData/DataVersion/Data)[1] with xs:string("TEST")')

All Replies

  • Tuesday, September 12, 2006 2:02 PMDeclan Bright Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    For untyped xml I know you can specify that its the text of the element that you want to modify:

    'replace value of (//ns:BookData/DataVersion/Data/text())[1] with "TEST"')

    For typed xml you can specify the type like so:

    'replace value of (//ns:BookData/DataVersion/Data)[1] with xs:string("TEST")')

  • Monday, July 02, 2007 6:33 AMGopinath M Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks Declan. The solution works perfectly.

    Gopinath M

    Tech Thoughts

  • Thursday, October 11, 2007 6:36 PMkumar_j Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I learned some where that ,We cant use replace for untyped -xml

    Is it true