【发布时间】:2016-01-13 20:18:47
【问题描述】:
这是我运行 XQueries 之前的 XML 文档示例:
<?xml version="1.0" encoding="UTF-8" standalone='yes'?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
...
<w:p w:rsidR="00BB265E" w:rsidRDefault="00BB265E">
<w:pPr>
<w:pStyle w:val="DefaultText"/>
<w:ind w:left="720" w:hanging="720"/>
</w:pPr>
<w:r>
<w:t>1.7</w:t>
</w:r>
<w:r>
**<w:tab/>**
</w:r>
<w:r w:rsidRPr="001C1D1B">
<w:rPr>
<w:shd w:val="clear" w:color="auto" w:fill="FABF8F"/>
</w:rPr>
<w:t>Member means any person who is enrolled in</w:t>
</w:r>
...
这是我尝试运行的一些 XQuery:
查询 1
UPDATE XML_TORTEST
SET XMLDOC = updateXML(XMLDOC,'declare namespace w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"; /w:document/w:body/w:p/w:r/w:tab',
XMLType('<w:t> </w:t>'))
WHERE XML_TORTEST_ID = 1
AND XMLExists('$p/w:document/w:body/w:p/w:r/w:tab'
PASSING XMLDOC AS "p");
这给出了这个错误:
SQL 错误:ORA-31013:XPATH 表达式无效 31013. 00000 - “无效的 XPATH 表达式” *原因:传递给函数的 XPATH 表达式无效。 *操作:检查 xpath 表达式是否有可能的语法错误。
查询 2 - 有效,但 XML 输出不正确(不是字面意思)
UPDATE XML_TORTEST po
SET po.XMLDOC =
XMLQuery('declare namespace w="http://schemas.openxmlformats.org/wordprocessingml/2006/main";
copy $i := $p1
modify
(
for $j in $i/w:document/w:body/w:p/w:r/w:tab
let $newn := ''<w:t> </w:t>''
return replace node $j with $newn)
return $i' PASSING po.XMLDOC AS "p1"
RETURNING CONTENT)
WHERE XML_TORTEST_ID = 1
AND XMLExists('declare namespace w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"; $p/w:document/w:body/w:p/w:r/w:tab'
PASSING po.XMLDOC AS "p");
这是我运行查询 2 后的示例 XML:
<w:p w:rsidR="00BB265E" w:rsidRDefault="00BB265E">
<w:pPr>
<w:pStyle w:val="DefaultText"/>
<w:ind w:left="720" w:hanging="720"/>
</w:pPr>
<w:r>
<w:t>1.7</w:t>
</w:r>
**<w:r><w:t> </w:t></w:r>**
<w:r w:rsidRPr="001C1D1B">
<w:rPr>
<w:shd w:val="clear" w:color="auto" w:fill="FABF8F"/>
</w:rPr>
<w:t>Member means any person who is enrolled in</w:t>
</w:r>
....
感谢任何将&lt;w:t&gt; &lt;/w:t&gt; 转换为<w:t> </w:t> 的帮助。
【问题讨论】:
标签: xml oracle xpath xquery-sql