If you are writing a configuration file for XXE, please do not forget to temporarily disable the Quick Start and Schema caches by unchecking the corresponding checkboxes in → , Advanced|Cached Data section. More information about these caches in Section 5.11.1, “Cached data options” in XMLmind XML Editor - Online Help.
The W3C XML Schema example is similar to the DTD example.
Create a subdirectory named example2
in the addon/
subdirectory of XXE user preferences directory:
Copy example2.xsd
to directory addon/example2/
.
<?xml version='1.0' encoding='ISO-8859-1'?> <xs:schema elementFormDefault="qualified" targetNamespace="http://www.xmlmind.com/xmleditor/schema/example2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e2="http://www.xmlmind.com/xmleditor/schema/example2"> <xs:element name="doc"> <xs:complexType> <xs:sequence> <xs:element type="e2:Para" maxOccurs="unbounded" name="para" minOccurs="1"></xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="Para" mixed="true"> <xs:attribute default="left" name="align" type="e2:Align"></xs:attribute> </xs:complexType> <xs:simpleType name="Align"> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="left"></xs:enumeration> <xs:enumeration value="center"></xs:enumeration> <xs:enumeration value="right"></xs:enumeration> </xs:restriction> </xs:simpleType> </xs:schema>
Copy example2.css
to directory addon/example2/
.
@namespace url(http://www.xmlmind.com/xmleditor/schema/example2); 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 XML Schema "http://www.xmlmind.com/xmleditor/schema/example2
" using a text editor. Save it as addon/example2/example2.xml
.
<?xml version="1.0" encoding="UTF-8" ?> <doc xmlns="http://www.xmlmind.com/xmleditor/schema/example2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmlmind.com/xmleditor/schema/example2 http://www.xmlmind.com/public/schema/example2.xsd"> <para></para> </doc>
If you specify an xsi:schemaLocation
or an xsi:noNamespaceSchemaLocation
attribute, it is highly recommended to use a public, absolute, URL such as "http://www.xmlmind.com/public/schema/example2.xsd
" rather than relative URL "example2.xsd
".
Using a text editor, create a XML catalog where URL "http://www.xmlmind.com/public/schema/example2.xsd
" is associated to local file example2.xsd
. Save it as addon/example2/example2_catalog.xml
.
<?xml version="1.0" ?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public"> <uri name="http://www.xmlmind.com/public/schema/example2.xsd" uri="example2.xsd"/> </catalog>
This catalog will spare XXE the effort of downloading W3C XML Schema example2.xsd
from http://www.xmlmind.com/public/schema/example2.xsd
.
Create a configuration file for XXE. Save it as addon/example2/example2.xxe
.
<?xml version='1.0' encoding='ISO-8859-1'?> <configuration name="Example2" 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/example2</rootElementNamespace> </detect> <schema> <location>http://www.xmlmind.com/xmleditor/schema/example2 example2.xsd</location> </schema> <css name="Style sheet" location="example2.css" /> <template name="Template" location="example2.xml" /> </configuration>
If you create a configuration file with a text editor, do not forget to check its validity before deploying it because, for performance reasons, XXE does not thoroughly validate its configuration files at start-up time. The simplest way to do that is to open the configuration file in XXE.
Restart XXE.
Now you can use Example2/Template to create a new document.
→ and selectMake 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, example2.xml
, is invalid, please use a text editor and fix it because XXE is not designed to be comfortable to use with invalid documents.
About addon/example2/example2.xxe
:
detect: Simplest possible detection condition for a XML Schema based document: if a document opened by XXE has a root element in namespace "http://www.xmlmind.com/xmleditor/schema/example2
" then XXE will automatically use configuration addon/example2/example2.xxe
.
schema: this configuration element allows to avoid specifying xsi:schemaLocation
or xsi:noNamespaceSchemaLocation
attributes in your documents. With it, your document template could be:
<?xml version="1.0" encoding="UTF-8" ?> <doc xmlns="http://www.xmlmind.com/xmleditor/schema/example2"> <para></para> </doc>
which is simpler and cleaner.