【发布时间】:2017-01-05 00:11:30
【问题描述】:
我想准备 .xsd 来验证我收到的 XML 文档。
在定制文档中定义了两个命名空间:
<?xml version="1.0" encoding="UTF-8"?>
<komunikat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="www.example.com/xml"
xmlns:nfz="www.example.com/xml/nfz"
nfz:version="1.7"
nfz:info-aplik-nad="KS-PPS 2016.00.3.1">
type="someType"
version="4"
</komunikat>
在我尝试过的架构中:
targetNamespace="www.example.com/xml"
xmlns:nfz="www.example.com/xml/nfz"
...
<xs:attribute name="nfz:info-aplik-nad" use="optional" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="40" />
</xs:restriction>
</xs:simpleType> ...
但在我的验证器中我收到一个错误:
.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}attribute', attribute 'name': 'nfz:info-aplik-nad' is not a valid value of the atomic type 'xs:NCName'., line 25
我所理解的 : 字符在 attribute 名称属性中是不允许的。
是否可以不更改 xml 文件?
【问题讨论】: