kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="utf-8"?>
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 2 | <!--Arbortext, Inc., 1988-2006, v.4002-->
|
kprice | b80ff2a | 2006-09-18 19:22:32 +0000 | [diff] [blame] | 3 | <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"
|
| 4 | "concept.dtd">
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 5 | <concept id="cxmlcat" xml:lang="en-us">
|
| 6 | <title>XML file associations with DTDs and XML schemas</title>
|
| 7 | <titlealts>
|
| 8 | <searchtitle>XML file associations with DTDs and XML schemas</searchtitle>
|
| 9 | </titlealts>
|
| 10 | <shortdesc>When an XML file is associated with a DTD or XML schema, it is
|
| 11 | bound by any structural rules contained in the DTD or XML schema. To be considered
|
| 12 | a valid XML file, a document must be accompanied by a DTD or an XML schema,
|
| 13 | and conform to all of the declarations in the DTD or the XML schema.</shortdesc>
|
| 14 | <prolog><metadata>
|
kprice | 9623e9d | 2007-05-03 03:43:05 +0000 | [diff] [blame] | 15 | <keywords><indexterm>XML catalog<indexterm>overview</indexterm></indexterm>
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 16 | <indexterm>XML files<indexterm>associations</indexterm></indexterm></keywords>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 17 | </metadata></prolog>
|
| 18 | <conbody>
|
| 19 | <p>There are two different ways to associate XML files with DTDs or XML schemas.</p>
|
| 20 | <ol>
|
| 21 | <li>Direct association - The XML file contains either the name of a DTD in
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 22 | its doctype declaration (for example, <!DOCTYPE root-element SYSTEM "<varname>dtdfile.dtd</varname>"
|
| 23 | >, where <varname>dtdfile.dtd</varname> is the name of the DTD file) or it
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 24 | contains the path of an XML schema in the schemaLocation attribute of the
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 25 | XML file root element (for example, <xsi:schemaLocation="http://www.ibm.com/<varname>schema.xsd</varname>">,
|
| 26 | where <varname>schema.xsd</varname> is the name of the XML schema.</li>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 27 | <li>XML Catalog entry - You can register DTD and XML schema files in the XML
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 28 | Catalog and associate them with a Key that represents them. You can then
|
| 29 | refer to a DTD or XML schema file Key from an XML file instead of referring
|
| 30 | directly to the DTD or XML schema file. An XML Catalog entry contains two
|
| 31 | parts - the Key (which represents the DTD or XML schema) and a URI (which
|
| 32 | contains information about the DTD or XML schema location).</li>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 33 | </ol>
|
| 34 | <section><title>How an association works</title><b>Associating an XML file
|
| 35 | with a DTD </b><p>If an XML file is associated with a DTD, a DOCTYPE tag such
|
| 36 | as the following one is included in the XML file:<codeblock><!DOCTYPE root-name PUBLIC "<varname>InvoiceId</varname>" "<varname>C:\mydtds\Invoice.dtd</varname
|
| 37 | >">
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 38 | </codeblock></p><p>InvoiceId is the public identifier of the DTD file. It
|
| 39 | is used to associate the XML file with a DTD file (in this case, the DTD file
|
| 40 | is Invoice.dtd). If the public identifier InvoiceId corresponds to the Key
|
| 41 | of the XML Catalog entry for Invoice.dtd, then the U<?Pub Caret?>RI of the
|
| 42 | XML Catalog entry (which contains information about the location of Invoice.dtd)
|
| 43 | is used to locate the DTD. Otherwise, the DOCTYPE's system identifier ("C:\mydtds\Invoice.dtd"),
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 44 | which refers directly to the file system location of the DTD, is used to locate
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 45 | the DTD.</p><note>You can also use a system identifier as a Key in an XML
|
| 46 | Catalog entry. If you use a system identifier as a Key, a DOCTYPE tag such
|
| 47 | as the following one is included in an XML file:</note><codeblock><!DOCTYPE Root-name SYSTEM "MyDTD.dtd"> </codeblock><p>where
|
| 48 | MyDTD.dtd is the system identifier that corresponds to the Key of an XML Catalog
|
| 49 | entry.</p></section>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 50 | <section><b>Associating an XML file with an XML schema</b><p>If an XML file
|
| 51 | is associated with an XML schema, one or more schema location attributes are
|
| 52 | included in the XML file. The information in the schemaLocation is provided
|
| 53 | as a "hint" to the XML processor. The following examples show schemaLocation
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 54 | attributes:</p><p> <b>Example 1 </b><codeblock><purchaseOrder xmlns="http://www.ibm.com"
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 55 | xsi:schemaLocation="http://www.ibm.com C:\myschemas\PurchaseOrder.xsd">
|
| 56 | <shipTo country="US">
|
| 57 | ...</codeblock> </p><p><b>Example 2 </b><codeblock><purchaseOrder xmlns="http://www.ibm.com"
|
| 58 | xsi:schemaLocation="http://www.ibm.com PO.xsd">
|
| 59 | <shipTo country="US">
|
| 60 | ....</codeblock> </p><p>In Example 1, the schemaLocation 'hint' ('C:\myschemas\PurchaseOrder.xsd')
|
| 61 | refers directly to the file system location or URI of the XML schema. In this
|
| 62 | case, the schema file will be located by the XML processor directly.</p><p>In
|
| 63 | Example 2, the schemaLocation 'hint' ('PO.xsd') refers to an XML Catalog entry.
|
| 64 | PO.xsd corresponds to the <varname>Key</varname> of the XML Catalog entry
|
| 65 | for PurchaseOrder.xsd, and the URI of the XML Catalog entry (which contains
|
| 66 | information about the location of PurchaseOrder.xsd) will be used to located
|
| 67 | the XML schema.</p><p>In both examples, <codeph>http://www.ibm.com</codeph> in
|
| 68 | the <codeph>xsi:schemaLocation</codeph> tag is a URI that identifies the namespace
|
| 69 | for the XML schema.</p><p>You can also use a namespace as a Key for an XML
|
| 70 | Catalog entry. If you use a namespace as a Key, a schemaLocation tag such
|
| 71 | as the following one is included in an XML file:<codeblock><purchaseOrder xmlns:="www.ibm.com"
|
| 72 | xsi:schemaLocation="http://www.ibm.com po/xsd/PurchaseOrder.xsd "></codeblock></p><p>The
|
| 73 | schemaLocation attribute points to both the Key and the actual location of
|
| 74 | the schema.</p><p><b>DTD or XML schema resides on a remote server</b></p><p>Several
|
| 75 | functions in the XML editor, such as validation and content assist, require
|
| 76 | the availability of a DTD or an XML schema. The product documentation provides
|
| 77 | usage information for cases when the DTD or XML schema resides on your local
|
| 78 | machine. However, in many cases, the DTD or XML schema can reside on a remote
|
| 79 | server, for example:</p><p><codeph><!DOCTYPE Catalog PUBLIC "abc/Catalog"
|
| 80 | "http://xyz.abc.org/dtds/catalog.dtd"></codeph></p><p>Normally, this case
|
| 81 | poses no problem, because the DTD or XML schema can be retrieved from the
|
| 82 | remote server. However, if you are behind a firewall, and do not have a SOCKSified
|
| 83 | system, the workbench currently does not provide a way for you to specify
|
| 84 | a socks server for retrieving a DTD or XML schema. If you are unable to SOCKSify
|
| 85 | your system, the workaround for this problem is to retrieve a copy of the
|
| 86 | DTD or XML schema (using a Web browser, for example) and save that copy on
|
| 87 | your local machine. Then, you can either place a local copy in the same project
|
| 88 | as your XML file, or use the XML Catalog to associate a public identifier
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 89 | with the DTD's (local) location.</p><note>If you have an XML file associated
|
| 90 | with an XML schema or DTD that is elsewhere in the network, and you are working
|
| 91 | on a machine disconnected from the network, you can follow the steps described
|
| 92 | previously if you want to use content assist or validate your XML file. </note></section>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 93 | <section><title>Advantages of XML Catalog entry associations</title><p>If
|
| 94 | you create a direct association between an XML file and an XML schema or DTD
|
| 95 | file, any time you change the location of the schema or DTD you have to track
|
| 96 | down and update all of the referencing XML files with the new location of
|
| 97 | the DTD or schema. If, however, you associate an XML file with an XML schema
|
| 98 | or DTD Key, then, when you change the location of the schema or DTD, you only
|
| 99 | have to update the XML Catalog entry, instead of each individual XML file.</p><p>For
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 100 | example, you have a DTD called Building.dtd, which is associated with five
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 101 | XML files - Office.xml, House.xml, Apartment.xml, Bank.xml, and PostOffice.xml.
|
| 102 | You move the DTD file Building.dtd to a new location. If you have a direction
|
| 103 | association between Building.dtd and all the XML files, you will have to update
|
| 104 | the <DOCTTYPE> declaration in each XML file to reflect the new location
|
kprice | b80ff2a | 2006-09-18 19:22:32 +0000 | [diff] [blame] | 105 | of Building.dtd. If, however, you have an XML Catalog association, and all
|
| 106 | the XML files just refer to the Key of Building.dtd, then you only have to
|
| 107 | update the URI and all the XML files will point to the new location of Building.dtd.</p></section>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 108 | <section><title>Updating an entry in the XML Catalog</title><p>After you have
|
| 109 | updated an entry in the XML Catalog, you might need to refresh the XML editor
|
| 110 | view so that it uses the new information. To do this, click the <uicontrol>Reload
|
| 111 | Dependencies</uicontrol> toolbar button <image href="../images/rldgrmr.gif">
|
| 112 | <alt>This graphic is the Reload Dependencies toolbar button</alt></image> and
|
| 113 | the view will be updated using the current XML Catalog settings. You only
|
| 114 | need to refresh the XML editor view when you have an XML file open that references
|
| 115 | the XML Catalog entry that was updated.</p><p>For more information, refer
|
kprice | b80ff2a | 2006-09-18 19:22:32 +0000 | [diff] [blame] | 116 | to the related tasks.</p></section>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 117 | </conbody>
|
| 118 | </concept>
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 119 | <?Pub *0000008359?>
|