* Commons.Xml.Relaxng

** Introduction

  RelaxngValidatingReader is an implementation to validate XML with RELAX NG
  grammar. You can use full standard grammar components with it.

  Currently it supports both xml syntax and compact syntax.

  It supports RELAX NG predefined datatypes and XML Schema datatypes (its
  DatatypeLibrary is http://www.w3.org/2001/XMLSchema-datatypes ).

  All classes which is expected to use are in namespace Commons.Xml.Relaxng,
  except for Commons.Xml.Relaxng.Rnc.RncParser class (which is used to parse
  compact syntax).
  There is another namespace Commons.Xml.Relaxng.Derivative which is not
  expected to be used in users custom classes, though the classes are public
  as yet.


** Grammar Object Model

  RELAX NG grammar structure is represented in abstract RelaxngPattern class
  and its derivations. The easiest way to get this instance is to use
  static Read() method of RelaxngPattern class:

	RelaxngPattern pattern = RelaxngPattern.Read (
		new XmlTextReader ("relaxng.rng");

  You can also use RelaxngPattern class to reuse grammar instance, as
  already described (see Grammar Object Model).

  And also, RelaxngGrammar and its contents can be created with managed code
  like System.Xml.Schema.XmlSchema.


** Compact Syntax Support

  Commons.Xml.Relaxng.dll also supports RELAX NG Compact Syntax. To parse
  compact syntax file, use Commons.Xml.Relaxng.Rnc.RncParser class:

	RncParser parser = new RncParser (new NameTable ());
	TextReader source = new StreamReader ("relaxng.rnc");
	RelaxngGrammar grammar = parser.Parse (source);


** Validating Reader usage

  RelaxngValidatingReader is used to validate XML document with RELAX NG
  grammar. The usage is simple:

	XmlReader instance = new XmlTextReader ("instance.xml");
	XmlReader grammar = new XmlTextReader ("my.rng");
	RelaxngValidatingReader reader = 
		new RelaxngValidatingReader (instance, grammar);

  Then Read() method (and other reading methods such as ReadElementString())
  reads the instance, validating with the supplied grammar.


** Datatype support

  Commons.Xml.Relaxng now supports custom datatype library. There are two 
  classes from which you have to write classes derived.

  <ul>
	* RelaxngDatatype: it represents the actual data type

	* RelaxngDatatypeProvider: it provides the way to get RelaxngDatatype from QName and parameters
  </ul>

  RelaxngDatatype class has Parse() method which is used for validation.
  Basically RelaxngValidatingReader is only aware of that if the typed
  elements or attributes are parsable (you can override IsValid() method
  to change this behavior) using Parse() method for each datatype.

  To enable custom datatype support, first you have to implement concrete
  RelaxngDatatype implementations (it only requires to override Parse(), 
  Name and NamespaceURI) and then RelaxngDatatypeProvider implementations
  (only GetDatatype() is required) to return the datatypes you implemented
  as above.

  Basically RelaxngDatatypeProvider is designed to allow to contain 
  datatypes in different namespaces (e.g. supporting both XML schema
  datatypes and default namespace types). You can also use 
  RelaxngMergedProvider class to combine existing two or more datatype
  providers. However, for ease of datatype search, it is indexed by the
  namespace URI (if you want to mix namespace-overrapped providers, you can
  implement your own merging provider). 


** Known bugs

  Currently it is beta version as yet. It has some bugs:

	- Grammar simplification is incorrectly implemented as yet. It will
	  fail to check incorrect recursion and might bind ref to incorrect
	  definitions.
	  not handle the same name define components properly.
	- Name class analysis and constraint check is not implemented (part
	  of spec 7).
	- Empty string might not be validated properly.

