3.1. Uniform Resource Names and Uniform Resource Locators

URIs identify namespaces. URIs take the form of Uniform Resource Names (URNs) or Uniform Resource Locators (URLs). URNs identify a resource by giving it a globally unique and persistent name. The following is a typical URN:

urn:example:mytags 

in which ‘urn’ identifies the Uniform Resource Name scheme, which means that this URI is a URN, ‘example’ is a namespace identifier (NID), and ‘mytags’ is a namespace-specific string (NSS).

Do not confuse namespace in the URN syntax description with the concept of Namespace from the Namespace Recommendation. The URN specification has its own concept of namespaces.

URLs uniquely identify the location of a resource. Browsing the Web wouldn’t be possible without URLs. The following is a typical URL:

http://www.example.com/mytags 

in which ‘http’ identifies the scheme and ‘//www.example.com/mytags’ is the scheme-specific part.

The scheme-specific part differs, based on the scheme used. Although you usually see URLs with the http protocol specified, URLs using other protocols are perfectly legal to use as namespace identifiers. These include mailto, ftp, and uuid, among others. Although no resource is required to be available when using a URL to identify an XML Namespace, people—and even applications—might try to dereference your URL, looking for resources such as an XML schema or documentation. As a best practice, you should use a URN if you have no intention of providing additional information about the XML vocabulary the XML Schema is defining. See Section 3.1.2 for ideas on what can appear at the end of a namespace URL.

3.1.1. Creating URIs

When generating a URI for a namespace that you plan to distribute publicly, you should follow certain protocols to ensure uniqueness. You do not want to use a common name that others might use. If you do, you risk having naming clashes with other XML vocabularies.

That is one of the reasons HTTP URLs are popular for specifying namespaces. The first part of the scheme-specific string is a domain name that you register and own. This eliminates accidental naming clashes and gives you certain rights in forbidding others to use it.

URNs have similar rules. There is a procedure to register an NID with the Internet Engineering Task Force (IETF). After you go through the registration process, you own the NID for use in creating names. You are not required to register an NID, however. There is a protocol for using unregistered names by prepending an ‘x-’ to the NID to identify it as experimental. Even so, you risk naming clashes if you choose common words for your NID, so a good practice would be to use a domain you control. For example:

urn:x-example-com:mytags 

where ‘example.com’ is a registered domain name under the control of the author. You might have noticed that the periods used in the URL were turned into dashes in the URN. Both URLs and URNs have specific rules about which characters are allowed. For more information on creating URLs and URNs, see the IETF RFCs:

3.1.2. Using RDDL with Namespace URLs

When deciding whether to use a URL or a URN, a good rule is to use a URL if something is retrievable from the identified location. This could be an XML schema, documentation for the namespace, or something else. If you don’t have anything to retrieve, use a URN. When using a URL to identify a namespace, the question arises of what you get when you access the URL with a browser. There’s no consensus in the XML community on this. Some in the community think it should be a DTD or schema. Others feel it should be documentation or a package of various resources related to the namespace being used.

To help solve this problem, an XML vocabulary called Resource Directory Description Language (RDDL) was developed by a group of individuals on the XML-DEV mailing list. This vocabulary uses the XLink Recommendation, XML Linking Language (XLink) Version 1.0 (http://www.w3.org/TR/xlink), to identify a number of resources that can be associated with a namespace. Here’s an example from the XML namespace that identifies a DTD as well as a schema:

<rddl:resource 
    xlink:title="DTD for validation" 
    xlink:arcrole= 
        "http://www.rddl.org/purposes#validation" 
    xlink:role= 
        "http://www.isi.edu/in-notes/iana/assignments/media-types/text/xml-dtd" 
    xlink:href="XMLSchema.dtd"/> 
<rddl:resource id="xmlschema" 
    xlink:title="XML Schema schema document" 
    xlink:role="http://www.w3.org/2001/XMLSchema" 
    xlink:arcrole= 
        "http://www.rddl.org/purposes#schema-validation" 
    xlink:href="XMLSchema.xsd"/> 

When processing a RDDL document, you can use the xlink:arcrole attribute to determine what resources are available, and then use the xlink:href attribute to retrieve them. This gives you the flexibility to associate a variety of resources with a document. The application that processes the document can use whichever of the resources is most appropriate. For more information on RDDL, see http://www.rddl.org/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.214.155