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.


This program uses Xerces-J schema component API.

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

Changes from previous version

  1. Fixed some errors in handling of built-in types, and named groups
  2. Added limited support for non-canonical locators with currentComponent and component axes
  3. Added option to use full paths in generating (e.g. using schemaElement:: form)
  4. Made the locator program able to handle some paths that refer to multiple components

Earlier changes

  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.


The locator only understands a subset of legal paths. In particular it does not currently understand all paths that refer to more than one component. It does not understand many non-canonical path abbreviations.


java com.mathling.scd.SCDGenerator [-a] [-s] [f] [-l N] [-ns prefix=uri]* uri*
Generate paths for annotations. You must build from the latest CVS source for this to work.
Generate paths using full form, e.g. /schemaElement::foo instead of /foo
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.
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.
URIs of the schemas to process.


>java com.mathling.scd.SCDGenerator http://dublincore.org/schemas/xmls/simpledc20021212.xsd

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.

Licensing and Copyright

Copyright 2005-2010 Mary Holstege.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 United States License.

Previous versions

Version 1 is available here: mhscd_01.jar using the built-from-CVS xerces262.jar.

Version 2 is available here: mhscd_02.jar.