softsmith infotech xml. softsmith infotech xml extensible markup language xml is a markup language...

17
Softsmith Infotech XML

Upload: kerry-farmer

Post on 01-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML

Page 2: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML

• EXtensible Markup Language • XML is a markup language much

like HTML • Designed to carry data, not to

display data • XML tags are not predefined. You

must define your own tags • Self-descriptive • W3C Recommendation

Page 3: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

Overview

• Comparing HTML and XML• XML• DTD• XSD• XSL• Tags• Naming convention• Usage• Parsing

Page 4: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

HTML and XML

• HTML– Display data– How data looks?

• XML– Store and Retrieve data– What data is?

Page 5: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Usage

• To display html contents, dynamically

• Helps to store data that has no compatibility issues

• Simplifies data transfer

• Platform independent

Page 6: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Format

• Similar to HTML• Has start tags and end tags• Strict nesting (every start tag should have an

end tag)<root> <child> <sub-child>.....</sub-child> </child></root>

Page 7: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Tags

• Every start tag should have an end tag

• Tag names are case sensitive

• Attribute values should be enclosed in quotes

• XML documents should have a root element

• XML tags should be properly nested

Page 8: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Special characters

• &lt

• &gt

• &amp

• &apos

• &quot

• XML – Whitespace is preserved

Page 9: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

Comments in XML

• <!-- - Start

• - -> End

• Similar to HTML

Page 10: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Naming Rules

• Names can contain letters, numbers, and other characters

• Names must not start with a number or punctuation character

• Names must not start with the letters xml (or XML, or Xml, etc)

• Names cannot contain spaces

Page 11: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

Best Naming Practices• Make names descriptive. Names with an underscore separator are nice:

<first_name>, <last_name>.• Names should be short and simple, like this: <book_title> not like this:

<the_title_of_the_book>. • Avoid "-" characters. If you name something "first-name," some software

may think you want to subtract name from first.• Avoid "." characters. If you name something "first.name," some software

may think that "name" is a property of the object "first."• Avoid ":" characters. Colons are reserved to be used for something called

namespaces (more later).• XML documents often have a corresponding database. A good practice is to

use the naming rules of your database for the elements in the XML documents.

• Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.

Page 12: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Attributes limitation

• Attributes cannot contain multiple values

• Attributes cannot contain tree structures

• Attributes are not easily expandable

Page 13: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML types

• Well formed XML - XML written with correct syntax

• Valid XML – A well formed XML which also conforms to the rules of DTD (Document type definition) or an XSD (XML Schema definition)

Page 14: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

DTD

• Document Type Definition

• Tells how an XML document is to be structured

• Used by XML Parser to check for the validity of XML document

Page 15: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XSD

• XML Schema Definition

• Similar to DTD, but more powerful than it

• Tells the parser, what are the elements that an xml document will contain and what data type do each element belongs to

Page 16: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XSL

• Extensible Style sheet Language• Similar to CSS for HTML• Defines styles for an xml document• Controls the format of XML tag• XML document will be displayed in a raw

way in the browser. That is with – and + symbols

• XSL makes XML document more appealing

Page 17: Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display

Softsmith Infotech

XML Parsers

• Two parsers available for XML– SAX

• Simple API for XML• Reads XML document serially

– DOM• Document Object Model• Treats every XML tag as an element or object with in a

document• Can access each tag as Document.Node or

Document.ParentElement• Available in .Net framework