Encoding XSD中字符串数据类型的maxLength限制应该基于预编码数据还是后编码数据?
如果my DB中字符串的最长值为Encoding XSD中字符串数据类型的maxLength限制应该基于预编码数据还是后编码数据?,encoding,xsd,maxlength,Encoding,Xsd,Maxlength,如果my DB中字符串的最长值为 "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.
"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:)
&;1.
<?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 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>