The RELAX NG example is similar to the other examples.
Create a subdirectory named example3 in the addon/ subdirectory of XXE user preferences directory:
Copy example3.rnc[1]to directory addon/example3/.
default namespace = "http://www.xmlmind.com/xmleditor/schema/example3"
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
start = doc-element
doc-element = element doc {
para-element+
}
para-element = element para {
mixed {
[ a:defaultValue = "left" ]
attribute align { "left" | "center" | "right" }?
}
}Copy example3.css to directory addon/example3/.
@namespace url(http://www.xmlmind.com/xmleditor/schema/example3);
doc,
para {
display: block;
}
para {
margin: 1ex 0;
}
para[align] {
text-align: concatenate(attr(align));
}This style sheet would work fine without default namespace declaration at the top of it but rule matching is faster when @namespace is used.
Create a document template for RELAX NG schema "http://www.xmlmind.com/xmleditor/schema/example3" using a text editor. Save it as addon/example3/example3.xml.
<?xml version="1.0" encoding="UTF-8" ?> <doc xmlns="http://www.xmlmind.com/xmleditor/schema/example3"> <para></para> </doc>
Note that, unlike with DTDs and with W3C XML Schemas, there is no standard way to associate a RELAX NG schema to an instance[2].
Create a configuration file for XXE using XXE itself. Save it as addon/example3/example3.xxe.
<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration name="Example3"
xmlns="http://www.xmlmind.com/xmleditor/schema/configuration"
xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration">
<detect>
<rootElementNamespace
>http://www.xmlmind.com/xmleditor/schema/example3</rootElementNamespace>
</detect>
<relaxng compactSyntax="true" encoding="ISO-8859-1" location="example3.rnc"
name="http://www.xmlmind.com/xmleditor/schema/example3"/>
<css location="example3.css" name="Style sheet"/>
<template location="example3.xml" name="Template"/>
</configuration>The relaxng configuration element is essential because there is no standard way to associate a RELAX NG schema to an instance.
Restart XXE.
Now you can use | and select Example3 > Template to create a new document.
Do not forget to temporarily disable the Schema cache (using |, Schema tab, Enable cache toggle) if you intend to develop your own schema and test it using XXE.
Make sure that the template document is valid: the red icon must not be displayed at the bottom/left of XXE window.
If the template document, example3.xml, is invalid, please use a text editor and fix it because XXE is not designed to be comfortable to use with invalid documents.
[1] Example3.rng is also available in , in case you prefer the XML syntax to the compact syntax.XXE_install_dir/doc/configure/samples/example3/
[2] There is a non standard, proprietary, way to do that: the <?xxe-relaxng-schema location="..."?> processing instruction. However, its use should be restricted to testing and other quick and dirty experiments.