Using The For-each Element To Loop in XSLT Stylesheets
Using The For-each Element To Loop in XSLT Stylesheets
XSLT is an XML-related technology which is used to transform XML data. XML files 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 XML 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 elements in an XML file is the the "For-each" element. This requires the "select" attribute to specify which element is to be used in the loop. The "For-each" element normally requires both an opening and a closing tag and any lines of markup 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, let's say we have an XML file containing a list of companies and the addresses of their websites. Let's also say 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 beginning 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 then output an HTML "li" element and, between the opening and closing "li" tags, output the contents of the "name" and "telephone" elements from the XML file. The data in the "website" could then be used to convert the "name" into a clickable link.
As to 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 desire, so our bulleted list can take on pretty much any appearance we desire.
Are you looking for training on InDesign JavaScript? Read InDesign CS5 Automation Using XML and JavaScript by Grant Gamble.
Money Clip Wallets Offer Style And Function Limo hire - Making your way around in Sheer Style Finding A Wallet That Has Both Style And Functionality Designer Ipad Cases At Attractive Prices Dickies Lab Coats Offer Style In The Workplace Style by Industry Who are the top and most famous fashion designers? Canvas prints - a great artwork for memories Round Collared Shirts – the simple clothes with style Efficient Ideas For Intelligent Web Style Web Design – Designing of a Good Banner ITunes: Finding Album Artwork TuneUp Media - Your Essential iTunes Album Artwork Finder
www.yloan.com
guest:
register
|
login
|
search
IP(216.73.216.250) California / Anaheim
Processed in 0.016447 second(s), 5 queries
,
Gzip enabled
, discuz 5.5 through PHP 8.3.9 ,
debug code: 12 , 2228, 99,