XML
XML stands for Extensible markup language. It is known as extensible language becuase it allows its users to define their own elements. So it defines a set of rules for encoding documents in a format that is both human-readable & machine - readable format. It is basically designed to transport & store data. XML is a W3C recommendation & it is designed to be self descriptive.
The aim of XML is to facilitate the sharing of structured data across different information systems, with the help of internet. So XML provides simplicity, generality & usability over the internet. XML is a markup language like HTML but XML & HTML are designed with different goals for example XML was designed to transport and store data, with focus on what data is where as HTML was designed to display data, with focus on how data looks.
HTML is about displaying information, while XML is about carrying information. So XML is not a replacement for HTML, RSS, Atom, SOAP and XHTML are some examples of XML based languages, where as office open XML, open office.org, Libre Office, Apple's is work are some examples of XML based formats.
XML provides a framework for defining markup languages like:
1. There is no fixed collection of mark up tags.
2. There is a common set of a generic tools for processing documents.
3. XML is targeted as its own application domain, but the language will share many features.
XML is widely used for storing data in a structured manner just like tree. XML documents can be used as a mini data store & this data is used to present it on a variety of targets including browsers, print media etc. When XML data is transferred acorss different systems, the data contained is an XML document can be read by using a software entity called parser. Oracle, MSSQL Server, Sybase, DB2 are some popular data bases & they provide their own mechanisms to store and retrieve data as XML.
where
XSD is XML schema definition
DTD is Document type definition
XSL is Extenisble style sheet language.
By default the structured data is contained in a XML document with. XML extension, we can use XSL to build the style sheets because of advanced features power & the flexibilty.
DTD consists of structural constrains & rules.
XML VS HTML
XML & HTML both grew out of SGML XML is a subset of SGML & it is more complicated than HTML but it is powerful, where as HTML is a markup language written in SGML.
FEATURES OF XMI
1. XML files are text files, which can be managed by any text editor.
2.It is simple, because it follows less than 10 syntax rules.
3. It is extensible.
4. It can be used with existing protocals.
5. It supports variety of applications.
6.It is compatiable with SGML because it is a subset of SML.
7.User can create its own tags. So XML allows user to define their own tags.
8.With the help of XML we can create new internet languages. A lot of new internet languages are created with XML some of them are XHTML, WSDL, WAP, WML, RSS, RDF, OWL etc.
ADVANTAGE OF XML
1. XML is a platform independent language.
2. It is easy as HTML
3. It is compatible with applications like Java.
4. It is portable language.
5. It is an extendable language. In XML we can create our own tags.
7.It can be deplayed on any network.
8. It is vendor independent.
9. It is system independent language.
DISADVANTAGE OF XML
1. It is more difficult, demanding & precise than HTML
2. Due to lack of browser support it is not used by end user applications.
3. Still experimental.
USES OF XML
1. XML is used for storing the databse.
2. It helps in making tree like structure.
3.It is used for storing vector graphics and describing multimedia presentations.
4. XML helps in defining the channels. In XML channels are the web pages that are pushed to subscribers.
5. XML is used as a communicating media among applications over the web.
TERMINOLOGYFOR XML
1. Unicode: Almost every legal unicode character may appear in an XML document.
2. Processor & application: The processor analyzes the markup & then it passes structured information to an application.
3. Markup & Content : The characters making up an XML document are divided into markup & content.
4. Tags: In XML tags are divided into three parts namely :
- Start tag
- End tags
- Empty element or container .tag
5. Element : A XML document begins with a start tag & ends with a end tag. The characters between the start & end tag, if any are the elements content & may contain markup, including other elements, which are called child elements.
6. Attribute: A markup construct may consists of a name or a value of a pair that exists with in a start or empty element tag.
How to create XML document
1. Open new text file.
2. Type XML document.
3. Save XML document with file name using .xml extension.
Rules for XML
1. At top level document must resides & all other elements must be nested within it.
2. Elements of XML must be properly nested.
3. Elements of XML must consists of both tags i.e. start tag and an end tag.
4. The element type name is a start tag & it must exactly match the name in the corresponding end tag.
5. Element type names are case sensitive.
XML DOCUMENT STRUCTURE
XML document consists of logical and physical structure & it is made up of storage units known as entities. XML document mainly consists of declarations, elements, comments, character references and processing instructions & collectively these are known as markup.
XML is used to convey the messages between applications such as from web server to a client; XML content may be generated on the fly.
XML document consists of three parts namely :-1.
1.XML delcaration.
2. A document type declaration that refers to a DTD.
3. Document instance or a body.
Normally XML declaration and the document type declaration are known as XML prolog
XML DECLARATION
XML declaration is a piece of markup that identifies this as an XML document. This XML declaration indicates whether the document can be valiaded by referring to an external DTD i.e. document type definition.
Syntax of XML declaration is given below :
< ? XML version = "1.0"?>
As XML is a case sensitive language, the declaration must be written in lower case. Do not include a space before the string XML or between the question mark & the angle barackets. The strings< ?xml and?> must appear exactly as indicated. The space before the ? is optional. The formal definition of an XML declaration, according to the XML 1.0 specification is given below :
XML Decl :: = '<?XML' version encoding Decl? SDDed? '?>'
This EBNF i.e. extended backus - Naur Form notation is a characteristic of many W3C specifications that means XML declaration consists of the literal sequence'<?XML, followed by the required version information & followed by the optional encoding & a standalone declarations followed by an optional white space & terminatng with the literal sequence "?>
Document Type Delcaration
The main aim of document type declaration is to announce the root element & to provide the location of the document type delcaration. The general syntax of document type declaration is
given below :
<! Doctype Root Element (System Public)
External Declarations ? Internal Declaration]?>
Where:-
Doctype is a literal string.
Root element is the outermost element followed by system or public.
External Declaration: It is optional & it is relative path to the DTD that describes our document type.
Internal Declaration: It constitute the internal subset & it is enclosed in square brackets.
DTD related keywords such as DOCTYPE, SYSTEM, PUBLIC must be in upper case.
Document Body: Document Bodyis the whole bulk of the information content of the document. In multiple document body of a given type the XMI prolog will remain constant, the document body changes with each document instance.
Example:-
<?xml version = "1.0" encoding = '150 - 8859 - 1"?>
<note>
<to> Tove </to> <from> Jani </from>
<heading> Remainder </heading>
<body> Don't forget me </body> ‹note>
FLOW OBIECTS
To render the screen or print a page the browser uses flow objects. The document flows from the top of the bottom of the Canvas. Anything in the flow like characters, words, images are flow objects
WORKING WITH TEXT IN XML
There are many attributes which are associated with text in XML some of these are discuss below:
The letter spacing attribute is used to set the space between the individual characters in an element that normally displays the text. We can set this value in the style sheet. Command used for letter spacing attribute is given below :
letter - spacing : normal I <element> | auto l in herit where:
• Normal is the default value. Normal allows document browser to control space between individual characters.
• Length is the distance between characters in the text.
• Auto allows the text to be spaced so that complete text is placed on a single line.
• Inherit is the value for this distance is inherited from its parent elements.
*The line height property is used to specify the height of the line that may be text or graphics will be displayed upon & it also controls the whole amount of extra space provided for text and it is also used to create a shadow effect with our characters command used for line-height attribute is given below :-
line-height : normal | <number> I «length> | <percentage> I inherit.
where :.
• Normal is the value that informs user agent to use the computed value of the line height.
• Number is used to determine the computed line height of our text when it is multiplied by the absolute height of the property.
• Length is used to set the absolute height of the line.
• Percentage is used to allow the document author to control the height of the line by forcing the user agent to multiply this percentage to the height of the font is being used.
• Inherit forces the element to use the line-high value it received from its parent element.
Text-align attribute is used to align the inline-text contents of the block element to which the attribute is applied. Command used for text align attribute is given below text-align; left I right I center I justify I <string> I inherit.
where:-
left is left align.
right is reight align.
center is center text hroizontally.
justify is left or right justify text.
string is align against a string character.
*Word Spacing attribute is used to control the amount of space used between words. Syntax used for work-spacing attribute is given below.
word-spacing : normal I lengths |inherit.
where:
normalisthe spacing between words up to the xmi browser.
Length is positive integer and unit specifies identify a fixed width between each word.
ALIGNMENT IN MI
There are two type of alignment in XML namely :-
1.Baseline alignment: Baseline alignment is used to align objects with a font.
2.Margin alignment: Margin alignment is used to align objects to the outside margins of a page.
Valign is vertical alignment & it works with a variety of stable-related elements controlling the vertical position of information with in a cell. The syntax of valign is given below
Valign = top | middle I bottom I baseline
where :-
• Top: In the top information is rendered flush with the top of the cell.
• Middle: In middle the information is centered vertically with in the cell.
Bottom: In bottom the information is rendered flush with the cell bottom.
• Baseline: In baseline information is aligned against the baseline set for other objects.Halign is horizontal alignment & it works with a variety of table-related elements controlling the horizontal position of information with in a cell. The syntax of halign is given below
halign = top | middle I bottom I baseline
where :-
• In top information is rendered flush with the top of the cell.
• In middle the information is centered vertically with in the cell.
• In bottom information is rendered flush with the cell bottom.
• In baseline information is aligned against the baseline set for other objects.
TEXT DECORATIONS
Text decoration property is used to add decorative properties to element, it can cause an element to show an overline or to blink. The syntax for text decoration is given below :-text - deocration: none/underline/blink/overline/line-through.
where:
• Blink is used to blink the text.
• None is used when no decoration is required.
• Overline is placed above every line of text.
• Underline is used to underline the text.
• Line through is used to line midway through each character.
Text Shadow: Text shadow applies shadows to the text contents of an element. The syntax of text shadow is given below :-
text-shadow: none/[color/length length length ?,* [color/length length ?]inherit
where:
none is used for no shadow effect.
Color is the RGB value of the shadow color length is the value of the off set value of the horizontal, vertical or blur shadow dimension.
WORKING WITH FONTS IN XML
There are many properties which are associated with fonts in XML some of these porperties are discuses below:-
*Font family property is used to specify a prioritized list of font family names that can be searced by XML document browsers to match character glyphs. Syntax for font family is given below:
font-family : [l<family-name>/<generic-family>],] * [<family-name>/<generic-family> ]/inhierit
where:
• family name is the name of the font family. It includes : Bookman, Lucida, Time New Roman.
• generic family names are: Serif, sans-serif, cursive etc.
Font-Size Propety: This property is used to identify the size of the font. Syntax for font size property is given below:
font-size:<absolute-size>/relative-size/length>/<percentage>/inherit.
Font-Stretch: Font-stretch property is used to control the amount of space found between each individual character of the font.
Font-Style: Font style property is used to specify the style of font being used. The syntax for font-style is given below
font-style: normal/italic/oblique/inherit.
where:
• Normal is used to no style change.
• Italic displays with an italic slant to each character.
• Oblique is used to display with an oblique, slanted font.
Font Variant :- Font Variant property is used to write fonts using small caps for fonts supporting this sytle syntax for font variant is given below :
font-variant: normal/small-caps/inherit.
where
• Normal does not change from this standard font characters.
• Small-caps is used to use small capital letters in the place of the standard lower case letters with in specified text.
Font Weight: Font weight property is used to specify the weight or thickners of the font used to display the specified text. Syntax of font weight is given below :
Font weight:100/200/300/400/500/600/700/800/900/normal/bold/bolder/lighter/inherit.
where :-
• 100 to 900 are the numeric values from an ordered sequence in which each integer identifies a font weight that is at least as dark as its predecessor.
• Normal is value that is equivalent to 400.
• Bold is value that is equivalent to 700.
• Bolder is the value that is used to apply the next weight to a font darker than the inherite of one.
• Lighter is the value used to apply the previous weight to a font that is lighter than the inherited one.
Font Color : Font color property is used to identifies the foreground color for the text content of an element. Syntax for font color is given below :
Color: <colorname>/<RGB color> where :-
• Color name is the color names specified by the HTML 4.0 standard.
• RGB color is the name of the color is returned in hexa decimal format representing the
RGB value of the color.
XML FILE
An XML file (short for "eXtensible Markup Language") is a file format that is used for storing and exchanging data in a structured format. It is a markup language, which means that it uses a set of tags to describe the structure and meaning of the data it contains.
XML is often used as a data interchange format, as it is widely supported by many different software applications and programming languages. It can also be used for storing data in a way that is easily readable by both humans and machines, making it useful for tasks such as storing configuration data or storing data in a database.
An XML file typically consists of a set of elements, which are enclosed in opening and closing tags. Elements can contain other elements, as well as attributes that provide additional information about the element. Here is an example of an XML file:
xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person name="John" age="30">
<address>
<street>123 Main St</street>
<city>Anytown</city>
<state>CA</state>
<zip>12345</zip>
</address>
<phone>555-1234</phone>
</person>
<person name="Jane" age="25">
<address>
<street>456 Oak Ave</street>
<city>Somecity</city>
<state>NY</state>
<zip>54321</zip>
</address>
<phone>555-5678</phone>
</person>
</root>
In this example, the XML file contains a root element that contains two person elements. Each person element has a name and age attribute, as well as an address element and a phone element. The address element contains several sub-elements that describe the person's address.
Xml dtd
XML DTD (Document Type Definition) is a set of rules that define the structure and elements of an XML document. It is a formal declaration of the structure of an XML document that specifies the element names, attribute names, and data types of an XML document. It defines the allowed elements, attributes, entities, and the order in which they appear in the XML document.
DTD can be written using a simple text editor and is placed at the beginning of the XML document. It defines the document structure, element types, and their content models. Here's an example of a DTD:
<!DOCTYPE library SYSTEM "library.dtd">
<library>
<book>
<title>XML and Related Technologies</title>
<author>Atul Kahate</author>
<publisher>Tata McGraw Hill</publisher>
<price>450</price>
</book>
<book>
<title>XML: A Beginner's Guide</title>
<author>Steven Holzner</author>
<publisher>McGraw-Hill Osborne Media</publisher>
<price>320</price>
</book>
</library>
In this example, the DTD defines the library element, which contains one or more book elements. The book element has four child elements, namely title, author, publisher, and price.
The DTD can also define attribute types, entity references, and notations. A well-formed XML document must conform to its DTD, which ensures that the document is valid and structurally correct. A DTD also helps to enforce consistency and coherence in the XML documents, which makes it easier to validate and process the data in them.
