Translation

The oldest posts, are written in Italian. If you are interested and you want read the post in English, please use Google Translator. You can find it on the right side. If the translation is wrong, please email me: I'll try to translate for you.

martedì, agosto 22, 2017

Using XML 01: Introduction, Part 1/3

I don't know very much about XML. Anyway, there are some cases where as DBA, I have to use it. For example, if I want to read the HIGH_VALUE and other LONG columns or if I want to read the hints used by a SQL profile. So, with the following series, I would like to understand better how to use XML. Which I write here is just a minimum of knowledge on XML. I do not pretend to explain to you how to use XML in all its form.

What you read, in this first part is a collection of information taken from several links. You can find them in the References section.

Introduction to XML

Extensible Markup Language (XML) is a simple, very flexible text format derived from SGML (ISO 8879).

XML code is similar to Hypertext Markup Language (HTML). Both XML and HTML contain markup symbols to describe page or file contents. HTML code describes Web page content (mainly text and graphic images) only in terms of how it is to be displayed and interacted with.

Also, while HTML is not case-sensitive, XML it is.

The basic building block of an XML document is an element, defined by tags. An element has a beginning and an ending tag. All elements in an XML document are contained in an outermost element known as the root element. XML can also support nested elements or elements within elements. This ability allows XML to support hierarchical structures. Element names describe the content of the element, and the structure describes the relationship between the elements.

XML is much more accurate than HTML when it comes to closing tags: each one always has a closure.

Tags can also be defined as empty tags but their syntax is <TAG/>

Elements can be better characterized by specifying a list of attributes.

So we have a "start-tag" (STag), an "end-tag" (ETag) and a "tags for for Empty Elements" (EmptyElemTag). We can define them as

STag ::= <Name (Attribute)>
ETag ::= </Name>
EmptyElemTag ::= <Name (Attribute)/>

(As DBA, common queries do not use the EmptyElemTag, but I report it because it is a simple concept and it shows the difference against HTML).

There is always a prologue and is very important: it contains useful guidelines for programs that will use the document. Specifically, the XML document begins with '<' ?xml version=“1.0”? '>'

XML example:

The text: "Rex Stout was an American author of many yellow novels featuring famous Nero Wolfe and his aide and storyteller Archie Goodwin."

become

<?xml version=“1.0”?><author nationality="US" ><name>Rex</name> <surname>Stout</surname> </author> was an American author of many<genere> yellow novels </genere>featuring famous <protagonist><name>Nero</name> <surname>Wolfe&</surname></ protagonist> and his aide and storyteller <storyteller> <protagonist><name>Archie</name> <surname>Goodwin</surname></protagonist></storyteller>.

Graphic view of an XML tree

How to decide whether to represent an entity component as an attribute or as a separate entity? In general, it is difficult or even impossible to make an objective choice, as there is no clear advantage in either solution. In these cases, the programmer is free to use the form he or she prefers.


References

[1] https://www.w3.org/XML/
[2] https://www.w3.org/TR/REC-xml/
[3] http://searchmicroservices.techtarget.com/definition/XML-Extensible-Markup-Language
[4] http://www.diit.unict.it/users/alongheu/tpa/aa0910/tpa_lezione14_XML.pdf (ITA)
[5] https://www.youtube.com/watch?v=yKHQQXKdfOM
[6] http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/

Nessun commento: