XML

228 views
179 views

Published on

XML

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
228
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

XML

  1. 1. Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd
  2. 2. XML(XML Schema,XML Parsing, Glade XML Structure)
  3. 3. XML• XML stands for eXtensible Markup Language• XML was designed to carry data, not to displayData• XML tags are not predefined. You must define your own tags
  4. 4. Main Components of an XML DocumentElements: <hello>Attributes: <item id=“33905”>Entities: &lt; (<)
  5. 5. The Basic Rules• XML is case sensitive• All start tags must have end tags• Elements must be properly nested• XML declaration is the first statement• Every document must contain a root element• Attribute values must have quotation marks• Certain characters are reserved for parsing
  6. 6. Common Errors for Element Naming• Do not use white space when creating names for elements• Element names cannot begin with a digit, although names can contain digits• Only certain punctuation allowed – periods, colons, and hyphens
  7. 7. XML Schema Basics• XML Schema is an XML application• Provides simple types (string, integer, dateTime, duration, language, …)• Allows defining possible values for elements• Allows defining types derived from existing types• Allows defining complex types• Allows posing constraints on the occurrence of elements• Allows forcing uniqueness and foreign keys• Way too complex to cover in an introductory talk
  8. 8. Simplified XML Schema Example<xs:schema> <xs:element name=“article“> <xs:complexType> <xs:sequence> <xs:element name=“author“ type=“xs:string“/> <xs:element name=“title“ type=“xs:string“/> <xs:element name=“text“> <xs:complexType> <xs:sequence> <xs:element name=“abstract“ type=“xs:string“/> <xs:element name=“section“ type=“xs:string“ minOccurs=“0“ maxOccurs=“unbounded“/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
  9. 9. XML Parser• An XML parser converts an XML document into an XML DOM object - which can then be manipulated with JavaScript• A DOM (Document Object Model) defines a standard way for accessing and manipulating documentsThe XML DOM• The XML DOM defines a standard way for accessing and manipulating XML documents• The XML DOM views an XML document as a tree-structure• All elements can be accessed through the DOM tree. Their content (text and attributes) can be modified or deleted, and new elements can be created. The elements, their text, and their attributes are all known as nodes
  10. 10. Parse an XML DocumentThe following code fragment parses an XML document into an XML DOM object:if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","books.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML;
  11. 11. Parse an XML DocumentNote:Internet Explorer uses the loadXML() method to parse an XMLstring, while other browsers use the DOMParser object.
  12. 12. GladeXMLAllows dynamic loading of user interfaces from XML descriptions.This object represents an `instantiation of an XML interface description. When one of these objects is created, the XML file is read, and the interface is created. The GladeXML object then provides an interface for accessing the widgets in the interface by the names assigned to them inside the XML description.The GladeXML object can also be used to connect handlers to the named signals in the description. Libglade also provides an interface by which it can look up the signal handler names in the programs symbol table and automatically connect as many handlers up as it can that way.
  13. 13. UsageClass: <glade-xml> Derives from <gobject>.This class defines no direct slots.— Function: glade-xml-new (fname mchars) (root mchars) (domain mchars)  ⇒  (ret <glade-xml>) Creates a new GladeXML object (and the corresponding widgets) from the XML file fname. Optionally it will only build the interface from the widget node root (if it is not ‘#f’). This feature is useful if you only want to build say a toolbar or menu from the XML file, but not the window it is embedded in. Note also that the XML parse tree is cached to speed up creating another GladeXML object for the same filefnamethe XML file name. rootthe widget node in fname to start building from (or ‘#f’) domainthe translation domain for the XML file (or ‘#f’ for default) retthe newly created GladeXML object, or NULL on failure.
  14. 14. UsageMethod: get-widget This function is used to get a pointer to the GtkWidget corresponding to name in the interface description. You would use this if you have to do anything to the widget after loading.selfthe GladeXML object. namethe name of the widget. retthe widget matching name, or ‘#f’ if none exists.
  15. 15. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance.www.baabtra.com | www.massbaab.com |www.baabte.com
  16. 16. Contact Us

×