wt module ii xml
TRANSCRIPT
-
8/3/2019 Wt Module II XML
1/47
Sarju SLecturer
Department of Computer Science and EngineeringWWW.lectnote.blogspot.com
Web Technologies (RT 705)
XML
Java
Bean
JSP EJB
1
-
8/3/2019 Wt Module II XML
2/47
Module II
Document Type declarations Creating XML DTDs
Element type declaration Attribute List
Declaration Attribute types Attribute defaults Displaying XML Data in HTML browser as
HTML tables Storing XML data in HTML
document Converting XML to HTML with XSL
minimalist XSL style sheets XML applications
2
-
8/3/2019 Wt Module II XML
3/47
Document Type Declarations
is a statement embedded in XML document
whose purpose is to acknowledge the existence
and location of the Document Type Definition
(DTD).
It tells, what tags we can use in a document,
what order they should appear in, which tagscan appear inside other ones, which tags have
attribute so on.
3
-
8/3/2019 Wt Module II XML
4/47
Document Type Declarations
All document type declaration begins with
the string
-
8/3/2019 Wt Module II XML
5/47
Internal Subset(Internal DTD)
Document Type Definitions that are
included with in the xml document is called
Internal DTD.
Syntax
]>
5
-
8/3/2019 Wt Module II XML
6/47
Eg:
]>
12
#PCDATA :- Parsed Character Data, which explicitly
means that the text that not contain markups, just simplecharacter data.
Internal Subset(Internal DTD)
6
-
8/3/2019 Wt Module II XML
7/47
]>
Rani
Ravi
Remainder
About our parents Wedding Anniversary
Internal Subset(Internal DTD)
7
-
8/3/2019 Wt Module II XML
8/47
The DTD is interpreted as follows:
1) 4) PCDATA - Element contain only text data
5) # - # is reserved character indicates that #PCDATA is
a reserved word
Internal Subset(Internal DTD)
8
-
8/3/2019 Wt Module II XML
9/47
External Subset(External DTD)
consists of a reference to an external entity
following the DOCTYPE keyword.
apples.dtd
apples.xml
12
9
-
8/3/2019 Wt Module II XML
10/47
//mail.xml
Rani
Ravi
Remainder
About our parents Wedding Anniversary
External Subset(External DTD)
10
-
8/3/2019 Wt Module II XML
11/47
//mail.dtd
]>
External Subset(External DTD)
11
-
8/3/2019 Wt Module II XML
12/47
Internal and External
apples.dtd
apples.xml
12
12
-
8/3/2019 Wt Module II XML
13/47
Element Type Declarations
Element type declarations allow an xml
application to constrain the element that
can occur in the document and to specifythe order in which can occur.
13
-
8/3/2019 Wt Module II XML
14/47
To validate an XML document ,a validating
parser needs to know three things about
each element
1) What the element type is named
2) What elements of that type can
contain(content model)
3) What attributes an element of that type has
associated14
Element Type Declarations
-
8/3/2019 Wt Module II XML
15/47
Both the element type name and its content
model are declared together in what is
known asElement Type declaration
Element Type declaration must start with
the string
name and content specification
15
Element Type Declarations
-
8/3/2019 Wt Module II XML
16/47
Every element has certain allowed content.
There are four general types of content
specification
1) EMPTY content may not have content
Eg:
2) ANY content may have any combination of
elements in any order
Eg: 16
Element Type Declarations
-
8/3/2019 Wt Module II XML
17/47
3) Mixed content may have character data or
mix of character data and sub elements
Eg:
4) Element Content May have only sub
elements in element content specifications.
Eg:
body)>
17
Element Type Declarations
-
8/3/2019 Wt Module II XML
18/47
18
Element Type Declarations
-
8/3/2019 Wt Module II XML
19/47
19
Element Type Declarations
-
8/3/2019 Wt Module II XML
20/47
20
Element Type Declarations
-
8/3/2019 Wt Module II XML
21/47
21
Element Type Declarations
-
8/3/2019 Wt Module II XML
22/47
22
Element Type Declarations
-
8/3/2019 Wt Module II XML
23/47
23
Element Type Declarations
-
8/3/2019 Wt Module II XML
24/47
24
Element Type Declarations
-
8/3/2019 Wt Module II XML
25/47
Attribute List Declarations
Attribute list declarations serve to specify
the name, type and optionally the default
value of the attribute associate with anelement.
default-value>
There are ten different attribute types exist.
They are
25
-
8/3/2019 Wt Module II XML
26/47
-
8/3/2019 Wt Module II XML
27/47
The simplest type of attribute is the CDATA
or string attribute. CDATA attribute values
can be any string of characters.
For example
27
String Attributes
-
8/3/2019 Wt Module II XML
28/47
An element of type product has an attribute
called name whose values can be any string
of characters except ,&
Sample:or
28
String Attributes
-
8/3/2019 Wt Module II XML
29/47
An enumerated attribute is one that can take
on one of a fixed set of values supplied as
part of its declaration.
Ex:
Color(red|green) >
29
Enumerated Attributes
-
8/3/2019 Wt Module II XML
30/47
An element of type product has two
attributes known as name and color. The
name attribute can have any string ofcharacters except ,&.Color attribute
must be either the string red orgreen .
Note : Remember the enumerated attribute elements are case
sensitive.
30
Enumerated Attributes
-
8/3/2019 Wt Module II XML
31/47
ID
name to an element to uniquely identify it.
mustbegin with a letter, a _ ,or a :
character .
Example
the sample element might look like this
31
ID/IDREF/IDREFS
-
8/3/2019 Wt Module II XML
32/47
IDREF
Represents the value of an ID attribute of
another element.
the sample element might look like this
32
-
8/3/2019 Wt Module II XML
33/47
IDREFS
Represents multiple IDs of elements,
separated by whitespace.
book element might look like this:
33
-
8/3/2019 Wt Module II XML
34/47
ENTITY/ENTITIES
The name of an entity (which must be
declared in the DTD)
The letter element might look like this:
34
-
8/3/2019 Wt Module II XML
35/47
NMTOKEN /NMTOKENS
A valid XML name.
any combination of letters, digits and some
punctuation characters ., -, _ and
:.
Note that this list does not contain any
white space characters.
35
-
8/3/2019 Wt Module II XML
36/47
NOTATION
An attribute list declaration of type
NOTATION must specify one or more
notations declared somewhere in theDocument Type Declaration.
36
-
8/3/2019 Wt Module II XML
37/47
ATTRIBUTE DEFAULTS
#IMPLIED
#REQUIRED
#FIXED value
37
-
8/3/2019 Wt Module II XML
38/47
#IMPLIED
Specifies that there is no default value for
this attribute, and that the attribute is
optional.
Syntax
#IMPLIED>Example
38
-
8/3/2019 Wt Module II XML
39/47
#REQUIRED
The attribute must have an explicitly
specified value on every occurrence of the
element in the document.
Syntax
CDATA #REQUIRED>
Example
#REQUIRED> 39
-
8/3/2019 Wt Module II XML
40/47
#FIXED
The #FIXED keyword specifies that you will
provide value, and that's the only value that
can be used by users of this DTD.
Syntax
CDATA #FIXED>
Example
#FIXED "EN"> 40
-
8/3/2019 Wt Module II XML
41/47
XSL
XSL stands forExtensible Styles Language
and is a very powerful language for
applying styles to XML documents.formatting language
transformation language.
41
-
8/3/2019 Wt Module II XML
42/47
XSL
The formatting language allows you to
apply styles similar to what CSS does.
The transformation language is known as
XSLT (XSL Transformations).
42
B i h d i h
-
8/3/2019 Wt Module II XML
43/47
43
xsl:stylesheet
In this element we can specify the Namespace
for style sheet.
Basic tags that are used in the
XSL
xmlns:xsl='http://www.w3.org/TR/WD-xsl
B i t th t d i th
-
8/3/2019 Wt Module II XML
44/47
tag allows us to select any node in our XML
document and transform its contents.
Eg: 1.
Eg: 2.
-
8/3/2019 Wt Module II XML
45/47
45
Basic tags that are used in the
XSL
-
8/3/2019 Wt Module II XML
46/47
(other content/HTML markup goes here)
(other content/XSLT/HTML markup goes
here)
46
Basic tags that are used in the
XSL
-
8/3/2019 Wt Module II XML
47/47