All Downloads are FREE. Search and download functionalities are using the official Maven repository.

msv.msv.doc.commandline.html Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version



	
	Usage Guide For Sun Multi-Schema Validator



Sun Multi-Schema XML Validator

version @@VERSION@@

Kohsuke KAWAGUCHI

Copyright © 2001-@@YEAR@@
Sun Microsystems, Inc.
All Rights Reserved

Command Line Usage Guide

The Sun Multi-Schema Validator(MSV) is a JavaTM technology tool to validate XML documents against a variety of XML schemata. It supports RELAX Namespace, RELAX Core, RELAX NG, TREX, XML DTDs, and a subset of W3C XML Schema Part 1.

Usage

To validate XML documents with a RELAX grammar/module, enter a command of the following form:


$ java -jar msv.jar MySchema.rxg MyDocument1.xml MyDocument2.xml ...

If you'd like to use TREX, enter a command of the form:


$ java -jar msv.jar MySchema.trex MyDocument1.xml MyDocument2.xml ...

Or if you'd like to use W3C XML Schema, enter the command:


$ java -jar msv.jar MySchema.xsd MyDocument1.xml MyDocument2.xml ...

MSV will detect the schema language regardless of its file extension if the schema is written in XML syntax.

However, DTD is only one exception. MSV relies on the file extension ".dtd" to detect XML DTDs. That means you have to have the ".dtd" extension for your DTDs. To validate XMLs with a DTD, enter the command:


$ java -jar msv.jar my.dtd MyDocument1.xml MyDocument2.xml ...

Some environments support wild cards for filenames, while others (e.g., "jview" VM from Microsoft) don't. You can also use a URL instead of a filename.

If the schema contains errors, you will see messages like this.


start parsing a grammar.
the following hedgeRules form an infinite recursion ( y > z > y )
  18:23@file:///c:/work/relax/relax024.e.rlx
  14:23@file:///c:/work/relax/relax024.e.rlx
failed to load a grammar.

18:23@XYZ indicates that the error is located at line 18, column 23 of file XYZ.

If the document and the schema are both valid, you will see messages like this:


start parsing a grammar.
validating c:\work\relax\relax001.v00.xml
the document is valid.

If the schema is valid but the document has errors, you will see messages like this:


start parsing a grammar.
validating c:\work\relax\relax001.n02.xml
Error at line:5, column:5 of file:///c:/work/relax/relax001.n02.xml
  tag name "q" is not allowed. possible tag names are:

the document is NOT valid.

Please note that line/column infomation is sometimes inaccurate, and one tab char is counted as one character, not 4 or 8. So you might want to look around to find the actual error.

Options

The command line tool has several other options. You can see the list of available options by invoking MSV without any arguments.


$ java -jar msv.jar

Here are some notable ones that require some explanations.

-catalog
This option will enable the catalog support, which allows you to resolve external references to schemas/DTDs to your local copies. This can be used to avoid costly network operations to obtain a standard schema, for example.
To use this option, you have to download resolver.jar from http://xml.apache.org/commons/ and place it in the same directory as msv.jar (or make it somehow available to the classpath.)
For detailed instruction regarding how to use/configure catalogs, refer to the documentation of the entity resolver.

Known Limitations

DTD

  1. Attribute declarations of the form of xmlns:*** are ignored. All namespace declarations within the instance document are also ignored.

  2. The detection of XML DTD is based on the file extension. This causes a problem when you are using MSV through JARV or GrammarLoader. For details, see this.

  3. In general, MSV handles XML namespaces differently from most DTD validators. As a result, MSV may validate documents that other DTD validators reject. When this is the case, MSV always issues a warning.

  4. Strictly speaking, MSV cannot replace XML parser's DTD validation because DTD validation affects lot of other things. For example, DTD validation in XML parser can expand entity references and provides default attribute values; DTD validation by MSV doesn't do those things.

TREX

This implementation fully conforms to the current specification (2001-02-13 version).

RELAX NG

This implementation is intended to almost fully implement the spec (Aug,11,2001 version) except the followings:

  • recursive self reference check is performed after notAllowed is expanded. Therefore MSV fails to catch some of the error. (section 4.18 of the spec.)

MSV supports RELAX NG DTD Compatibility Spec (2001/09/07). MSV implements all three features and all of them conform to level 1 (everything except infoset modification.)

MSV supports a vendor-independent Java interface for RELAX NG datatype libraries. MSV can work with any datatype library that implements this interface. For more information, see RNGDatatypeLibrary.html.

RELAX Core

This implementation fully conforms to the current JIS TR specification. ( English , Japanese )

RELAX Namespace

<anyOtherAttribute> is not implemented.

W3C XML Schema Part 1

  1. "Schema component constraints" and "Schema representation constraints" are not fully enforced. In other words, MSV may accept schemas that are rejected by other conforming processors.

    Unimplemented checks include (but not limited to) "UPA constraint" and "Particle Valid Restriction"

  2. "Missing sub-components" are treated as immediate errors. This behavior better serves the majority of users.

  3. Default values are ignored. In fact, no infoset contribution is supported: MSV validates documents, but it doesn't augment them. Post Schema-Validation Infoset (PSVI) is also not supported.

Further Reading

To learn RELAX, "How to RELAX" is a good starter. To learn TREX, there is the "TREX tutorial". RELAX NG also has its own tutorial. For W3C XML Schema Part 2, see section 2.3 of XML Schema Part 0: Primer.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy