90 likes | 250 Views
XML (Extensible Markup Language). Prepared by: Jaclyn Soh. XML (Extensible Markup Language). a language for describing structured data. improves on the HTML approach & makes the web a better place in which to do a business, to learn, and to have fun.
E N D
XML (Extensible Markup Language) Prepared by: Jaclyn Soh
XML (Extensible Markup Language) • a language for describing structured data. • improves on the HTML approach & makes the web a better place in which to do a business, to learn, and to have fun. • have a freedom to use pretty much any names you like to tag up your data.
Example <!-- HTML Snippet --> <h1>Invoice</h1> <p>From: Jaclyn Soh <p>To: Whoever <p>Amount: $100.00 <p>Tax: 21% <p>Total Due: $121.00 View in .html <!-- XML Snippet --> <Invoice> <From>Jaclyn Soh</From> <To>Whoever</To> <Date>Year=‘2001’ month=‘4’ day=’16’/> <Amount currency = ‘Dollars’>100.00 </Amount> <TaxRate>21</TaxRate> <TotalDue currency = ‘Dollars’>121.00 </TotalDue> </Invoice> View in .xmlfrom .xml to .html
XML – Cont. • any language based on XML consists of a set of element types that have been given certain names & certain meanings. • the presence of elements of various types in documents is indicated by tags that serve to indicate where the element starts and ends. • a set of element types serves to define types of documents and are referred to as Document Type Definitions, or DTD.
XSL – Extensible Stylesheet Language • Extensible Stylesheet Language (XSL) • relationship between XML and XSL is similar to the relationship between HTML and CSS. • example
More XML… • strictly hierarchical. • can have only one root element. Example: <Invoice> document, the <Invoice> element is called root element. • root element is the top-level element in the document, and all the other elements are its children or descendents.
XML – Generosity??? • indeed! XML is very generous in the names we’re allowed to use. For example, there aren’t any reserved words to avoid in XML, as there are in most programming languages. We have a lot flexibility in this regard. • However…
Some rules to follows: • names can start with letters (including non-Latin characters) or the “_” character, but not numbers or other punctuation characters. • after the first character, numbers are allowed, as are the characters “_” and “.”. • names can’t contain spaces. • names can’t contain the “:” character. • names can’t start with letters “xml”, in uppercase, lowercase, or mixed. • there can’t be a space after the opening “<“ character; the name of the element must come immediately after it. • case sensitive. • For example, <first> is different from <FIRST>
Questions • XML is used for describing structural data. (T/F) • XML document can have more than one root element. (T/F) • XML is not case sensitive. (T/F) • XML allows you to create your own tags to precisely describe data. (T/F) • Names can start with letters, characters, numbers and punctuation. (T/F)