Unit-3 XML
Unit-3 XML
Unit3 : XML
Date & Time :08-3-2021 &11:00AM-11.50AM
Mrs G Karthika
Asst.Professor
Department of CSE
GITAM Institute of Technology (GIT)
Visakhapatnam – 530045
Email: [email protected]
• Levels of syntax
– Well-formed documents conform to basic XML rules
– Valid documents are well-formed and also conform to a schema which
defines details of the allowed content
• Well-formed XML documents
– All begin tags have a matching end tag
• Empty tags
– If a begin tag is inside an element, the matching end tag is also
– There is one root tag that contains all the other tags in a document
– Attributes must have a value assigned, the value must be quoted
– The characters <, >, & can only appear with their special meaning
• Validity is tested against a schema, discussed later
• Auxiliary files
– Schema file: defines its tag set and structural syntactic rules
• DTD or XML Schema or one of several other
– Style file: contains a style sheet to describe how the content of the
document is to be printed or displayed
• Cascading Style Sheets
• XSLT
• Breaking file up
– Document entities
– Entity syntax
• Character data
– <![CDATA ….. ]]>
• A set of declarations
• Define tags, attributes, entities
• Specify the order and nesting of tags
• Specify which attributes can be used with
which tags
• General syntax
– <!keyword …. >
– Note, not XML!
04/21/25 Department of CSE EID 302 & Web Technologies 5
Declaring Elements
• General syntax
– <!ELEMENT element-name content-description)>
– Content description specifies what tags may appear inside the named
element and whether there may be any plain text in the content
• Sequence of tags
• Alternate tags
• Multiplicity
– + : one or more number of occurrences
– * : zero or more occurrences
– ? : zero or one occurrence
• #PCDATA
• General syntax
– <!ATTLIST element-name
(attribute-name attribute-type default-value?)+ >
• Default values
– A value
– #FIXED value
– #REQUIRED
– #IMPLIED (default, if not specified)
• General Syntax
– <!ENTITY [%] entity-name “entity-value”>
– With %: a parameter entity
– Without %: a general entity
• Parameter entities may only be referenced in the DTD
• Remote form
– <!ENTITY entity-name SYSTEM “file-location”>
– The replacement for the entity is the content of the file
XSLT
Document
XSLT XSL
Processor Document
XML
Document
• Four purposes
– Check the basic syntax of the input document
– Replace entities
– Insert default values specified by schemas or DTD’s
– If the parser is able and it is requested, validate the input document against the
specified schemas or DTD’s
• The basic structure of XML is simple and repetitive, so providing library
support is reasonable
• Examples
– Xerces-J from the Apache foundation provides library support for Java
– Command line utilities are provided for checking well-formedness and validity
• Two different standards/models for processing
– SAX
– DOM
Department of CSE EID
04/21/25 33
302 & Web Technologies
7.10 Parsing