donglian4879 2019-09-17 10:46
浏览 86
已采纳

libxml2在元素类型anyURI包含特殊字符(例如“ [”,“ [”)的xsd模式验证上失败

I am using go-libxml2 for my xsd schema validation. I have an XML element which takes url as a value. My xsd also contains its type as anyURI as follows

<xs:element name="url" type="xs:anyURI"> 

The following code throws error on validation url which contains "[]"

xsd.schema.Validate(xml)

The following is the sample url which throws an error

<url>
    <![CDATA[
        http://example.com/orda/var[div]=super
    ]]>
</url>

Error:

'http://example.com/orda/var[div]=super is not a valid value of the atomic type 'xs:anyURI'

Regular urls are working fine. Any idea how to solve this issue

  • 写回答

1条回答 默认 最新

  • doxrxwn2252 2019-09-17 10:55
    关注

    See RFC3986 (emphasis mine):

    A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax.

    Try replacing them with %5b and %5d, respectively.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 Ubuntu20.04无法连接GitHub
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥30 C++行情软件的tick数据如何高效的合成K线