Title: XML: Technology and Application Lecture 1: Introduction
1XML Technology and ApplicationLecture 1
Introduction
- Jay A. Crossler, Instructor
- Johns Hopkins University
2INTRO to XML
- Unicode Angle Brackets Interoperability
3XML
- eXtensible Markup Language (XML) is a simple,
standard way to describe text data - Described as ASCII of the web
- XML - a W3C standard, lets you create your own
tags - Tags name the concept you are describing
4Advantages
- More semantics to the data human machine
readable - More structures Standard/configurable
data-types - Move to the web Plain text files,
self-referential - Easy to exchange data with others Web Services
- Platform independent - (relatively) Easy to parse
- Unicode Support AT038T
5Example
2HGEJ6675YH519046
Honda 2000
Civic
Kate Winslet 48
My St, Atown, CA
01 18147890
05-11-1974
6HTML vs XML
- HTML tags describe rendering, XML tags describe
data - HTML can at most do browser specific presentation
- In HTML Information extraction is not easy
- XML is written for information exchange
7Well-formed Documents
- Tags are nested correctly
- Only one root node
- Well-formed document example
- 1
- 2
-
-
- Not well-formed document example
- 12
8XML Syntax
- Elements
- XML tags for markup
- Attributes
- Tuple information of elements
- Declarations
- Instructions to XML processor
- Processing Instructions
- Instructions to external applications
9A Piece of XML
-
- SWISS-PROT
- P09651
-
- SKSESPKEPEQLRKLFIGGLSFETTDE
SLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNARPHK
VDGRVVEPKRAVSREDSQRPGAHLTVKKIFVGGIKEDTEEHHLRDYFEQY
GKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQKYHTVNGHNCEVR
KALSKQEMASASSSQRGRSGSGNFGGGRGGGFGGNDNFGRGGNFSGRGGF
GGSRGGGGYGGSGDGYNGFGNDGGYGGGGPGYSGGSRGYGSGGQGYGNQG
SGYGGSGSYDSYNNGGGRGFGGGSGSNFGGGGSYNDFGNYNNQSSNFGPM
KGGNFGGRSSGPYGGGGQYFAKPRNQGGYGGSSSSSSYGSGRRF -
10INTRO to JAVA and Programming
11Java
- Object-oriented programming language.
- Inheritance, overloading and overriding, dynamic
binding. - Interfaces, reflection.
- Platform independent.
- Interpreted.
- Lots of APIs.
- Standard utilities.
- 2D and 3D graphics, accessibility, servers,
collaboration, telephony, speech, animation, and
more.
12HelloWorld.java
- public class HelloWorld
- public static void main(String args)
- // Display "Hello World!"
- System.out.println("Hello World!")
-
13Compilation and Execution
- Compile
- Use compiler javac
- Compile java source file to bytecode program
- Execution
- Use interpreter java
- Interprets the bytecode
- Platform independence bytecode program should be
executable on all platforms
14Object-Oriented Languages
- Object
- An object is a software bundle of related
variables and methods. Software objects are often
used to model real-world objects you find in
everyday life. - Message
- Software objects interact and communicate with
each other using messages. - Class
- A class is a blueprint or prototype that defines
the variables and the methods common to all
objects of a certain kind.
15Object-Oriented Languages
- Inheritance
- A class inherits state and behavior from its
superclass. Inheritance provides a powerful and
natural mechanism for organizing and structuring
software programs. - Interface
- An interface is a contract in the form of a
collection of method and constant declarations.
When a class implements an interface, it promises
to implement all of the methods declared in that
interface. - Example Set
16Variables (declared as type name)
public class MaxVariablesDemo public static
void main(String args) // integers
byte largestByte Byte.MAX_VALUE
short largestShort Short.MAX_VALUE int
largestInteger Integer.MAX_VALUE long
largestLong Long.MAX_VALUE // real
numbers float largestFloat
Float.MAX_VALUE double largestDouble
Double.MAX_VALUE // other primitive
types char aChar 'S' boolean
aBoolean true
17Handling Objects
public class Rectangle public int width
0 public int height 0 public Point
origin //Four constructors public
Rectangle() origin new Point(0, 0)
public Rectangle(Point p)
origin p
(continued) public Rectangle(int w, int h)
this(new Point(0, 0), w, h) public
Rectangle(Point p, int w, int h) origin
p width w height h
18Handling Objects
//A method for moving the rectangle public
void move(int x, int y) origin.x x
origin.y y //A method for
computing the area of the rectangle public
int area() return width height
19XML, Part II
20Example
-
- cook_time"3 hours"
- Basic bread
- Flouredient
- Yeastingredient
- Warm
Water - Saltngredient
-
- Mix all ingredients together, and
knead. - Cover with a cloth, and leave for
one hour. - Knead again, place in a tin, bake in
the oven. -
21Example
- Thing
oneThing two - Normal
emphasized strong
emphasized strong
22XML Technologies we will cover
23DTD XSDs(XML Schema Definitions)
- Describe the structure of valid XML documents
- Use a form of context-free grammar
24XML Syntax
- Elements
- XML tags for markup
- Attributes
- Tuple information of elements
- Declarations
- Instructions to XML processor
- Processing Instructions
- Instructions to external applications
25Elements
- Basic rules
- Start tag and end tag
- Tags must be nested
-
- Tags may be empty (no enclosed data)
-
- Whitespace in element content usually ignored
-
-
26Attributes
- Provides additional information about an element
- Enclosed by quotes - either " or '
- Case-sensitive
- May be character data or tokenized
- value"Blue Peter" (character data)
- value "blue" (single token)
- value "red green blue" (tokens)
- Values may be enumerated or defaulted (DTD)
27Comment Declaration
- Comments are not considered part of XML document
and should not be published -
- Cannot have additional '--' in comment
- Cannot embed inside other declarations
28Processing Instructions
- Information required by an external application
- Processing Instructions
- Format -
- XML PI -
- Confusingly, this is called the XML declaration,
but is a processing instruction
29Entities
- XML document may be distributed among a number of
files - Each unit of information is called an entity
- Each entity has a name to identify it
- Defined using an entity declaration
- Used by calling an entity reference
30An XML DTD
-
-
-
- name CDATA IMPLIED
- length CDATA IMPLIED
-
- REQUIRED
31Attribute Types
- CDATA
- Character data
- NMTOKEN
- Single token
- NMTOKENS
- Multiple tokens
- ENTITY
- Attribute is entity ref
- ENTITIES
- Multiple entity ref's
- ID
- Unique ID
- IDREF
- Match to ID
- IDREFS
- Match to multiple ID's
- NOTATION
- Describe non-XML data
- Name group
- Restricted list
32Attribute Types
- CDATA
- name "Tom Jones"
- NMTOKEN
- color"red"
- NMTOKENS
- values"12 15 34"
- ENTITY
- photo"MyPic"
- ENTITIES
- photos"pic1 pic2"
- ID
- ID "P09567"
- IDREF
- IDREF"P09567"
- IDREFS
- IDREFS"A01 A02"
- NOTATION
- FORMAT"TeX"
- Name group
- coord"X"
33Character Data Declaration
- For occasions when text must contain
uninterpreted markup characters - Press ltltltENTERgtgtgt
-
- But, why is this in your data? This should be
stylistic information!
34XML Schema
-
- hema
- targetNamespacehttp//localhost8080/crossler
- xmlnshttp//localhost8080/crossler
- elementFormDefault"qualified"
-
-
-
- type"xsdstring"/
- type"xsdinteger"/
-
-
-
-
- Whats wrong with this XML?
35Formatting
- Cascading Style Sheets
- href"myStyleSheet.css"?
- Extensible Style Sheets Language
Transformations - href"transform.xsl"?
36Why XML Schema(why not just DTD)?
- More data types
- Complex data types
- More like a database schema
- Will continue in Lecture 2 Format
- Time to assign the first Project!