How do you resolve a URN?
Asked Answered
N

3

5

I have an XML schema file which references a urn based location. Is there some way to resolve this into a url, or some way to actually read the file it refers to.

<xs:include schemaLocation="urn:oasis:names:tc:dita:xsd:tblDeclGrp.xsd:1.1"/>
Natalianatalie answered 7/5, 2009 at 17:50 Comment(1)
This question is not a good place for explanations about "URN resolution". Please post here a comment with a link to a better one, answering the generic "How do you resolve a URN?"... Ok, I posted bellow a draft.Styrene
L
2

...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.

Longwood answered 7/5, 2009 at 18:1 Comment(1)
I had a read through the RFC, and a few other sources. As a unique identifier this seems useful, but its not much help to a parser trying to resolve the actual schema, as each provider may have a different format.Natalianatalie
S
7

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,

If URN resolution is collapsed into generic URI resolution, URNs may suffer by the lack of adoption of URI resolution.

The solution is to allow for shortcutting for URN resolution. (...) generic URI resolution starts by inserting rules for known URI schemes into the 'uri.arpa.' registry. For the 'URN:' URI scheme, one of the rules found in 'uri.arpa.' would be for the 'urn' URI scheme. This rule would simply delegate to the 'urn.arpa.' zone for additional NAPTRs based on the URN namespace. Essentially, the URI Resolution Rewrite Rule for 'URN:' is the URN Resolution Application's First Well Known Rule.

Some resolution problems persist: URNs like urn:doi or urn: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 like urn:oasis:names:tc:dita have urn:oasis registered at IANA.

Styrene answered 8/6, 2014 at 12:14 Comment(5)
For XML specifically, such a "URN resolver" would typically be handled as an XML catalog provided to the software processing the XML or an XML parser in code. There are various formats of XML catalog, including an OASIS XML-based format, an OASIS plain-text format (TR 9401) and another XML-based format called XCatalog. What is supported depends on the software/parser.Stringed
Hi @G_H, important to remember that URNs are names, that is, simple and valid strings, there are no XML encode in it. And, of course, an URN is a valid attribute-value in XML element.Styrene
I think you misunderstood my comment. I am not implying there's any XML in a URN. The question asked about resolving a URN specifically within an XML schema. Many libraries and software for handling XML will support so-called XML catalogs which allow you to map a URN string to a specific URL. For the asker that might have been a solution so I decided to mention it.Stringed
@G_H, ops, ok, but remember that my answer is about generic resolution. The old original TR 9401 (or this other link say nothing about URN, seems an augment suggested by RFC 2483... Them, the "XML catalogs" based in URNs (like urn:oasis:names:tc:entity:xmlns:xml:catalog) have non-obvious resolution algorithm. The simplest algorithm for XML is the concatenation a url_base attribute with URN.Styrene
Other good reference for URN resolution in a context of "REST API resolution by redirection" is the RFC 6570, that defines "URI templates", that, in this case, is an URL template where the place holder is an URN or a simplifyed URN. Example: https://doi.org/{urn}. You can test with full doi.org/urn:doi:10.1000/182 or simplified URN by doi.org/10.1000/182 using theDOI fragment of urn:doi:{theDOI}. Test with a scientific article's URN, urn:doi:10.1038/ncomms7368. Other example: https://www.lexml.gov.br/urn/{urn_lex}.Styrene
L
2

...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.

Longwood answered 7/5, 2009 at 18:1 Comment(1)
I had a read through the RFC, and a few other sources. As a unique identifier this seems useful, but its not much help to a parser trying to resolve the actual schema, as each provider may have a different format.Natalianatalie
B
1

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

Biology answered 7/5, 2009 at 17:58 Comment(1)
In addition, the include is used to use other schema of the same namespace or without namespace, it makes no sense to specify a namepace here but a physical location. The import is used to use other schema in other namespaces, and that element has a separate attribute to specify this.Keeney

© 2022 - 2024 — McMap. All rights reserved.