.rnc
) easy to write..rng
)
e.g. %xmllint --noout myFile.xml --relaxng
myGram.rng
DOMDocument::relaxNGValidate
exact parallel
to DOMDocument::schemaValidate
(used in Average_1V.php
)http://code.google.com/p/jing-trang/
jing
java -jar
/The/.../Path/to/jing-20091111/bin/jing.jar $1.rng $2.xml
trang
java -jar /The/.../Path/to/trang-20091111/trang.jar
$1.rnc $1.rng
java -jar /The/.../Path/to/trang-20091111/trang.jar
$1.rnc $1.xsd
text, empty, string, token
<name>
= <expression>
element <name> { <expression> }
attribute <ame> { <expression> }
list { <expression> }
,
" "&
" and "|
"
(sequence, arbitrary order, choice)*
", "+
" and "?
"
(iteration, strict iteration, option) node = element node {
(node, node) | leaf { empty }
}
<xsd:restriction
base="xsd:integer"> |
xsd:integer { minInclusive
= "0" maxInclusive = "20" } |
<xsd:restriction
base="xsd:string"> <xsd:minLength
value="1"/> <xsd:maxLength
value="127"/> |
xsd:string { minLength
= "1" maxLength = "127" } |
<xsd:restriction
base="xsd:string"> [A-Z][a-z]* "/> |
xsd:string { pattern
=
"[A-Z][a-z]*" } |
noteSur20 = attribute note { xsd:integer {minInclusive =
"0"
maxInclusive = "20" } }
<define name="noteSur20">
<attribute name="note">
<data type="integer">
<param
name="minInclusive">0</param>
<param
name="maxInclusive">20</param>
</data>
</attribute>
</define>
<define name="nomPers">
<data type="string">
<param
name="pattern">[A-Z][a-z]*</param>
</data>
</define>
namespace prefix
= "URI"
default namespace = "URI"
NM1.ds.rnc
(with default ns) and NM1.ns.rnc
(with prefix)NM1.ds.xml
(with
default ns) as well as to NM1.ns.xml
(with prefix).NMrdf.rnc
(translated in XML format as NMrdf.rng
)javax.xml.validation
SchemaFactory
factory =
SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
// as opposed to XMLSchema :
XMLConstants.W3C_XML_SCHEMA_NS_URI
...........
compiles, but does not run :
Error : No SchemaFactory that implements the schema language specified
by: http://relaxng.org/ns/structure/1.0 could be loaded
import com.thaiopensource.relaxng.jaxp.CompactSyntaxSchemaFactory;
// Jing
.............
System.setProperty(
SchemaFactory.class.getName() + ":" + XMLConstants.RELAXNG_NS_URI,
"com.thaiopensource.relaxng.jaxp.CompactSyntaxSchemaFactory"
); // necessary
precaution
SchemaFactory factory
=
CompactSyntaxSchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
............
.....jing-20091111/bin/jing.jar
(to be downloaded from jing-trang) on the classPath.VerifRNC
,
to be used with grammars in
compact syntax (.rnc
)..rng
), use "com.thaiopensource.relaxng.jaxp.XMLSyntaxSchemaFactory"
.StreamSource
. DOMSource
,
as we did in Average_1V
,
execution aborts IllegalArgumentException (null)
javax.xml.validation
.