我有以下XML -
<root>
<CUSTOMER_ID>0010059863</CUSTOMER_ID>
<PO_NUMBER>6873w/PO_NUMBER>
<VENDOR_ORDER_NUMBER>0038447</VENDOR_ORDER_NUMBER>
</root>我需要创建一个Xpath,它应该满足以下条件-
中。
,它必须有一个值。
,那么它必须有一个值。
。
我写了以下几封信
boolean(//CUSTOMER_ID) and boolean(//VENDOR_ORDER_NUMBER) and count(//PO_NUMBER)=0 and string-length(//VENDOR_ORDER_NUMBER)<=10 and //VENDOR_ORDER_NUMBER!="" and string-length(//CUSTOMER_ID)<=10 and //CUSTOMER_ID!="" or boolean(//CUSTOMER_ID) and boolean(//PO_NUMBER) and count(//VENDOR_ORDER_NUMBER)=0 and string-length(//PO_NUMBER)<=10 and //PO_NUMBER!="" and string-length(//CUSTOMER_ID)<=10 and //CUSTOMER_ID!="" or (boolean(//CUSTOMER_ID) and boolean(//VENDOR_ORDER_NUMBER) and boolean(//PO_NUMBER) and string-length(//VENDOR_ORDER_NUMBER)<=10 and //VENDOR_ORDER_NUMBER!="" and string-length(//CUSTOMER_ID)<=10 and //CUSTOMER_ID!="" and string-length(//PO_NUMBER)<=20) or (boolean(//CUSTOMER_ID) and boolean(//VENDOR_ORDER_NUMBER) and boolean(//PO_NUMBER) and string-length(//PO_NUMBER)<=20 and //PO_NUMBER!="" and string-length(//CUSTOMER_ID)<=10 and //CUSTOMER_ID!="" and string-length(//VENDOR_ORDER_NUMBER)<=10)
发布于 2022-09-25 09:09:38
这似乎是Schematron的一项任务,例如给您一个开始:
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3">
<pattern>
<rule context="root">
<report test="CUSTOMER_ID">root element has CUSTOMER_ID child.</report>
<report test="PO_NUMBER | VENDOR_ORDER_NUMBER">At least one of PO_NUMBER or VENDOR_ORDER_NUMBER should be present in the XML.</report>
</rule>
<rule context="root/CUSTOMER_ID">
<report test="string-length() = (1 to 10)">Length of CUSTOMER_ID is between 1 and 10.</report>
</rule>
</pattern>
</schema>我没有详细说明所有的规则,也不确定它们是否都是一致的(有些规则需要一定的字符串长度,还有一些则允许空值)。
https://stackoverflow.com/questions/73842647
复制相似问题