Showing posts with label needs_work. Show all posts
Showing posts with label needs_work. Show all posts

Friday, 25 November 2011

Data modelling with XML


Needs work:
Expand example ( w. code ), ID-REFS, XLink
http://www.ibm.com/developerworks/xml/library/x-xdm2m.html

Logical data modeling usually occurs largely at a high level, outside the constraints of particular technologies, such as XML or SQL. However, since the resulting data model will ultimately be implemented in one ( or more ) of the available technologies, the logical data model might be adjusted for the particular computing system on which the physical data model is to be implemented – in this case, XML.

A logical data model consists of three main components: entities, attributes, and relationships (http://web.archive.org/web/20080509063521/http://www.dbmsmag.com/9506d16.html ). XML provides a robust platform for implementing entities and attributes, but relationships can be more difficult to express ( http://www.tdan.com/view-articles/5538 ).

The hierarchical structure of XML can be used to convey basic relationships, such as one-to-one and one-to-many; for example, a document called ‘Module’ can contain one or more ‘Tutor’ elements. This can be thought of as expressing either an one-to-one relationship ( if the module only has one tutor ), or as one-to-many, if the module contains multiple ‘Tutor’ elements.

Thursday, 24 November 2011

Encodings in XML

The character set used throughout an XML document can be declared as part of the first line of the document, inside the xml declaration:

1 <?xml version="1.0"? encoding="UTF-8"?>

If no encoding is declared, parsers will generally try to guess which encoding is used, first by looking at the first bytes of the file. If characters outside the assumed encoding are detected, the parser will try to find an alternative encoding that will contain it. If the characters are not recognized, the parser should stop processing (http://www.w3.org/TR/REC-xml/#charencoding ).

XML encodings can be divided into three categories, the most common encodings being Unicode/ISO/IEC10646 encodings and transformations: "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4". UTF-8 is the most used encoding (http://w3techs.com/technologies/overview/character_encoding/all ), accounting for 67% of websites which use a known character encoding.

The main advantage of UTF-8 is that it can encode any Unicode character, and any valid ASCII text file is also a valid UTF-8 document. This is due to the fact that UTF-8 characters do not have a fixed width ( in bytes ), but can occupy from one to six bytes; and since it was designed with backwards-compatibility with ASCII, the first 127 characters are the same for ASCII and UTF-8.

Among disadvantages, the major drawback of UTF-8 is that for certain languages, it will take up more space. Taking Romanian as an example – the word “ampulă” cannot be represented with ASCII because of the “ă” character ( http://www.fileformat.info/info/unicode/char/103/index.htm ); however, the ISO/IEC 8859-16, informally known as Latin-10” or “South-Eastern European” encoding defines the character I need as 0xE3, so I would use this encoding for my document. ISO-8859-16 is a single-byte encoding, so it is very efficient and suited for situations when I don’t need other non-ASCII characters.

However, to represent ă” using UTF-8, two bytes are needed: 0xC4 and 0x83, because it is decomposed into 'LATIN SMALL LETTER A' ( 0xC4 ) and 'COMBINING BREVE' ( 0x83 ), hence occupying double the amount of space. Therefore, if space were a concern, I would use the ISO-8859-16 encoding for Romanian texts.

However, it is unpractical to represent Chinese characters with any encodings which don’t support many characters. Single-byte encodings work for Romanian and other languages with a small number of characters, but not for languages which use ideograms, such as Chinese or Japanese. In this situation, UTF-8 becomes the better option.

Saturday, 12 November 2011

What is XML well-formedness and how could you measure it?


If an XML document is well-formed, it conforms to the syntax rules, as defined in the XML standard. Unlike HTML, the XML standard is very strict, and does not tolerate errors such as the omission of a closing tag, or having different cases in the opening and closing tags; for example, the following is not a well-formed XML document:

1 <?xml version="1.0"?>
2 <person>
3     <name>John Smith</Name>
4 </person>

Although the “name” tag was closed, the closing tag tag should have the same casing as the opening tag, therefore this document is not a well-formed XML file. The line should be: <name>John Smith</name> to form a well-formed XML document.

Well-formedness also implies correct nesting; for example, the following code is not well-formed because the <surname> tag was opened before the <name> tag was closed, therefore the two tags overlap – which is not allowed in XML.
Wrong: 
<name>John<surname>Smith</name></surname>

Correct:
<name>John</name><surname>Smith</surname>

Another way in which documents can fail the well-formedness test is by not having a single root tag; in other words, all of the tags inside the document must reside inside a unique pair of opening and closing tags. But it doesn’t have to be the xml tag; it could be any tag ( with a valid name, of course ).

Well-formedness can be checked with special tools – for example, the w3scools validator (http://www.w3schools.com/xml/xml_validator.asp); but due to the strictness of the XML standard, the parser should abort at the first encountered error. Therefore, the number of errors is rarely important; what matters is whether the whole document is valid.

Thursday, 3 November 2011

Task 2, part 1

Needs work: what does the X mean ?

1.       1)    What is the “X” in XML and what is its significance? Select one response and write the letter
here [ b ]
a) Extended
b) Extensible
c) Extreme
d) Extendable
The “X” is significant because
XML was designed to be extensible, which allows it to be used for a variety of applications. Many such XML-based formats have been defined, such as XML-RPC, SVG, XHTML, RSS – this proves XML’s usefulness, and would not be possible if not for XML being extensible.

1.       2)    What is a markup language? Select one response and write the letter
here [  c ]
a.       A system of symbols to support the transmission of Morse code.
b.       A system to display website standards to which a website conforms,
c.        A system of embedded codes to make an electronic document
                display on a web page as required
a.       A system to only prepare documents for publication

What is a mark-up language and how is it used?
A mark-up language is used to give a special meaning to portions of text – this is accomplished by marking up the text with special tags, which have a meaning that is determined by the particular format of the XML file. Each type of XML file can have it’s own tags, which are meaningless to other applications, or can have a different meaning.

1.       3)    What does SGML stand for? Select one response and write the letter
here [ a ]
a.                               Standard Generalized Markup Language
b.                               Structured Generalized Markup Language
c.                                School of Global Management and Learning
d.                               Simplified Generic Machine Language

What is the significance of SGML ?

SGML is important because most of the technologies that make the internet possible are based on it – such as (X)HTML and XML. The reason these languages were derived from SGML is that, due to it’s complexity, a parser for SGML is complex to write; therefore, subsets of SGML were chosen for particular applications.  


1.       4)    What is the relationship between SGML and XML? Select one response and write the letter here [ c ]
a.       SGML is based on XML
b.       SGML and XML are the basis for HTML
c.        SGML is a slimmed-down, streamlined version of XML
d.       XML is a slimmed-down, streamlined version of SGML

Describe and explain the relationship between SGML and XML

XML is based on SGML, but only has a subset of it’s features. The creators of XML acknowledged the value of SGML, but felt is too ‘heavy’ for many purposes. Therefore, XML was developed – a light markup language, that can be extended to accommodate numerous applications.


1.       5)    What is the relationship between SGML and HTML? Select one response and write the letter
here [  a  ]
a.       HTML is a mark-up language derived from SGML
b.       SGML is a mark-up language derived from HTML
c.        Both are derived from XML
d.       Both are derived from AJAX

Give further  explanation  of the relationship between SGML and XML

HTML was derived from SGML, but most HTML documents do not validate as SGML documents. Since it was introduced, HTML accumulated many features that would not be practical to exclude for backward-compatibility purposes, which prevented HTML from being an SGML application – until HTML 4.0 – which fully conforms to the SGML standard.