2
如果在我的数据库字符串的最长值是XSD中的字符串数据类型maxLength限制应基于预编码还是后编码数据?
"ABC<DEF"
应在XSD这串数据类型的最大长度的限制是7(预编码),或者它应该是(编码后)10,即
"ABC<DEF"
如果在我的数据库字符串的最长值是XSD中的字符串数据类型maxLength限制应基于预编码还是后编码数据?
"ABC<DEF"
应在XSD这串数据类型的最大长度的限制是7(预编码),或者它应该是(编码后)10,即
"ABC<DEF"
简短回答:预编码。
XML中的编码字符不影响字符串的“真实”长度值。
快速测试:
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="root">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:schema>
有效的XML :)
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">&1</root>