Java Reference
In-Depth Information
F IGURE 33.4
A default JSF page is created in a new Web project.
JSF namespace
h:head
6 xmlns:h="http://xmlns.jcp.org/jsf/html">
7 <h:head>
8 <title>Facelet Title</title>
9 </h:head>
10 <h:body>
11 Hello from Facelets
12 </h:body>
13 </html>
h:body
Line 1 is an XML declaration to state that the document conforms to the XML version 1.0
and uses the UTF-8 encoding. The declaration is optional, but it is a good practice to use it.
A document without the declaration may be assumed of a different version, which may lead
to errors. If an XML declaration is present, it must be the first item to appear in the document.
This is because an XML processor looks for the first line to obtain information about the docu-
ment so that it can be processed correctly.
Line 2 is a comment for documenting the contents in the file. XML comment always
begins with <!-- and ends with --> .
Lines 3 and 4 specify the version of XHTML used in the document. This can be used by
the Web browser to validate the syntax of the document.
An XML document consists of elements described by tags. An element is enclosed between
a start tag and an end tag. XML elements are organized in a tree-like hierarchy. Elements
may contain subelements, but there is only one root element in an XML document. All the
elements must be enclosed inside the root tag. The root element in XHTML is defined using
the html tag (line 5).
Each tag in XML must be used in a pair of the start tag and the end tag. A start tag begins
with < followed by the tag name and ends with > . An end tag is the same as its start tag except
that it begins with </ . The start tag and end tag for html are <html> and </html> .
The html element is the root element that contains all other elements in an XHTML page.
The starting <html> tag (lines 5 and 6) may contain one or more xmlns (XML namespace)
attributes to specify the namespace for the elements used in the document. Namespaces are
like Java packages. Java packages are used to organize classes and to avoid naming conflict.
XHTML namespaces are used to organize tags and resolve naming conflict. If an element
with the same name is defined in two namespaces, the fully qualified tag names can be used
to differentiate them.
XML declaration
XML comment
DOCTYPE
element
tag
html tag
 
Search WWH ::




Custom Search