如何在xs:list
中表示项目(如果它包含空格)?XML xs中的转义空间:列表
模式片段:
<xs:simpleType name="mylisttype">
<xs:list itemType="xs:string" />
</xs:simpleType>
<xs:element name="mylist" type="mylisttype" />
示例XML片段:
<mylist>item1 item2 item3 item4</mylist>
输出示例:
["item1", "item2", "item3", "item4"]
示例XML片段(不正确)
<mylist>Item One Item Two Item Three Item Four</mylist>
所需的输出:
["Item One", "Item Two", "Item Three", "Item Four"]
我读过这个,我不想改变分隔符。对于我的用例'xs:list'是最合适的类型。列表中的每个字符串都是一个短的原子标识符,它可能偶尔包含来自已知集合的空格字符。 –
@ BenSarahGolightly:已更新的答案清楚地表明'xs:list'中的字符串中没有空格的转义机制。使用元素代替,无需验证您的列表,或验证带外wrt XSD。 – kjhughes
这应该是被接受的答案。 ty kjhughes,你救了我一些想知道的。 – user1712447