XML Introduction
XML Introduction
XML Introduction
What is XML?
a meta language that allows you to
create and format your own document
markups
a method for putting structured data
into a text file; these files are
- easy to read
- unambiguous
- extensible
- platform-independent
- XML names:
- Entity names:
- No length limitation
- Must begin with a letter, a dash, or a colon
- Can include letters, digits, periods, dashes,
underscores, or colons
&entity_name;
< <
> >
& &
" "
' '
e.g., instead of
use
<!keyword … >
UTF-16 uses 2 bytes (16 bits) for most characters, and four bytes
for the rest.
Data Type Definitions (continued)
- Declaring Elements
- General form:
e.g.,
memo
e.g.,
<!ELEMENT person
(parent+, age, spouse?, sibling*)>
- General form:
- Default values:
a value
#FIXED value (every element will have
this value),
#REQUIRED (every instance of the element must
have a value specified), or
#IMPLIED (no default value and need not specify
a value)
- e.g.,
- Two kinds:
- A reference: &jfk;
→ SHOW planes.dtd
8.4 Data Type Definitions (continued)
- XML Parsers
http://xml.apache.org/xerces-j/index.html
- Internal DTDs
<!DOCTYPE root_name [
…
]>
- External DTDs
- Two purposes:
http://www.w3.org/2001/XMLSchema
targetNamespace ="http://cs.uccs.edu/planeSchema"
8.6 XML Schemas (continued)
- If we want to include nested elements, we must
set the elementFormDefault attribute to
qualified
xmlns = "http://cs.uccs.edu/planeSchema"
<xsd:schema
<xmlns:xsd =
"http://www.w3.org/2001/XMLSchema"
<targetNamespace =
"http://cs.uccs.edu/planeSchema"
xmlns = "http://cs.uccs.edu/planeSchema"
elementFormDefault = "qualified">
8.6 XML Schemas (continued)
- Defining an instance document
<planes
xmlns = "http://cs.uccs.edu/planeSchema"
xmlns:xsi =
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation =
"http://cs.uccs.edu/planeSchema
planes.xsd" >
- Use the element tag and set the name and type
attributes
fixed = "three-toed"
- User-Defined Types
1. Element-only elements
2. Text-only elements
3. Mixed-content elements
4. Empty elements
- Element-only elements
http://www.ltg.ed.ac.uk/~ht/xsv-status.html
- XSLT - Transformations
- XSL-FO - Formatting objects
-XSL-P-Path Langauge
XSLT
XML DOC XSL DOC
PROCESSOR
8.8 XSLT Style Sheets (continued)
- An XSLT processor merges an XML document into
an XSLT style sheet
- An example:
<xsl:stylesheet xmlns:xsl =
"http://www.w3.org/1999/XSL/Format">
- Has no content