Sunday, April 6, 2014

70-461 Training Kit Chapter 7, Lesson 1: XML Basics Part II

More XML terminologies.

Element-centric presentation
         Data is stored between start tag and end tag of XML elements.
         Recommendation to store data.
Example:
<Customers>
    <Customer>
 <custid>1</custid>
 <contactname>Allen, Michael</contactname>
    </Customer>
    <Customer>
 <custid>2</custid>
 <contactname>Hassall, Mark</contactname>
    </Customer>
</Customers>

Attribute-centric presentation
         Data is stored inside of element tags.
         Recommendation to store metadata
Example:
<Customers>
    <Customer custid="1" contactname="Allen, Michael" />
    <Customer custid="2" contactname="Hassall, Mark" />
</Customers>

Mixed presentation
XML documents can contain both element-centric and attribute-centric presentation.
Example:
<Customers>
    <Customer>
 <custid>1</custid>
 <contactname>Allen, Michael</contactname>
    </Customer>
    <Customer custid="2" contactname="Hassall, Mark" />
<Customers>

Prolog
Denoting the XML version & encoding
Must be the first line of the XML document
Example: 
<?xml version="1.0" encoding="ISO-8859-15"?>

Namespaces
Declared in the root element
Can have alias
Example:
<Employees xmlns:emp="EmployeesCompanyA">
<emp:Employee>
<emp:employeeid>1</emp:employeeid>
</emp:Employee>
</Employees>

Special characters
<, >, &, ", '
Use & as escape character and end with a semicolon.
Example: $lt; is equivalent to <
Another option: use XML CDATA section as <![CDATA[…]]>
The characters in the … is treated as literal character
Example:
<Product><![CDATA[<<&>" ']]></Product>

Comment
          Syntax: <!-- this is a comment -->
 Example:
<Customers>
    <!-- this is a comment -->
    <Customer custid="1" contactname="Allen, Michael" />
    <Customer custid="2" contactname="Hassall, Mark" />
</Customers>

Processing Instructions
         Syntax:  <?instruction?>
Instruction for application that process the XML document. 
Example:
<?xml-stylesheet type="text/xsl" href="/style1.xsl"?>

XSD (XML Schema Description) Document
Describe the metadata of other XML documents
Can specify: constraints, data type, element names, # of occurrence for elements.
Schema of XSD document is predefined

Typed XML document
When have a predefined schema (from XSD document)

XML Document Validation
A process of checking if the XML document is complied with a schema (in XSD document)


Reference: 
70-461 Training Kit

No comments:

Post a Comment