Employing Iteration In XSLT Stylesheets

Extensible Stylesheet Language (XSL) is an XML-related technology which is used to transform XML data. XML file are used to set the ground-rules for a given body of data and to describe the data itself. XSL allows us to take that data and convert it into information which can be displayed in a web browser window or opened with a text editor. It can also be used to create an XML file which is a modified version of an original XML file.

When displaying elements in a browser window, the XSL elements which enable looping through an XML tree and decision-making really come into their own. One of the key methods used in XSL for looping through XML elements is the “For-each” element. This uses the “select” attribute to specify which element is to be targeted in the loop. The “For-each” element has both an opening and a closing tag and any lines of code placed between the opening and closing tags will be repeated each time the element specified in the “select” attribute is encountered in the XML file.

For example, suppose we have an XML file containing a list of companies and the addresses of their websites. Suppose, as well, that the element which we will be targeting in the XSL “For-each” statement is called “company” and that, within each company element, we have a “name”, “telephone” and “website” element. Before starting our “For-each” loop, we could place the opening tag of an HTML “ul” element (an unordered or bulleted list).

Inside the “For-each” loop, we could output an HTML “li” element and, between the opening and closing tag, output the contents of the “name” and “telephone” elements from the XML file. The data in the “website” could be used to convert the “name” into a clickable link.

As for the appearance of the data in the resulting HTML output, this would be controlled by a linked CSS file. CSS can be used to format the output in any way we like, so our bulleted list can take on pretty much any appearance we desire.

You can get up to date information on PHP AJAX training courses, visit Macresource Computer Training, an independent computer training company offering PHP AJAX training courses in London and throughout the UK.

categories: xml,extensible markup language,sgml,pdf,html,web development,tutorial,training,computer software,computers,software programs


Related posts:


  • XML Offers Developers Platform Independent Data Storage Extensible Mark-up Language (XML) has very rapidly established itself as a viable technology with a huge range of real-world applications. One of the main reasons for its growing importance and wide acceptance is the fact that it offers a working solution to one of the key problems faced by software developers and computer users alike: the exchange of incompatible data. Each software program creates its own unique type of binary file which only it can understand. When data is exported in XML format, it becomes a known, clearly defined quantity, independent of the environment in which it was originated....
  • Using XML Schema To Validate XML Documents XML schema definition languages are founded on recommendations laid down by the World Wide Web Consortium (W3C). They use XML 1.0 syntax and aim to explicit describe the structure of XML documents and constrain the data which they may contain. They offer a distinct improvement on the more limited schema features offered by the Document Type Definition (DTD) recommendation which formed part of the original XML specification released in 1998. The most widely used schema language is the one defined by the W3C in 2001: W3C XML Schema. However, there are alternatives, such as RELAX NG and Schematron....
  • Quick Way To Import Extra Large Mysql File Mysql is the number one open-source database management system, which give the programmer or developer a lot of flexibility in managing huge and complex tables of data. This is very enticing to the developer who would like to spit out data on the fly using PHP - open-source, server-side programming language . However, many hosting companies like Godaddy limit the amount mysql will load or import to roughly 2M....
  • Optimized File Hosting Service Only At Jiffy Upload File hosting is fast becoming a crucial requirement so as to accommodate the vast amount of electronic data being produced at a fast pace. The online users now find it more comfortable to upload their favorite image, document or other files on the sites offering simple file hosting services. This is indeed a welcome change and gives the users a sweet respite from flooding their computer hard disks from tones of data....
  • Web Analytics And A Short History About It The main purpose of web analytics is to optimize the web usage. It does so by measuring, collecting, and analyzing the internet data. There are two forms of web analytics, the off-site web analytics, and the on-site web analytics. Both these forms are discussed below....


Share This Post

Related Articles

Leave a Reply

*

Copyright © 2008-2012 One Way Links. All rights reserved.
Powered by WordPress · Designed by Theme Junkie