【发布时间】:2018-08-07 13:48:29
【问题描述】:
我有一个 XSD,我必须在其中使用断言条件。当指标='A'时,我想打印所有列的条件,而另一个条件是指标='D'的几列。我有以下逻辑,但我有大约 100 列,所以有人可以帮我优化查询吗?
<xs:assert test="if (indicator eq 'A')
then test1 and test2 and test3 and test4 and test5 and test6 and test7
else if (indicator eq 'B') then test1 and test3
else false()"/>
输入的 XML 格式如下:
`<?xml version="1.0" encoding="utf-8"?>
<p:CustomerElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<recordCount>1234</recordCount>
<Customer>
<indicator>A</indicator>
<test1>hdjfs</test1>
<test2>idsfh</test2>
<test3>idsfh</test3>
<test4>idsfh</test4>
<test5>idsfh</test5>
<test6>idsfh</test6>
<test7>idsfh</test7>
</Customer>
<Customer>
<indicator>B</indicator>
<test1>abcd</test1>
<test2></test2>
<test3>uydshjk</test3>
<test4></test4>
<test5></test5>
<test6></test6>
<test7></test7>
</Customer>
</p:CustomerElement>
正如我提到的,当 A 填充所有列时,当 B 只有 2 列时。如果我写错了条件,请帮助我使用哪个条件。
指标的值肯定是 A 或 B。
谢谢。
【问题讨论】:
-
@kjhughes 嗨,希望你做得很好!你能帮我解决这个问题吗!谢谢
-
见下文。如果对你有用请采纳。谢谢。
标签: xml xsd xml-parsing xsd-validation xsd-1.1