RebXML

Updated: 21-Jun-2007
John Niclasen, NicomSoft
Email: docs at niclasen dot name

Contents:

1. Introduction
2. Document
2.1 Element
2.2 Attribute
2.3 Empty Element
2.4 Content
3. Examples

1. Introduction

RebXML is a REBOL representation of an XML document. The idea behind XML is very good with an interchange format, that is strictly build on the hierarchical datamodel.

Definitions:

 XML 1.0http://www.w3.org/TR/2004/REC-xml-20040204/
 XMLDecl<?xml version="1.0" encoding="ISO-8859-1"?>

The XMLDecl (XML declaration) will be found in first line of XML files.

Notice!

I've put space around start- and end-block brackets to make the text more readable. Of course the normal block-rules apply.

2. Document

A RebXML document consist of an element within a block (type block!).

[ Element ]

2.1 Element

An element can either be an empty element or have some content. Elements have a name and any number of attributes. The elements name is a word (of type word! - or of type url!, so namespace tags like <ns:tag> can be made).

Name any Attribute Content

2.2 Attribute

An attribute has a name (of type word! - or of type url! like element names) and a value (of type string!).

AttName string!

2.3 Empty Element

An empty element has a name (of type word! - or of type url!, so namespace tags like <ns:tag /> can be made), any number of attributes, and is followed by a slash (a /).

Name any Attributes /

2.4 Content

Content can either be a string (type string!) or a block (type block!). If it's a block, it can consist of an optional string (type string!) followed by any number of elements and an optional string (type string!).

"A string with some content"

[ opt string! any [ Element opt string! ] ]

3. Examples

The shortest RebXML document:

[ empty / ]

It consist of one empty element with the name: empty
The XML version looks like this:

<empty />

Other RebXML examples and their XML versions:

RebXML: [ element1 / ]
XML : <element1 />

RebXML: [ element1 "" ]
XML : <element1></element1>

RebXML: [ element1 [ ] ]
XML : <element1></element1>

RebXML: [ element1 "value" ]
XML : <element1>value</element1>

RebXML: [ element1 [ "value" ] ]
XML : <element1>value</element1>

RebXML: [ element1 att1 "a1" / ]
XML : <element1 att1="a1" />

RebXML: [ element1 att1 "a1" "value" ]
XML : <element1 att1="a1">value</element1>

RebXML: [ element1 att1 "a1" [ "value" ] ]
XML : <element1 att1="a1">value</element1>

RebXML: [ element1 att1 "a1" [ element2 "value" ] ]
XML : <element1 att1="a1"><element2>value</element2></element1>

RebXML: [ element1 att1 "a1" [ "value1" element2 "value2" ] ]
XML : <element1 att1="a1">value1<element2>value2</element2></element1>

RebXML: [ element1 att1 "a1" [ "value1" element2 "value2" "value3" ] ]
XML : <element1 att1="a1">value1<element2>value2</element2>value3</element1>

RebXML: [ element1 att1 "a1" att2 "a2" "value" ]
XML : <element1 att1="a1" att2="a2">value</element1>

And so on can elements, attributes and content be combined in many ways.


NicomDoc - 21-Jun-2007