XML验证失败,错误:
元素'CategoryPageUrl':'http://www.example.com/products?my_query_parameter[]=45'不是原子类型'xs:anyURI'的有效值。,第29行
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>
答案 0 :(得分:5)
不,xs:anyURI
不能包含方括号([
或]
)。
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"
如您所见,[
和]
不允许在那里。此外,方括号在URI中的任何位置通常被认为是 unwise ,每 2.4.3。排除的US-ASCII字符:
unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
RFC 2732确实使用[
和]
定义了IPv6地址的语法,但这不在URI的query
部分内。
答案 1 :(得分:0)
此外,RFC1738指出这些字符不安全