XML Page

Schema Component Designators

Here is a little program that takes in XML Schemas and spits out short-form schema component paths for the canonical paths to components in the schema and an inverse program that takes simple paths and locates the corresponding compoment and prints some metadata about it.

Installation

This program uses Xerces-J schema component API.

Download these jar files and put them in your class path: mhscd_02.jar and (for convenience) xercesImpl291.jar.

Changes from previous version

  1. Xerces 2.9-1 fixed the null pointer exception involving annotations, so a special build is no longer required.
  2. Added a level parameter so that non-canonical paths could be generated.
  3. Added a namespace binding parameter so that when non-canonical paths are generated they do not have to use the same prefix for different namespaces.
  4. Added a simple schema locator program.
  5. Added API documentation online and ZIP.

Limitations

The locator only understands a subset of legal paths. In particular it does not currently understand paths that refer to more than one component. It does not understand most non-canonical path abbreviations. I expect to replace it with a more general locator API that does something more useful than printing basic metadata to standard output.

Usage

java com.mathling.scd.SCDGenerator [-a] [-s] [-l N] [-ns prefix=uri]* uri*
-a
Generate paths for annotations. You must build from the latest CVS source for this to work.
-s
Generate paths for components in the XML Schema namespace.
-l N
Generate paths N levels deep. N=0 (the default) means to generate only canonical paths.
-ns prefix=uri
Bind the prefix to the namespace URI.
uri
URIs of the schemas to process.
java com.mathling.scd.SCDLocator [-p path]* [-ns prefix=uri]* uri*
-p path
Path to locate. If no -p parameter is given, read paths from standard input.
-ns prefix=uri
Bind the prefix to the namespace URI.
uri
URIs of the schemas to process.

Example:

>java com.mathling.scd.SCDGenerator http://dublincore.org/schemas/xmls/simpledc20021212.xsd
/
/@p:base
/@p:lang
/@p:space
/@p:space/~0
/@p:space/~0/facet::enumeration
/p:relation
/p:source
/p:type
/p:coverage
/p:rights
/p:contributor
/p:title
/p:date
/p:identifier
/p:subject
/p:format
/p:creator
/p:publisher
/p:description
/p:language
/group::p:elementsGroup
/group::p:elementsGroup/model::sequence
/group::p:elementsGroup/model::sequence/model::choice
/attributeGroup::p:specialAttrs
/attributeGroup::p:specialAttrs/@p:base
/attributeGroup::p:specialAttrs/@p:lang
/attributeGroup::p:specialAttrs/@p:space
/attributeGroup::p:specialAttrs/@p:space/~0
/attributeGroup::p:specialAttrs/@p:space/~0/facet::enumeration
/~p:elementType
/~p:elementType/@p:lang

You can use this as a quick way of getting a sense of what it in a schema. I have also found that it can be a handy way to isolate differences in related schemas. The output of SCDGenerator can be the input to SCDLocator.

This is definitely a work-in-progress, buggy, subject to change and improvement without notice. Play with it, but don't bet the farm on it. I expect to expand and improve SCDLocator with a more general locator framework that understands the full range of paths in the current SCDs draft.

The previous version is available here: mhscd_01.jar using the built-from-CVS xerces262.jar.