Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)

Similar presentations


Presentation on theme: "1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)"— Presentation transcript:

1 1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)

2 2 XHTML

3 3 HTML example: This is a bad HTML page Bad HTML page

4 4 Why XHTML? Many pages on the WWW contain "bad" HTML. The previous HTML code works fine if you view it in a browser, even though it doesn’t follow the HTML rules. XML was designed to describe data and HTML was designed to display data. By combining HTML and XML, and their strengths, we got a markup language - XHTML.

5 5XHTML XHTML stands for EXtensible HyperText Markup Language XHTML is aimed to replace HTML XHTML is almost identical to HTML 4.01 XHTML is a stricter and cleaner version of HTML XHTML is HTML defined as an XML application - XHTML consists of elements in HTML combined with the syntax of XML. XHTML is a W3C Recommendation

6 6 Well-formed XML/XHTML Documents must have a root element Elements must have a closing tag Tags are case sensitive Elements must be properly nested Attribute values must always be quoted

7 7 XML Namespaces

8 8 When an element name appears in two different XML documents, we would like to know that it has the same meaning in both documents -Is the tag used as the XHTML tag in both documents? -If two documents about books have the tag, does it mean that they use the same system for cataloging books?

9 9 XML Namespaces are/are not: Namespaces merely provide a mechanism for creating unique names (for elements and attributes) that can be used in XML documents all over the Web -A namespace is just a collection of names that were created for a specific domain of applications Namespaces are not DTDs and they do not provide a mechanism for validation of XML documents using multiple DTDs A “valid” XML document conforms to a DTD. A DTD defines the legal elements of an XML document.

10 10 A name space is identified by a Uniform Resource Identifier ( URI - a string of characters which identifies an Internet Resource ). The most common URI is the Uniform Resource Locator ( URL - identifies an Internet domain address ). -The only purpose of the URI is to give the namespace a unique name. However, very often companies use the namespace as a pointer to a real Web page containing information about the namespace. An element name or attribute name from a namespace has two parts prefix:name prefix identifies the namespace name is just a name from the namespace Identifying an XML Namespace

11 11 Namespaces – example: Apples Bananas African Coffee Table 80 120 URI name prefix

12 12 Recognizing Namespace When an application sees a qualified name, it may recognize it and act accordingly -A browser identifies tags that belong to the XHTML namespace and processes them -An XSLT processor identifies tags and attributes that belong to the XSLT namespace and executes them (XSLT processor - a program which interprets and executes XSLT programs)

13 13 Declaring a Namespace An XML namespace is declared in the xmlns attribute XML Namespaces John Doe Using foo as the prefix, instead of using the URI, is more convenient

14 14 The Default Namespace The default namespace is declared without a prefix XML Namespaces John Doe All the above elements belong to the default namespace

15 15 DTDs as Namespaces The URI of a namespace may point to a DTD A DTD defines a namespace comprising all its element names and attribute names But it is just a namespace - not a declared DTD!

16 16 Example <bib:book xmlns:bib=“http://www.acm.org/bibliography.dtd” xmlns:isbn=“http://www.isbn-org.org/def.dtd”> Proceedings of SIGMOD 472010 1-58113-332-4 This document is invalid according to either DTD! But the document is well formed! (e.g., in the book element, attribute names are unique)

17 17 Alternatively, One Namespace can be Declared as the Default <book xmlns=“http://www.acm.org/bibliography.dtd” xmlns:isbn=“http://www.isbn-org.org/def.dtd”> Proceedings of SIGMOD 472010 1-58113-332-4 This document is well formed but invalid according to either DTD!

18 18 Scope of Namespaces The scope of a namespace declaration is the element containing the declaration and all descendant elements -Must use the prefix anywhere in the scope More than one namespace can be declared in the same scope -At most one can be the default namespace -All others must have unique prefixes

19 19 What about Attributes? Recall that element names and attribute names must be qualified if they belong to a nondefault namespace Unqualified element names belong to the default namespace (if they are inside the scope) However, an unqualified attribute does not belong to the default namespace An unqualified attribute is processed according to the rules that apply to its element name subject to namespace interpretation

20 20 Book Review XML: A Primer Example:

21 21 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)

22 22 XSL= XML Style Sheets XSL describes how the XML document should be displayed XSL is a standard that consists of three parts: XPath (navigation in documents) -taught in the lecture XSLFO (FO for formatting objects) -This is a rather complex language for typesetting (i.e., preparing text for printing), will not be taught XSLT (transformation of documents)

23 23 XSL Transformations (XSLT)

24 24 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath to navigate in XML documents. An XSLT program is itself an XML document (called an XSL stylesheet) that describes the transformation process for input (XML) documents.

25 25 XSLT Processors XSLT Processor

26 26 Web Page Layout Doc. Structure Data Web Pages – The Whole Picture XML XSLXHTML Style Knowledge CSS

27 27 Dark Side of the Moon Pink Floyd 10.90 Space Oddity David Bowie 9.90 Aretha: Lady Soul Aretha Franklin 9.90 catalog.xml

28 28 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> cd catalog This is a cd catalog! Valid XML! Commands are XML elements with the namespace xsl Includes XHTML elements catalog.xsl

29 29 To be continued...


Download ppt "1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)"

Similar presentations


Ads by Google