如何解析 URN?
我有一个 XML 架构文件,它引用基于 urn 的位置。 有什么方法可以将其解析为 url,或者有什么方法可以实际读取它引用的文件。
<xs:include schemaLocation="urn:oasis:names:tc:dita:xsd:tblDeclGrp.xsd:1.1"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题不是解释“URN 解析”的好地方......
我们可以想象从这个 oasis URN 到一个 schemaLocation 文件名或 URL 的翻译(通过自动翻译器),但这对于 URN 来说是一个有点奇特的应用程序。
请参阅 schemaLocation 的常用语义和值,网址为 http ://www.w3.org/TR/xmlschema-1/#schema-repr
#URN解析
可以看到维基百科上 URN 的现实示例以及术语“解析 URN”的完整语义RFC-2169 和 RFC-2483 >。 根据这些 RFC,您需要的是本地软件或“URN 解析器”软件的 URL(webservice)执行N2L:给定一个URN,
返回一个网址。
广泛使用 URN
2002 年,URN 解析机制受到更多关注,并且出现了两个新的 RTF,RFC-3404 和 RFC-3405,解决了一个潜在的问题URN 问题,
一些解析问题仍然存在:诸如
urn:doi
或urn:lex:br
有一个如此使用且稳定的解析机制(位于 dx.doi.org 和 lexml.gov.br/urn 分别),但未在 IANA 的分配/urn-namespaces; 未使用、不稳定且不受控制的 URN(例如urn:oasis:names:tc:dita
)已在 IANA 注册了urn:oasis
。This question is not a good place for explanations about "URN resolution"...
We can imagine a translation (by an automatic translator) from this oasis URN to a schemaLocation filename or a URL, but it is a little bit exotic application for URNs.
See the usual semantic and values for schemaLocation at http://www.w3.org/TR/xmlschema-1/#schema-repr
#URN resolution
You can see real-life examples of URNs at Wikipedia and the complete semantic of the term "resolve a URN" at RFC-2169 and RFC-2483. According these RFCs what you need is a local software or a URL of a "URN resolver" software (a webservice) that do N2L: given a URN,
return a URL.
Wide use URNs
In 2002 the URN resolution mechanism received more attention, and two new RTFs, RFC-3404 and RFC-3405, solved a latent problem of URNs,
Some resolution problems persist: URNs like
urn:doi
orurn:lex:br
have a so used and stable resolution mechanism (at dx.doi.org and lexml.gov.br/urn respectively), but is not registered at IANA's assignments/urn-namespaces; a not used, not stable and not controlled URN likeurn:oasis:names:tc:dita
haveurn:oasis
registered at IANA....也许看看 RFC3121 OASIS 的 URN 命名空间?
编辑:我永远记不起 URI 和 URN,但我的理解是它们只是命名空间,它们实际上不必对应于网络上存储文件的某个真实位置。 他们只是划分了对命名空间部分的控制,因此 urn:oasis 处于 OASIS 的控制之下。 您不应该发明层次结构该部分中的任何 URI/URN,除非您可以控制它。
编辑2:在 oasis-open.org 中进行了一些谷歌搜索,名为 tblDeclGrp.xsd 和一些 对其和其他模式的评论。
...maybe look at RFC3121 A URN Namespace for OASIS?
edit: I can never remember URIs and URNs, but my understanding is they're just namespaces, they don't actually have to correspond to some real location on the network where a file is stored. They just divide up control over portions of the namespace so
urn:oasis
is under control of OASIS. You're not supposed to invent any URIs / URNs that are within that section of the hierarchy unless you have control over it.edit 2: A little google searching found a file in oasis-open.org called tblDeclGrp.xsd and some commentary on it and other schemas.
在本例中,schemaLocation 就是位置。 如果您在同一目录中有一个与此名称完全相同的文件,则应该对其进行解析。 它甚至包括 urn: 部分,所以完整的字符串。 在模式命名空间之后命名文件只是方便而已。 我必须承认一开始很混乱。
顺便提一句。 瓮不是一个位置,它只是一个 URI。 xs:include schemaLocation 的属性引用位置,但属性类型为包含 urn 架构的 anyURI
The schemaLocation is in this case the location. If you have a file named exactly like this in the same directory it should be resolved. It is even include the urn: part so the complete string. It is just convienient to name the file after the schema namespace. Confusing at first I must admit.
Btw. the urn is not a location it is just an URI. The attribute of the xs:include schemaLocation that refers to a location but the attribute type is anyURI which includes urn schema