530 likes | 789 Views
EEC4113 Data Communication & Multimedia System Chapter 10: Presentation Layer – Data Formatting by Muhazam Mustapha, November 2011 and contributions by class members, October 2010. Learning Outcome.
E N D
EEC4113Data Communication &Multimedia SystemChapter 10: Presentation Layer – Data Formattingby Muhazam Mustapha, November 2011and contributions by class members, October 2010
Learning Outcome • By the end of this chapter, students are expected to be able to understand formatting of data especially with XML standard
Chapter Content • ASN.1 Data Formatting • XML • XML Based Language • XML Based Data
Data Formatting • Presentation layer lies between application and session layer • Application layer deals with human readable data • Presentation layer is responsible to convert the data into more machine readable for lower layers CO1
Data Formatting Not only handling the conversion between application and the lower layers, presentation layer also needs to handle the different platforms exist at application layer e.g. MS Windows, Linux, Solaris, VAX Conversion of data among, and, from these platforms should comply to the standards in the lower layers CO1
Abstract Syntax Notation One Abstract Syntax Notation One (ASN.1) was the earliest work done on standardization of data format Only define the abstract syntax but does not restrict the way of doing encoding ASN.1 defines a general rule of formatting and a few specific rules CO1
ASN.1 General Rules Looks like C syntax Example: FooProtocol DEFINITIONS ::= BEGIN FooQuestion ::= SEQUENCE { trackingNumber INTEGER, question IA5String } FooAnswer ::= SEQUENCE { trackingNumber INTEGER, answer BOOLEAN } END Example of use: myQuestion FooQuestion ::= { trackingNumber 5, question "Anybody there?" } myAnswer FooAnswer ::= { trackingNumber 6, answer False } CO1
ASN.1 Specific Rules Basic Encoding Rules (BER) Canonical Encoding Rules (CER) Distinguished Encoding Rules (DER) XML Encoding Rules (XER) Packed Encoding Rules (PER) Generic String Encoding Rules (GSER) CO1
Basic Encoding Rules (BER) Has 2 subsets: CER, DER DER states data size, CER puts end of data marker DER Example (from previous slide): 30 -- tag indicating SEQUENCE 13 -- length in octets 02 -- tag indicating INTEGER 01 -- length in octets 05 -- value 16 -- tag indicating IA5String 0e -- length in octets 41 6e 79 62 6f 64 79 20 74 68 65 72 65 3f -- value ("Anybody there?" in ASCII) CO1
XML Encoding Rules (XER) Makes use of XML standard Example (from previous slide): <FooProtocol> <FooQuestion> <trackingNumber>5</trackingNumber> <question>Anybody there?</question> </FooQuestion> <FooAnswer> <trackingNumber>6</trackingNumber> <answer>False</answer> </FooAnswer> </FooProtocol> CO1
Packed Encoding Rules (PER) More packed (compressed) version of BER It is used if limiting values of data is known No. bits for data can be limited to cover just the range of value CO1
Generic String Encoding Rules Version of ASN.1 that uses human readable text format Used only in LDAP (Lightweight Directory Access Protocol) for publishing distributed computing services CO1
Impact of WWW ASN.1 remains as machine to machine data transfer standard Even though ASN.1 can be sent as XML (XER) but the two have no direct common predecessor – they more like hybrid ASN.1 is still not human readable enough But XML is, hence XML is more popular for the web CO1
Impact of WWW The plain text format of XML has both flavors – human and machine readability Human can easily read XML from its tags, attributes and values Machines have been equipped with an enormous no. APIs to handle XML the nature of XML makes it easy to write APIs for it CO1
SGML vs XML vs HTML SGMLStandard Generalized Markup Language Simplified,keep most useful features,applied to data transfer Simplified,loosen rules,applied to web layout definition Re-tighten rules,not forgiving,not popular XMLExtensible Markup Language HTMLHypertext Markup Language XHTMLExtensible Hypertext Markup Language XML-defined Language XML-formatted Data Mozilla’s XUL GIS’s GML Microsoft’s XAML Google’s KML MathML SVG . . . . . . CO1
Common Misconceptions XML and HTML are the same Not true – XML and HTML may just look the same XML tags are user defined HTML tags are fixed standard XML is just another kind of web page Not true – HTML is for web, XML is for data transfer CO1
XML Structure XML consists of tags bounded data There will be pairs of tags: Opening tags: <tagname> Closing tags: </tagname> Values (content) of XML elements are denoted by a pair of opening and closing tags: <distance>50</distance> CO1
XML Structure Some tags are defined not to have value: <empty /> Tags can have attributes to tell some properties of the content: <distance unit="km" >50</distance> attribute unit tells that the value of distance is in “km” CO1
XML Structure Data in XML file are arranged hierarchically – nested <car> <brand>Proton</brand> <model>Waja</model> <spec> <capacity unit="cc">1200</capacity> <door>4</door> </spec> </car> CO1
Support Document XML file needs a separate file to define the tags’ values and attribute The link to the support file is given some where at the top of the XML file Two most popular ways to define XML tags: DTD (Document Type Definition) XSD (XML Schema Document) CO1
Support Document DTD example: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE people_list SYSTEM "example.dtd"> <people_list> <person> <name>Fred Bloggs</name> <birthdate>2008-11-27</birthdate> <gender>Male</gender> </person> </people_list> example.dtd: <!ELEMENT people_list (person)*> <!ELEMENT person (name, birthdate?, gender?, socialsecuritynumber?)> <!ELEMENT name (#PCDATA)> <!ELEMENT birthdate (#PCDATA)> <!ELEMENT gender (#PCDATA)> <!ELEMENT socialsecuritynumber (#PCDATA)> CO1
Support Document XSD example: <?xml version="1.0"?> <p xsi:noNamespaceSchemaLocation="example.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> Hello world! </p> example.xsd: <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="p" type="xsd:string"/> </xsd:schema> CO1
XML Defined Language There are hundreds of languages defined using XML along side with its own XSD The language defines its own set of tags Normally the languages can work with JavaScript Examples: Scalable Vector Graphics (SVG) XUL (XML User Interface Language) XAML (Extensible Application Markup Language) CO1
SVG Vector graphic image for web pages Defines resolution free drawing objects Created by Adobe Besides vector graphics, it also provides support for: Embedded raster image Text Printing Gradients Filter More details in PBL CO1
XUL XUL or XML user interface markup language is an upgrade version of XML It was develop by the Mozilla project – intended to develop a way to design a desktop application with web programming technology XUL Slides contributed by: MUHAMMAD AZIZOL BIN AMINUDDIN,MOHAMAD JAMAL BIN KAMARUDIN CO1
XUL History: CO1
XUL XUL is not a programming language but a markup language Any programming feature required, can be included as JavaScript Can be viewed on Mozilla Gecko layout engine such as FireFox and Flock Can be standalone application XUL is part of (Cross Platform Front End) XPFE family CO1
XUL Example: <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="hello_world" title="Hello World Example by Jamal and Azizol" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <box> <button id="Hello World!" label="Hello World!"/> </box> </window> CO1
XAML XAML stands for eXtensible Application Markup Language It function as HTML for Windows applications, but it is really quite a bit more expressive and powerful XAML is used extensively in .NET Framework 3.0 & .NET Framework 4.0 technologies, particularly Windows Presentation Foundation(WPF), Silverlight, and Windows Workflow Foundation(WF). XAML Slides contributed by: MUHAMAD SAFWAN BIN ZAMRI,KRITHARAN A/L SUPRNIOM CO1
XAML A XAML file can be compiled into a .baml (Binary XAML) file, which may be inserted as a resource into a .NET Framework assembly. When used in Windows Presentation Foundation, XAML is used to describe visual user interface CO1
XAML WPF allows for the definition of both 2D and 3D objects, rotations, animations, and a variety of other effects and features. XAML can’t be embedded in HTML. CO1
XAML Silverlight Example: Silverlight project CO1
XAML The given default Page.xaml code (added 1 line of code): <Canvas x:Name="parentCanvas" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Page_Loaded" x:Class="SilverlightProject1.Page;assembly= ClientBin/SilverlightProject1.dll" Width="640" Height="480" Background="White"> <TextBlock Text="Hello World" FontSize="50"/> </Canvas> Added line CO1
XAML Output: CO1
XML Formatted Data The data is defined by a set of XML tags and XSD The limit and type of data depends on application and vendor Example: MathML GML (Geography Markup Language) KML (Google Map’s Keyhole Markup Language) CO1
MathML Option for writing complex mathematical expression on web pages Defines mathematical expression as structures Proposed by W3C More details in PBL CO1
GML Geography Markup Language A modeling language and an encoding for geographic information Designed for the web and web-based services An XML encoding for the transport Storage of geographic information, including the geometry and the properties of geographic features between distributed systems. GML Slides contributed by: NORZHAFRE HAZWAN BIN ZAINUDIN,EMMA EMELIA BINTI BARHATH ALI CO1
GML Based on XML technologies (W3C) Implements concepts of the ISO 19100 series Supports spatial and non-spatial properties of objects Open and vendor-neutral and extensible Supports the definition of profiles (proper subsets) of the full GML capabilities CO1
GML • Modeling feature types Road name I95 class Interstate centerLine gml:Curve maintainer DOT xyz Building an information community reaching consensus about the vocabulary (feature types and their properties) CO1
GML Geospatial Web Information Communities publish their Application Schemas (preferably in some sort of registry) so that it can be found, accessed and understood by others This enables that also the features can have properties whose values are maintained by other authorities a web of geospatial features is created Roads Parcels Traffic Messages Administrative Boundaries Buildings CO1
GML Examples: Slide from Galdos Inc. SVG Views GML Data y-plane Solid Model in VRML z-plane x-plane CO1
GML • Example (test.gml): <?xml version="1.0" encoding="UTF-8"?> <gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml"> <gml:featureMember> <LAYER> <attrib1>attrib1_value</attrib1> <attrib2container> <attrib2>attrib2_value</attrib2> </attrib2container> <location1container> <location1> <gml:Point> <gml:coordinates>3,50</gml:coordinates> </gml:Point> </location1> </location1container> <location2> <gml:Point> <gml:coordinates>2,49</gml:coordinates> </gml:Point> </location2> </LAYER> </gml:featureMember> </gml:FeatureCollection> CO1
GML • Associated .gfs: <GMLFeatureClassList> <GMLFeatureClass> <Name>LAYER</Name> <ElementPath>LAYER</ElementPath> <GeometryElementPath>location1container|location1</GeometryElementPath> <PropertyDefn> <Name>attrib1</Name> <ElementPath>attrib1</ElementPath> <Type>String</Type> <Width>13</Width> </PropertyDefn> <PropertyDefn> <Name>attrib2</Name> <ElementPath>attrib2container|attrib2</ElementPath> <Type>String</Type> <Width>13</Width> </PropertyDefn> </GMLFeatureClass> </GMLFeatureClassList> CO1
GML • The output of ogrinfo test.gml -ro -al is Layer name: LAYER Geometry: Unknown (any) Feature Count: 1 Extent: (3.000000, 50.000000) - (3.000000, 50.000000) Layer SRS WKT: (unknown) Geometry Column = location1container|location1 attrib1: String (13.0) attrib2: String (13.0) OGRFeature(LAYER):0 attrib1 (String) = attrib1_value attrib2 (String) = attrib2_value POINT (3 50) CO1
KML Keyhole Markup Language Keyhole Markup Language (KML) is an XML-based language schema for expressing geographic annotation and visualization on Internet-based, two-dimensional maps and three-dimensional Earth browsers KML was developed for use with Google Earth, which was originally named Keyhole Earth Viewer KML Slides contributed by: TUAN MOHD KHAIRI BIN TUAN MAT,NIK MOHAMAD RUKMAL HAKIM BIN ROKMAN CO1
KML It was created by Keyhole, Inc, which was acquired by Google in 2004 The name "Keyhole" is an homage to the KH reconnaissance satellites, the original eye-in-the-sky military reconnaissance system first launched in 1976 KML is an international standard of the Open Geospatial Consortium Google Earth was the first program able to view and graphically edit KML files CO1