XML (Extensible Markup Language) is a set of rules to define semantic labels that organize a document in different parts. XML is a meta-language that defines the syntax to define other structured label languages.
We will explain the XML format to be followed to convert data file correctly:
The first line must follow the next structure:
<? Xml version = "1.0" encoding = "UTF-8" standalone = "yes">
You can have several attributes, some mandatory and others are not:
version: indicates XML version used in the document. This field is compulsory.
encoding: indicates the way that has been encoded document. The default option is UTF-8, but could be others, as UTF-16, US-ASCII, ISO-8859-1, etc. This field is not obligatory.
standalone: specifies whether further documents, such as a DTD, are required to process the document. The default value is "no".
XML documents must follow a hierarchical structure by means of labels. XML elements can contain other elements. Elements may also have attributes, these are always expressed as name-value pairs in the element's open tag.
A well-formed document must conform to the following rules:
Element names are case sensitive, that is, the following is a well-formed matching pair: <step>…<step>, whereas this is not <step>…</step>.
Non-empty elements are delimited by both a start-tag and an end-tag.
Attribute values must always be quoted, using single or double quotes, and each attribute name should appear only once in any element.
All spaces and carriage returns are taken into account in the elements.
The element names must not begin with the letters “xml”.
The element names should not use character ":".
Although it is permissible to use the characters "." And "-" in element names, it is not recommended because the application processing XML file may interpret these signs as operators. Therefore these characters will be replaced in our tool
by the character "_”.It should not be used characters "\" in the names of elements.
The names may contain any alphanumeric character, but they can not start with a numerical or punctuation character.
Special characters can be represented either
using entity references, or by means of numeric character references. An
example of a numeric character reference is "€
",
which refers to the Euro symbol by means of its Unicode codepoint in
hexadecimal.
An entity reference is a placeholder that represents that entity. It consists of the entity's name preceded by an ampersand ("&") and followed by a semicolon (";"). XML has five predeclared entities:
& (ampersand) is &
< (less than) is <
> (greater than) is >
' (apostrophe) is '
" (quotation mark) is "
Comments can be placed anywhere in the tree, including in the text if the content of the element is text. XML comments start with <!- and end with ->.
<!- This a comment ->
XML requires that elements be properly nested, that is, elements may never overlap. For example, the code below is not well-formed XML, because the <em> and <strong> elements overlap:
<!- WRONG! NOT WELL-FORMED XML !->
<p>Normal<em>emphasized<strong>strong emphasized</em>strong</strong></p>
All XML documents must contain a single tag pair to define the root element. All other elements must be nested within the root element. All elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element.
The label <root> indicates the begin of the data. This label can have any name. If all the children of <root> do not have the same name on the label <row>, the user must enter the name of this tag, otherwise it is assumed that all children have the same value.
Each label <row> is parent of as labels as attributes exist. The name on the label of each of these children will be the attribute name, and the value of the label is the data value of the attribute.
There are as labels <row> as rows of data.
One XML format valid to Keel is the following:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<row1>
<attribute-name-1> attribute-value-11
</attribute-name-1>
<attribute-name-2> attribute-value-12
</attribute-name-2>
<attribute-name-N> attribute-value-1N
</attribute-name-N>
</row1>
<attribute-name-1> attribute-value-M1
</attribute-name-1>
<attribute-name-2> attribute-value-M2
</attribute-name-2>
<attribute-name-N> attribute-value-MN
</attribute-name-N>
</rowM>
</root>
|
Another XML format valid to Keel is the following:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<row1>
<field
name="attribute-name-1">attribute-value-11 </field>
<field
name="attribute-name-2">attribute-value-12 </field>
<field
name="attribute-name-N">attribute-value-1N </field>
</row1>
<field
name="attribute-name-1">attribute-value-M1 </field>
<field
name="attribute-name-2">attribute-value-M2 </field>
<field
name="attribute-name-N">attribute-value-MN </field>
</rowM>
</root>
|
One
example of a valid XML file is the following:
In this example there are:
<?xml version="1.0" encoding="UTF-8"?>
<customer>
<id>5</id>
<course>66</course>
<name>My book</name>
<summary>Book summary</summary>
<numbering>2</numbering>
<disableprinting>0</disableprinting>
<customtitles>1</customtitles>
<timecreated>1114095924</timecreated>
<timemodified>1114097355</timemodified>
</customer>
<customer>
<id>6</id>
<course>207</course>
<name>My book</name>
<summary>A test summary</summary>
<numbering>1</numbering>
<disableprinting>0</disableprinting>
<customtitles>0</customtitles>
<timecreated>1114095966</timecreated>
<timemodified>1114095966</timemodified>
</customer>
</root> |
The following example has another xml structure, but the same data than the previous example. You can see that there are 9 attributes and 2 instances of this.
<?xml version="1.0" encoding="UTF-8"?>
<row>
<field
name="id">5</field>
<field
name="course">66</field>
<field name="name">My
book</field>
<field
name="summary">Book summary</field>
<field
name="numbering">2</field>
<field
name="disableprinting">0</field>
<field
name="customtitles">1</field>
<field
name="timecreated">1114095924</field>
<field
name="timemodified">1114097355</field>
</row>
<row>
<field
name="id">6</field>
<field
name="course">207</field>
<field name="name">My
book</field>
<field
name="summary">A test summary</field>
<field
name="numbering">1</field>
<field
name="disableprinting">0</field>
<field
name="customtitles">0</field>
<field
name="timecreated">1114095966</field>
<field
name="timemodified">1114095966</field>
</row> </root> |