XML 文件路径的架构数据类型

XML Schema data type for file path

我对 XML Schema 相关的工作还比较陌生,一直在努力弄清楚我应该为文件路径使用哪种 XML Schema 数据类型。在这种情况下,是字符串还是 anyURI 最准确?

我会推荐 xsd:anyURI

[Definition:] anyURI represents a Uniform Resource Identifier Reference (URI). An anyURI value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be a URI Reference). This type should be used to specify the intention that the value fulfills the role of a URI as defined by [RFC 2396], as amended by [RFC 2732].

没有相对路径的方案组件或 file 绝对路径的方案组件。

例子:

  • ../path/to/filename.txt
  • file:///c:/path/to/filename.txt