Skip to content

Rhaptos Software Development

Personal tools
You are here: Home » Downloads » XML Editing » Etna XML Editor » RelaxNG pattern extensions

RelaxNG pattern extensions

Document Actions
This document describes all pattern extensions you can use in a RelaxNG schema for Etna.

Abstract

Relax NG format doesn't provide all specifications that a graphic xml editor needs. So we have to add some specific attributes or elements to enhanced the Relax NG format. This document describe all this extensions.

Namespace

The extensions described in this document have their own namespace : http://disruptive-innovations.com/ns/editor-rng-extension/1.0

The alias used in this document for this namespace is di.

Extensions

<di:blank>

Etna can generate automatically an element and its children, in order to generate valid content. But sometimes, the result is not always that we wish (because Etna cannot guess what you want when the schema specify many choice).

This extension is used to set an initial content to an element when it is created. You should use this as a child of an <element> pattern or a <grammar> pattern.

You can add several <di:blank> element. In this case, you should set a name attribute with a different value for each <di:blank> element. Then the editor can suggest this differents "blank" contents when the user wants to create a new element.

The <di:blank> element which have an empty name or no name attribute specify the default "blank" content.

Attributes
name A short name for the initial content (as an id)

Example

<element name=”ul” ns="http://www.w3.org/1999/xhtml">

   <di:blank xmlns:xhtml=”http://www.w3.org/1999/xhtml”>
       <xhtml:ul>
         <xhtml:li></xhtml:li>
       </xhtml:ul>
    </di:blank>

   <di:blank name=”foolist”>
       <ul xmlns=”http://www.w3.org/1999/xhtml”>
         <li>foo</li>
         <li>bar</li>
         <li>car</li>
       </ul>
    </di:blank>
   ...
</element>

<di:blank> could have a <di:label> and a <di:description> element as child.

<di:blank> must have only one child element (other than a <di:blank> or <di:description> element) which should be an element described by the <element> pattern. This child can have several children and it must have the right namespace.

di:defaultValue

This attribute is used on an <attribute> pattern, to set a default value for the attribute, when it is created. Of course, the given value should be valid compared with the schema of the <attribute> pattern.

Example:

<attribute name=”foo” di:defaultValue=”bar”>
   ...
</attribute>

<di:description>

You can use this element to assign a description to a schema, an element, an attribute or a blank content. So you should use this as a child of a <grammar>, <element> or <attribute> pattern, or as a child of <di:blank> element.

This description is displayed by Etna when the user wants some more informations about an element, a document etc..

You have two choice to specify the value :

  • by giving a key of a localized string. This localized string should be store inside a file of properties. The name of this file is indicated by the <di:localizationProperties/> extension.
  • by giving a simple value inside the <di:description> element.
Attributes
key The key of the localized string

Example:

<element name=”ul”>
   <di:description>You can use this element to 
add a list of items</di:description>
   ...
</element>

or

<element name=”ul”>
   <di:description key=”ul.description” />
   ...
</element>

<di:editorstylesheet />

This element indicates a stylesheet for the editor. This can be only a child of a <grammar> pattern.

Attributes
href The URI of the stylesheet. Could be relative to the URI of the schema file.

Example:

<grammar>
  <di:editorStyleSheet href=”mystylesheet.css” />
</grammar>

<di:externalDoctype />

This element indicates a doctype to insert into a new document. This can be only a child of a <grammar> pattern.

Attributes
Name The name of the doctype
publicId The value of the publicID content in a doctype
systemId The value of the systemID content in a doctype

Example:

<grammar>
  <di:externalDoctype name=”html” 
     publicId=”-//W3C//DTD XHTML 1.0 Strict//EN”
     systemId=”http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”
    />
  <start>
    <element name=”html”> ...</element>
  </start>
</grammar>

It will generate:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  ...

</html>

<di:label>

You can use this element to assign a label to a schema, an element, an attribute or a blank content. So you should use this as a child of a <grammar>, <element> or <attribute> pattern, or as a child of <di:blank> element.

Etna will display this label instead of the element name, the document name etc.

You have two choice to specify the value :

  • by giving a key of a localized string. This localized string should be store inside a file of properties. The name of this file is indicated by the localizationProperties extension.
  • by giving a simple value inside the <di:label> element.
Attributes
key The key of the localized string

Example:

<element name=”p”>
   <di:label>paragraph</di:label>
   <text />
</element>

or

<element name=”p”>
   <di:label key=”p.label” />
   <text />
</element>

<di:localizationProperties>

This element specify the file of properties to use to get the key value of label and description extension.

Attributes
href The URI of the file. Could be relative to the URI of the schema file.

The URI could contain the pattern : %%LANG%%. This pattern should be replaced by the RelaxNG parser with the current lang.

Example:

<di:localizationProperties href=”myfile.%%LANG%%.properties” />

If the schema is provided by a XUL extension, you don't have to use the %%LANG%%. Use a chrome URI instead : chrome://myextension/locale/my.properties

A property file contains some formatted lines like this : key=localized string. For example:

p.label=paragraph
ul.description=this element is used to include a list of item.

<di:processingInstruction/>

With this element, the validator will create a processing instruction inside a new document or other blank content. You can use this as a child of a <grammar> pattern or inside a <di:blank> element.

Attributes
target The name of the processing instruction
data The content of the processing instruction

Example:

<grammar>
  <di:processingInstruction target=”xml-stylesheet”
       data=”href=&quot;my_stylesheet.css&quot;” />
</grammar>

It will generate :

<?xml-stylesheet href=”my_stylesheet.css”?>
Created by ljouanneau
Last modified 2005-12-19 11:24