XSD文件无法验证包含dt:dt
属性的XML文件。在XSD文件中不接受dt:dt
属性。XSD无法验证包含dt:dt属性的XML
例如。
<xs:attribute name="dt:dt" type="xs:nonNegativeInteger" use="optional"/>
在上面的xs:属性中,dt:dt
名称不被接受。因此,包含属性dt:dt="10"
的XML文件无法验证。
是否有解决方案修改XSD,以便dt:dt
属性得到验证?
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<OperationalTopology xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dt="urn:schemas-microsoft-com:datatypes"
xsi:noNamespaceSchemaLocation="xsd.xsd">
<Element1>
<Element1_In ID="xx" dt:dt="string"/>
</Element1>
</OperationalTopology>
XSD文件:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="OperationalTopology">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Element1" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="Element1_In" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="ID" use="optional"/>
<xs:attribute name="dt" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
在XSD上面给出的错误,同时验证XML。 dt:dt属性发生错误。
一般的解决方案是修复所产生的无效的XML代码。 – jdweng
提供您正在使用的XML文件和XSD文件将非常有帮助,以便我们可以了解问题并为您提供帮助。谢谢! –
@GhislainFourny我粘贴了我正在使用的XML和XSD文件。 –