XML Catalog

XML Catalog

XML documents typically refer to external entities, for example the public and/or system ID for the Document Type Definition. These external relationships are expressed using URIs, typically as URLs.

However, if they're absolute URLs, they only work when your network can reach them. Relying on remote resources makes XML processing susceptible to both planned and unplanned network downtime.

Conversely, if they're relative URLs, they're only useful in the context where the were initially created. For example, the URL "../../xml/dtd/docbookx.xml" will usually only be useful in very limited circumstances.

One way to avoid these problems is to use an entity resolver (a standard part of SAX) or a URI Resolver (a standard part of JAXP). A resolver can examine the URIs of the resources being requested and determine how best to satisfy those requests. The XML catalog is a document describing a mapping between external entity references and locally-cached equivalents.

Example Catalog.xml

The following simple catalog shows how one might provide locally-cached DTDs for an XHTML page validation tool, for example.

This catalog makes it possible to resolve -//W3C//DTD XHTML 1.0 Strict//EN to the local URI dtd/xhtml1/xhtml1-strict.dtd. Similarly, it provides local URIs for two other public IDs.

Note that the document above includes a DOCTYPE - this may cause the parser to attempt to access the system ID URL for the DOCTYPE (i.e. http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd) before the catalog resolver is fully functioning, which is probably undesirable. To prevent this, simply remove the DOCTYPE declaration.

The following example shows this, and also shows the equivalent <system/> declarations as an alternative to <public/> declarations.

Using a Catalog - Java SAX Example

Catalog resolvers are available for various programming languages. The following example shows how, in Java, a SAX parser may be created to parse some input source in which the org.apache.xml.resolver.tools.CatalogResolver is used to resolve external entities to locally-cached instances. This resolver originates from Apache Xerces but is now included with the Sun Java runtime.

Simply create a SAXParser in the normal way, using factories. Obtain the XML reader and set the entity resolver to the standard one (CatalogResolver) or another of your own.

final SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); final XMLReader reader = saxParser.getXMLReader();

final ContentHandler handler = ...; final InputSource input = ...;

reader.setEntityResolver( new CatalogResolver() ); reader.setContentHandler( handler ); reader.parse( input );

It is important to call the parse method on the reader, "not" on the SAX parser.

ee also

* [http://www.oasis-open.org/committees/entity/spec-2001-08-06.html Oasis XML Catalogs specification]
* [http://java.sun.com/webservices/docs/1.6/jaxb/catalog.html XML Entity and URI Resolvers] , Sun
* [http://xmlcatmgr.sourceforge.net/ XML Catalog Manager] project on Sourceforge


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • XML Catalog — XML Catalogs ist eine Technik zum Ersetzen von externen Referenzen in XML Dokumenten. Hierbei wird beim Parsen des XML überprüft, ob es für die referenzierte externe Datei im Katalog eine Ersetzungsregel gibt. Wird hier eine zutreffende Regel… …   Deutsch Wikipedia

  • XML Catalogs — ist eine Technik zum Ersetzen von externen Referenzen in XML Dokumenten. Hierbei wird beim Parsen des XML überprüft, ob es für die referenzierte externe Datei im Katalog eine Ersetzungsregel gibt. Wird hier eine zutreffende Regel gefunden, so… …   Deutsch Wikipedia

  • XML — Infobox file format name = Extensible Markup Language icon = logo = extension = .xml mime = application/xml, text/xml (deprecated) type code = uniform type = public.xml magic = owner = World Wide Web Consortium genre = Markup language container… …   Wikipedia

  • XML for Analysis — (abbreviated as XMLA) is the industry standard for data access in analytical systems, such as OLAP and Data Mining. XMLA is based on other industry standards such as XML, SOAP and HTTP. XMLA is maintained by XMLA Council with Microsoft, Hyperion… …   Wikipedia

  • XML Shareable Playlist Format — Infobox file format name = XSPF extension = .xspf mime = application/xspf+xml owner = [http://xiph.org/ Xiph.Org Foundation] creatorcode = genre = Playlist containerfor = containedby = extendedfrom = XML extendedto =XML Shareable Playlist Format… …   Wikipedia

  • XML User Interface Language — Окно настройки Mozilla Firefox 1.5 сделано с использованием XUL (заголовок  от менеджера окон) XUL (произносится «зул», XML User Interface Language)  язык разметки для создания динамических пользовательских интерфейсов на основе Mozilla и… …   Википедия

  • Oxygen XML Editor — <oXygen/> XML Editor Stable release 13.1 / October 26, 2011; 26 days ago (2011 10 26) Written in Java …   Wikipedia

  • Java API for XML Processing — The Java API for XML Processing, or JAXP (pronounced jaks p ), is one of the Java XML programming APIs. It provides the capability of validating and parsing XML documents. The three basic parsing interfaces are: * the Document Object Model… …   Wikipedia

  • BME Catalog — BMEcat ist ein standardisiertes Austauschformat für Katalogdaten im Katalogmanagement. Das BMEcat Format basiert auf der XML Technologie und erlaubt den standardisierten Austausch von Katalogdaten sowie von Produktklassifikationssystemen wie z. B …   Deutsch Wikipedia

  • Office Open XML — Not to be confused with OpenOffice.org XML or Microsoft Office XML formats. Office Open XML Office Open XML file formats Open Packaging Conventions Open Specification Promise Vector Markup Language Office Open XML software Comparison of… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”