Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XQuery:将奇怪的xsi属性插入到我的XQuery输出中_Xquery_Xsi - Fatal编程技术网

XQuery:将奇怪的xsi属性插入到我的XQuery输出中

XQuery:将奇怪的xsi属性插入到我的XQuery输出中,xquery,xsi,Xquery,Xsi,下面是我得到的XQuery输出示例: <clinic> <Name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Healthy Kids Pediatrics</Name> <Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">510 W 27th St, Los Angeles, CA 90007

下面是我得到的XQuery输出示例:

<clinic>
    <Name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Healthy Kids Pediatrics</Name>
    <Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">510 W 27th St, Los Angeles, CA 90007</Address>
    <PhoneNumberList>213-555-5845</PhoneNumberList>
    <NumberOfPatientGroups>2</NumberOfPatientGroups>
</clinic>
现在我的XQuery XML输出将如下所示(这就是我想要的)


健康儿童儿科
加利福尼亚州洛杉矶市西27街510号,邮编90007
213-555-5845
2.
但是,当我在浏览器中查看XML时,它会给出一个错误并显示如下内容:

XML Parsing Error: prefix not bound to a namespace
Location: file:///C:/Users/Pac/Desktop/csci585-hw3/vaccination.xml
Line Number 3, Column 1:<Vaccination xsi:noNamespaceSchemaLocation="vaccination.xsd">
^
XML解析错误:前缀未绑定到命名空间
地点:file:///C:/Users/Pac/Desktop/csci585-hw3/investment.xml
第3行第1列:
^

有人知道如何在不破坏XML/XSL的情况下从XQuery输出中删除这些xsi标记吗?

从顶部节点删除名称空间声明会使XML文档无效,因为使用了xsi前缀,但没有声明。当您尝试在查询中加载文档时,这应该会导致错误

我假设Name和Address节点是直接从源文档复制的,其他节点是构造的

从源文档复制节点时,源节点中的作用域内命名空间将与包含副本的节点中的作用域内命名空间组合。它们的组合方式由复制命名空间模式指定

在本例中,您希望从父节点(查询中的节点)继承名称空间,但不希望在源文档中保留不必要的名称空间

这可以通过在查询顶部添加以下行来实现:

declare copy-namespaces no-preserve, inherit;

完美的工作起来很有魅力。非常感谢。
<clinic>
    <Name>Healthy Kids Pediatrics</Name>
    <Address>510 W 27th St, Los Angeles, CA 90007</Address>
    <PhoneNumberList>213-555-5845</PhoneNumberList>
    <NumberOfPatientGroups>2</NumberOfPatientGroups>
</clinic>
XML Parsing Error: prefix not bound to a namespace
Location: file:///C:/Users/Pac/Desktop/csci585-hw3/vaccination.xml
Line Number 3, Column 1:<Vaccination xsi:noNamespaceSchemaLocation="vaccination.xsd">
^
declare copy-namespaces no-preserve, inherit;