用SQL Server中的新元素替换XML元素

时间:2016-03-08 17:17:30

标签: sql-server xml tsql xslt-2.0 xquery-sql

将此内容的<apipAccessbility>元素替换为多行中具有XML类型列的新元素:

<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
    <ItemBody>xyz</ItemBody>
    <apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0">
        <accessibilityInfo>
        Blablah
        </accessibilityInfo>
    </apipAccessibility>
</Item>

一旦元素更新,它应该如下所示:

<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
    <ItemBody>xyz</ItemBody>
    <apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0"/>
</Item>

1 个答案:

答案 0 :(得分:2)

您可以使用modifydelete

     File "/home/bgarcial/.virtualenvs/neurorehabilitation_projects_dev/lib/python3.4/site-packages/rest_framework/relations.py", line 355, in to_representation
    raise ImproperlyConfigured(msg % self.view_name)
django.core.exceptions.ImproperlyConfigured: Could not resolve URL for hyperlinked relationship using view name "patientprofile". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
[08/Mar/2016 16:05:45] "GET /api/rehabilitation-session/ HTTP/1.1" 500 165647

LiveDemo

输出:

UPDATE tab
SET col.modify('
  declare namespace NS="http://www.imsglobal.org/xsd/imsqti_v2p2";
  declare namespace NS2="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0";
  delete /NS:Item/NS2:apipAccessibility/*')
-- WHERE id = 1;