Académique Documents
Professionnel Documents
Culture Documents
Objectives
Ver. 1.0
Session 5
Slide 1 of 33
A CSS is a text file containing one or more rules or definitions for the style characteristics of a particular element. It controls how tags are formatted in XML and HTML documents. The CSS file can be included in XML documents with the same data structure.
Ver. 1.0
Session 5
Slide 2 of 33
Ver. 1.0
Session 5
Slide 3 of 33
property1 and property2 specify the property names, such as font-family, font-size, and color
Ver. 1.0
Session 5
Slide 4 of 33
For example, to display the film title in red, you can type the following code in a CSS file: FILM {COLOR: RED}
Ver. 1.0
Session 5
Slide 5 of 33
Ver. 1.0
Session 5
Slide 6 of 33
Ver. 1.0
Session 5
Slide 7 of 33
Specifies the name of the CSS file used to format the XML document.
Ver. 1.0
Session 5
Slide 8 of 33
Problem Statement:
Jim, the XML developer at CyberShoppe, has been asked to display the product details for Cybershoppe in a browser in the following format:
The price per unit, description, and quantity on hand for each product should be displayed in teal, with a font size of 10 pts. The product name should be displayed in red, with a font size of 20 pts. It should be displayed in bold. All details should be displayed in the Arial font.
Ver. 1.0
Session 5
Slide 9 of 33
CSS does not support the reorder, sort, and display of elements based on a condition. For such advanced formatting, XML supports Extensible Style Sheet Language (XSL). XSL has two parts:
XSL Transformations (XSLT) XML Path (XPath)
XSL:
Contains instructions on how an XML document should be transformed into an HTML or an XHTML document. Uses XPath expressions to extract specific data from an XML document.
The XSLT processor transforms the XML document into an HTML or XHTML or into another XML document.
Ver. 1.0
Session 5
Slide 10 of 33
The XSLT processor applies the transformation information to the source document and builds the result tree as shown in the following figure.
XSLT processor
Result tree
XML document
Source tree
Ver. 1.0
Session 5
Slide 11 of 33
Ver. 1.0
Session 5
Slide 12 of 33
Ver. 1.0
Session 5
Slide 13 of 33
Ver. 1.0
Session 5
Slide 14 of 33
Instructs the XSLT processor to process the information for each instance of the specified pattern. Follows the syntax: <xsl:for-each select="pattern"> [action to be performed] </xsl:for-each>
Ver. 1.0
Session 5
Slide 15 of 33
Sorts data based on the values assigned to elements and attributes. Follows the syntax: <xsl:sort select="expression" order="ascending | descending" case-order="upper-first | lower-first data-type="text | number | qname"/>
Ver. 1.0
Session 5
Slide 16 of 33
Generates constant text in the output and displays labels. Follows the syntax: <xsl:text> Text to be displayed as label </xsl:text>
Ver. 1.0
Session 5
Slide 17 of 33
Ver. 1.0
Session 5
Slide 18 of 33
Session 5
Slide 19 of 33
The XSL-FO objects provides a logical layout to an XML document. The content of an XML document can be split into pages. These pages are divided into following four areas:
Regions: Are the topmost areas in the page. Block areas: Are the block level elements. Line areas: Contain the text within the block areas. Inline areas: Are part of line areas.
Ver. 1.0
Session 5
Slide 20 of 33
The XSL-FO properties specifies the type of formatting that can be specified on the XSL-FO objects. Consider the following code-snippet: <fo:simple-page-master master-name="right"> <fo:region-body margin-left="5in" margin-right="2in"/> </fo:simple-page-master> This element defines a template
with the name right. This specifies that the left margin of the template is set to 5 inches. This specifies that the right margin of the template is set to 2 inches.
Ver. 1.0
Session 5
Slide 21 of 33
A template rule:
Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts:
A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element.
Ver. 1.0
Session 5
Slide 22 of 33
A template rule:
Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts:
A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element.
Ver. 1.0
Session 5
Slide 23 of 33
A template rule:
Describes how an XML element and its contents are converted into a specific format for displaying in the browser. Consists of two parts:
A pattern that identifies an XML element in an XML document. An action or processing code that details the transformation and rendering of the resulting element.
Ver. 1.0
Session 5
Slide 24 of 33
Problem Statement:
CyberShoppe needs to display product details, such as product ID, name, and price per unit. The following figure depicts a sample output.
Ver. 1.0
Session 5
Slide 25 of 33
The various departments of a university store data in different formats. The IT department of the university decides to use XML as the data interchange format to transmit the data between the departments. Which of the following would be the best approach to accomplish the task using XML?
a. Devise a common information model and enforce its use by all the departments that need to exchange data. b. Implement a conversion application that can handle the data received from other departments.
Ver. 1.0
Session 5
Slide 26 of 33
c. Use an XSLT style sheet to convert the incoming or outgoing XML document into the format used within the departments. d. Modify the XML schema to use the same content model in all departments.
Answer:
c. Use an XSLT style sheet to convert the incoming or outgoing XML document into the format used within the departments.
Ver. 1.0
Session 5
Slide 27 of 33
Which of the following code snippets can be used in an XML document named Test.xml to associate it with a style sheet named Test.css?
a. <?xml-stylesheet href="Test.css" type="text/css"?> b. <?xml-stylesheet href="Test.xsl" type="text/css"?> c. <?xmlstylesheet href="Test.css" type="text/xsl"?> d. <xml-stylesheet href="Test.css" type="text/css"/>
Answer:
a. <?xml-stylesheet href=Test.css type=text/css?>
Session 5
Ver. 1.0
Slide 28 of 33
Consider the following statements: Statement A: CSS can be used to reorder, add, delete, or perform other operations on elements. Statement B: CSS uses less memory when compared to XSLT. Which of the following is correct about the preceding statements?
a. b. c. d. Statement A is True, and Statement B is False. Statement A is False, and Statement B is True. Both, Statement A and Statement B, are True. Both, Statement A and Statement B, are False.
Answer:
b. Statement A is False, and Statement B is True.
Ver. 1.0
Session 5
Slide 29 of 33
Answer:
d. xsl:choose
Ver. 1.0
Session 5
Slide 30 of 33
Consider the following statements: Statement A: XSLT is a superset of the CSS functionality. Statement B: XSLT is an application of XML. Which of the following is correct about the preceding statements?
a. b. c. d. Statement A is True, and Statement B is False. Statement A is False, and Statement B is True. Both, Statement A and Statement B, are True. Both, Statement A and Statement B, are False.
Answer:
c. Both, Statement A and Statement B, are True.
Ver. 1.0
Session 5
Slide 31 of 33
CSS is used to define the style or appearance of an XML document. XSL is made up of XSLT and XPath. XSLT is used to display selective elements or attributes, sort data on one or more elements, and process the data based on conditions.
Ver. 1.0
Session 5
Slide 32 of 33
The XSLT processor applies the transformation information contained in the XSLT style sheet and builds a resultant tree structure, which is then rendered to various targets. XSLT elements, such as template, apply-templates, sort, for-each, and value-of are used to extract and format data. XSL-FO provides formatting objects to break XML documents into pages, paragraphs, and lists. The associated properties of the formatting objects allow you to format the XML documents. A template rule describes how an XML element and its contents are converted into a format that can be displayed in the browser.
Ver. 1.0
Session 5
Slide 33 of 33