XML验证失败,并显示以下错误:
Feed看起来像这样:
<Category>
<ExternalId>1234</ExternalId>
<Name>Name</Name>
<CategoryPageUrl>http://www.example.com/products?my_query_parameter[]=45</CategoryPageUrl>
</Category>
适当的架构如下所示:
<xs:complexType name="CategoryType">
<xs:all>
<xs:element name="ExternalId" type="ExternalIdType" minOccurs="0"/>
<xs:element name="Name" type="xs:string" minOccurs="0"/>
<xs:element name="CategoryPageUrl" type="xs:anyURI" minOccurs="0"/>
</xs:all>
</xs:complexType>
最佳答案
不可以,xs:anyURI
不能包含方括号([
或]
)。
您的URI本身是无效的,而不仅限于XSD ...
xs:anyURI
遵循RFC 2396(由RFC 2732修订)。
RFC 2396对于URI的query
部分具有以下含义,您尝试在其中使用方括号:
query = *uric
uric = reserved | unreserved | escaped
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
"$" | ","
unreserved = alphanum | mark
mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
"(" | ")"
escaped = "%" hex hex
hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
"a" | "b" | "c" | "d" | "e" | "f"
alphanum = alpha | digit
alpha = lowalpha | upalpha
lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
"j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
"s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
"J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
"S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
"8" | "9"
如您所见,此处不允许使用
[
和]
。此外,根据2.4.3,在URI中的任何地方,通常都将方括号视为不明智的。排除的US-ASCII字符:unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
RFC 2732确实使用
[
和]
为IPv6地址定义了一种语法,但这不在URI的query
部分之内。关于python - 可以xs :anyURI contain square brackets in XSD?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41893073/