SQL将XML中的符号替换为';和';
我想替换符号,显示为SQL将XML中的符号替换为';和';,xml,replace,xquery,Xml,Replace,Xquery,我想替换符号,显示为& XML的结构是 <xs:simpleType name="ImportedData_Space_TypeType"> <xs:restriction base="xs:string"> <xs:enumeration value="SupportSpace" /> <xs:enumeration value="Teach&ResSpace" /> <xs:enumeration val
&
XML的结构是
<xs:simpleType name="ImportedData_Space_TypeType">
<xs:restriction base="xs:string">
<xs:enumeration value="SupportSpace" />
<xs:enumeration value="Teach&ResSpace" />
<xs:enumeration value="Teach&ResSpecialistSpace" />
</xs:restriction>
我试图返回一个视图,需要返回&代码>作为和
我看过xquery,但不确定这是否是最好的方法?只需使用replace函数,例如
declare variable $test := <ImportedData_Space_TypeType>Teach&ResSpace</ImportedData_Space_TypeType>;
<ImportedData_Space_TypeType>{replace($test, "&", "and")}</ImportedData_Space_TypeType>
使用XSLT做这件事要容易得多,XSLT是一个标识模板,由一个匹配ImportedData\u Space\u TypeType/text()的模板覆盖,在覆盖模板中只需:
copy $c := $test
modify replace value of node $c with replace($c, "&", "and")
return $c