I'm writing a XMl schema to check an xml file. I want to add a restriction that checks, if the value contains spaces. If it does, they should be deleted.
eg: "Hello world" -> check -> "Helloworld"
If this isn't possible, I would like to throw an error when a space is found. I tried it with but this only works if the value is "" or " " and not with "hello world".
Thanks for your help!
You cannot replace characters, but a type does not accept spaces might bed declared like so:
<simpleType name="NoSpaceType">
<restriction base="string">
<pattern value="[^ ]+"/>
</restriction>
</simpleType>
pattern is a regexp expression that you may change to better suite your needs.
您可以使用whiteSpace方面将多个空间折叠为一个空间(等同于XSLT的normalize-space()函数,但不能删除所有空间)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.