Scripts to make working with XML schemas simpler on OSX and Linux by generating an XML Catalog.
The scripts works out-of-the box on OSX with limxml2-utils
from macports.
It should be easy to adapt to other systems by changing the paths in create_catalog.sh
.
create_catalog.sh
downloads a bunch of schema's and creates an local XML catalog from them.
It requires xmlcatalog
and curl
. xmlcatalog
is typically packaged in libxml2-utils
.
The generated catalog is used by xmllib2
and xmllint
will automatically be used
if it is stored in a well known location.
Schema's are downloaded once and stored locally. See create_catalog.sh
for the list
of downloaded schema's and paths, and update it to your needs.
For a Linux distro, you probably need to update the CATALOG_LOCATION
and CATALOG_SHARE
in create_catalog.sh
first so the catalog is stored in a location that is used by xmllint
.
You can use xmllint --help
to find out what this location is on your system.
To create the catalog or to update an existing catalog run: create_catalog.sh
In the "Oxygen XML Editor" preferences go to XML->XML Schema and under "catalogs" add:
file:/opt/local/etc/xml/catalog
Now XML schema validation and "Show definition" works for XML files that use schema's that are defined in the catalog.
Create and catalog.properties
file (e.g. in the same directory as the catalog) with the following content:
# Catalog.properties file for Xerces (Java apps)
# See: https://xerces.apache.org/xml-commons/components/resolver/tips.html#properties
# List of XML catalog files to load, separated by ';'.
catalogs=/opt/local/etc/xml/catalog
# If non-zero, the Catalog classes will print informative and debugging
verbosity=99
In the IDE preferences go to "Languages & Frameworks" -> "Schemas and DTDs" -> "Catalogs" and add the path to the
catalog.properties
file.
To test if the catalog is working, open an XML file that uses a schema that is defined in the catalog
xsdvalidate
validates an XML file against it's schema using the XML catalog to
lookup the schema's used in the XML file by namespace. Requires xmllint
.
Use: xsdvalidate <XML file>