4

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"/>
Norbert Hartl
  • 9,675
  • 5
  • 33
  • 45
Colin
  • 576
  • 3
  • 6
  • This question is not a good place for explanations about "[URN resolution](http://tools.ietf.org/html/rfc2483)". 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. – Peter Krauss Jun 08 '14 at 12:16

3 Answers3

5

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.

Peter Krauss
  • 11,340
  • 17
  • 129
  • 247
  • 1
    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. – G_H Feb 15 '17 at 09:25
  • 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. – Peter Krauss Jan 14 '21 at 17:41
  • 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. – G_H Jan 16 '21 at 14:56
  • @G_H, ops, ok, but remember that my answer is about generic resolution. The [old original TR 9401](https://www.oasis-open.org/specs/a401.htm) (or [this other link](https://support.ptc.com/help/arbortext/r8.0.0.0/en/index.html#page/admin/doctypes/help6563_help6563_3.html) say nothing about URN, seems an augment suggested by [RFC 2483](https://tools.ietf.org/html/rfc2483)... 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. – Peter Krauss Jan 16 '21 at 23:50
  • Other good reference for URN resolution in a context of "REST API resolution by redirection" is the [RFC 6570](https://tools.ietf.org/html/rfc6570), 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 https://doi.org/urn:doi:10.1000/182 or simplified URN by https://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}`. – Peter Krauss Jan 17 '21 at 00:07
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.

Jason S
  • 171,795
  • 155
  • 551
  • 900
  • 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. – Colin May 08 '09 at 07:44
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

Norbert Hartl
  • 9,675
  • 5
  • 33
  • 45
  • 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. – Bruno Ranschaert Oct 25 '11 at 20:08