纯 XPath 1.0 解决方案:
接收方 1 接收低于 documentID 范围的消息 范围:F00 到 F99
/*/Upload/ContainerEvent
[WorkAssignmentId
[string-length() = 3]
[starts-with(., 'F')][substring(.,2,2) >= 0][99 >= substring(.,2,2)]
]/EX
Receiver 2 接收低于 documentID 范围的消息 范围:FA0 到 FZ9
/*/Upload/ContainerEvent
[WorkAssignmentId
[string-length() = 3]
[starts-with(., 'F')]
[26 > string-length(
translate('ABCDEFGHIJKLMNOPQRSTUVWXYZ',substring(.,2,1), ''))]
[substring(.,3,1) >= 0][9 >= substring(.,3,1)]
]/EX
这是基于 XSLT 的验证:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select=
"/*/Upload/ContainerEvent
[WorkAssignmentId
[string-length() = 3]
[starts-with(., 'F')][substring(.,2,2) >= 0][99 >= substring(.,2,2)]
]/EX"/>
==============================
<xsl:copy-of select=
"/*/Upload/ContainerEvent
[WorkAssignmentId
[string-length() = 3]
[starts-with(., 'F')]
[26 > string-length(
translate('ABCDEFGHIJKLMNOPQRSTUVWXYZ',substring(.,2,1), ''))]
[substring(.,3,1) >= 0][9 >= substring(.,3,1)]
]/EX"/>
</xsl:template>
</xsl:stylesheet>
当此转换应用于以下 XML 源文档(未提供)时:
<p1>
<Upload>
<ContainerEvent>
<WorkAssignmentId>F13</WorkAssignmentId>
<EX>F13</EX>
</ContainerEvent>
<ContainerEvent>
<WorkAssignmentId>F99</WorkAssignmentId>
<EX>F99</EX>
</ContainerEvent>
<ContainerEvent>
<WorkAssignmentId>E15</WorkAssignmentId>
<EX>E15</EX>
</ContainerEvent>
<ContainerEvent>
<WorkAssignmentId>FA7</WorkAssignmentId>
<EX>FA7</EX>
</ContainerEvent>
<ContainerEvent>
<WorkAssignmentId>FZ9</WorkAssignmentId>
<EX>FZ9</EX>
</ContainerEvent>
<ContainerEvent>
<WorkAssignmentId>FAB</WorkAssignmentId>
<EX>FAB</EX>
</ContainerEvent>
</Upload>
</p1>
产生了想要的结果:
<EX>F13</EX>
<EX>F99</EX>
==============================
<EX>FA7</EX>
<EX>FZ9</EX>