BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Welcome to all the Students > Tutorial

Tutorial Teach,Learn,Share,Discuss and Do everything other than Class Lectures


Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
Old 13-09-2008, 09:16 PM   #1
What is XSL?
BSIT07-01 BSIT07-01 is offline 13-09-2008, 09:16 PM
Rating: (1 votes - 4.00 average)

What is XSL?

XSL is a language for expressing style sheets. An XSL style sheet is, like with CSS, a file that describes how to display an XML document of a given type. XSL shares the functionality and is compatible with CSS2 (although it uses a different syntax). It also adds:
  • A transformation language for XML documents: XSLT. Originally intended to perform complex styling operations, like the generation of tables of contents and indexes, it is now used as a general purpose XML processing language. XSLT is thus widely used for purposes other than XSL, like generating HTML web pages from XML data.
  • Advanced styling features, expressed by an XML document type which defines a set of elements called Formatting Objects, and attributes (in part borrowed from CSS2 properties and adding more complex ones.
How Does It Work?

Styling requires a source XML documents, containing the information that the style sheet will display and the style sheet itself which describes how to display a document of a given type.
The following shows a sample XML file and how it can be transformed and rendered. The XML file


PHP Code:
<scene>
  <
fx>General Road Building noises.</fx>
  <
speech speaker="Prosser">
    
Come off it Mr Dentyou can't win
    you know. There'
s no point in lying
    down in the path of progress
.
  </
speech>
  <
speech speaker="Arthur">
    
I've gone off the idea of progress.
    It'
s overrated
  
</speech>
</
scene
This XML file doesn't contain any presentation information, which is contained in the stylesheet. Separating the document's content and the document's styling information allows displaying the same document on different media (like screen, paper, cell phone), and it also enables users to view the document according to their preferences and abilities, just by modifying the style sheet.
The Stylesheet

Here are two templates from the stylesheet used to format the XML file. The full stylesheet (which includes extra information on pagination and margins) is available.

...
PHP Code:
<xsl:template match="FX">
  <
fo:block font-weight="bold">
    <
xsl:apply-templates>
  </
xsl:apply-templates>
</
fo:block>

<
xsl:template match="speech[@speaker='Arthur']">
  <
fo:block background-color="blue">
    <
xsl:value-of select="@speaker">:
    <
xsl:apply-templates>
  </
xsl:apply-templates>
</
xsl:value-of
... The stylesheet can be used to transform any instance of the DTD it was designed for. The first rule says that an FX element will be transformed into a block with a bold font. is a recursive call to the template rules for the contents of the current element. The second template applies to all speech elements that have the speaker attribute set to Arthur, and formats them as blue blocks within which the value speaker attribute is added before the text.
Rendering

The figure below shows a rendering of the Formatting Objects generated by the XML file and the stylesheet. The XSL-FO vocabulary is designed to be displayed on a wide variety of media: screen, paper, or even voice. The full PDF document is also available.


Frequently Asked Questions

How is XSL different from CSS?
XSL uses a XML notation, CSS uses its own. In CSS, the formatting object tree is almost the same as the source tree, and inheritance of formatting properties is on the source tree. In XSL, the formatting object tree can be radically different from the source tree, and inheritance of formatting properties is on the formatting object tree. Most modern Web browsers support both CSS and XSLT; there are also many stand-alone XSLT implementations.
Will XSL replace CSS?
No. They are likely to co-exist since they meet different needs. XSL is intended for complex formatting where the content of the document might be displayed in multiple places; for example the text of a heading might also appear in a dynamically generated table of contents. CSS is intended for dynamic formatting of online documents for multiple media; its strictly declarative nature limits its capabilities but also makes it efficient and easy to generate and modify in the content-generation workflow. So they are two different tools; for some tasks, CSS is the appropriate choice and for some tasks, XSL. They can also be used together - use XSL on the server to condense or customize some XML data into a simpler XML document, then use CSS to style it on the client.
How is XSL different from DSSSL? From DSSSL-O?
DSSSL is an International Standard style sheet language. It is particularly used for formatting of print documents. DSSSL-O is a profile of DSSSL which removes some functionality and adds capabilities to make it more suited for online documentation. XSL draws on DSSSL and the DSSSL-O work and continues the trend towards a Web-oriented style sheet language by integrating experience with CSS.
Will XSL replace DSSSL?
DSSSL has capabilities that XSL does not, and continues in use in the print publishing industry. Experience with XSL might be used in a future revision of DSSSL, but it is too early to say.
So, CSS is for HTML and XSL is for XML?
No, CSS can be used with HTML and also with XML, provided that the XML document has a reasonably linear structure that can be displayed without extensive manipulation. See the CSS2 Recommendation for details. XSL is targeted at XML, in particular highly-structured, data-rich documents that require extensive formatting.
Should I render all my XML documents to HTML on the server?
Unless you are very careful to retain semantics, no. XSL can be used server-side and client-side. The XSL Submission has two classes of output: DSSSL-style flow objects and HTML tags. Unfortunately, the combination of server-side processing and HTML tag output can result in completely inaccessible, hard to search, hard to index presentational HTML (the sort that is a mass of FONT and BR tags, spacer gifs - you know, the sort of single-shot presentational mess that style sheets were designed to avoid). The trouble is that by "rendering" to HTML, all that remains of your carefully crafted XML semantics are the presentational aspects - block element, this font, that weight - which makes it hard to generate decent HTML.
Technical: how do I do X, Y or Z in XSL?
First, have a look at D. Pawson's excellent XSL FAQ. If you don't find an answer, check the XSL mailing list at mulberrytech.com


 
BSIT07-01's Avatar
BSIT07-01
Addicted to Computer


Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
Views: 1673
Reply With Quote
Reply

Tags
xsl


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 03:59 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.