【发布时间】:2019-01-16 16:15:23
【问题描述】:
我是 xquery 的菜鸟,我正在“测试”代码
对我来说不可能过滤一个具体的 xml。 我不确定,但第一个 TAG 似乎有问题,它包含一个属性,并且可能我解析错误......
XML 示例
<findToFileResponse xmlns="xmlapi_1.0">
<equipment.PhysicalPort>
<mtuValue>9728</mtuValue>
<userLabel>RIOXXXX</userLabel>
<displayedName>Port 1/1</displayedName>
<siteId>10.10.10.1</siteId>
<siteName>LO0015P1</siteName>
<children-Set>
<ethernetequipment.EthernetPortSpecifics>
<actualDuplex>fd1000</actualDuplex>
<children-Set></children-Set>
</ethernetequipment.EthernetPortSpecifics>
</children-Set>
</equipment.PhysicalPort>
<equipment.PhysicalPort>
<mtuValue>9728</mtuValue>
<userLabel>RIOXXXX</userLabel>
<displayedName>Port 1/2</displayedName>
<siteId>10.10.10.10</siteId>
<siteName>LO0015P1</siteName>
<children-Set>
<ethernetequipment.EthernetPortSpecifics>
<actualDuplex>fd1000</actualDuplex>
<children-Set></children-Set>
</ethernetequipment.EthernetPortSpecifics>
</children-Set>
</equipment.PhysicalPort>
</findToFileResponse>
例如,这个xquery(我在测试,目的是与其他具有相同第一个TAG的xml):
let $docu1 := doc("ListadoVanos.Mon_Jan_14_040000_CET_2019.xml")/findToFileResponse
return $docu1
我希望是这样的:
<equipment.PhysicalPort>
<mtuValue>9728</mtuValue>
<userLabel>RIOXXXX</userLabel>
<displayedName>Port 1/1</displayedName>
<siteId>10.10.10.1</siteId>
<siteName>LO0015P1</siteName>
<children-Set>
<ethernetequipment.EthernetPortSpecifics>
<actualDuplex>fd1000</actualDuplex>
<children-Set></children-Set>
</ethernetequipment.EthernetPortSpecifics>
</children-Set>
</equipment.PhysicalPort>
<equipment.PhysicalPort>
...
</equipment.PhysicalPort>
<equipment.PhysicalPort>
...
</equipment.PhysicalPort>
...
但回答一个空的结果
有什么想法吗?你能帮我建立第一个过滤器吗?
提前致谢
我正在使用 BaseX。这是相关信息:
Compiling:
- pre-evaluate fn:doc(uri) to document-node() item: doc("ListadoVanos.Mon_Jan_14_040000_CET_... -> document-node {"ListadoVanos.Mon_Jan_14_...
- remove unknown element/attribute findToFileResponse
- pre-evaluate iter path to empty sequence: document-node {"ListadoVanos.Mon_Jan_14_... -> ()
- inline $docu1_0
- simplify FLWOR expression: ()
Optimized Query:
()
Query:
let $docu1 := doc("ListadoVanos.Mon_Jan_14_040000_CET_2019.xml")/findToFileResponse return $docu1
Result:
- Hit(s): 0 Items
- Updated: 0 Items
- Printed: 0 b
- Read Locking: ListadoVanos.Mon_Jan_14_040000_CET_2019.xml
- Write Locking: (none)
Timing:
- Parsing: 0.26 ms
- Compiling: 123.72 ms
- Evaluating: 0.17 ms
- Printing: 0.01 ms
- Total Time: 124.17 ms
Query plan:
<QueryPlan compiled="true" updating="false">
<Empty size="0" type="empty-sequence()"/>
</QueryPlan>
【问题讨论】: