Topic: XSLT tutorial: Seperating data and style

Return to Archives of Graphic Forums


Antidepressant Medications
Handle stress, elevate the mood,
treat anxiety disorders.
Weight Loss Supplements
Natural supplements that burn body fat,
suppress appetite and support a healthy diet.
Shared Movies
Over 80 Million Movies and TV-Shows
No Charge per movie, No download limit!
Casino Classic
Best Online Casino!
Get $500 free on the house!


Posted at December 13, 1901, 2:45 pm:

XSLT: Seperating data and styl
Assumption
Heading into this tutorial, it's difficult to write without any asusmptions at all. There are parts which only require an understanding of HTML, other parts require an understanding of PHP or MySQL or both. While all of this is useful to know - and this tutorial is aimed at people who are interested in dynamic web-system design - knowledge of PHP and MySQL specifically isn't necesary in order to follow along. Most of what follows is replicable without a server with PHP and MySQL (or any server at all for that matter) thanks to browser support of XSLT rendering
That said, the people who will get the most from this tutorial will have an understanding of PHP (4 or 5), MySQL (or any SQL based relational database), XHTML/HTML and web programming in general
An introductio
XSLT is a language which is used to transform one XML document into another. Some uses to which XSLT is applied in the commercial world are governing transactions, creating SVG documents for various programs (inkscape, illustrator) and in the workings of enterprise level plotters to transform documents into postscript. What the hell do I care about banking, I hear you say?
Remember that XSLT is a language which is used for transforming one XML document into another. One of the most exciting applications of XSLT, and the one that we'll be focusing on here, is the transformation of XML data into XHTML for the web. This is usefull for a great number of reasons, not least of which is the fact that for any given project you may need to represent the same data in a number of different ways. The advantages of seperating style from data is beyond the scope of this tutorial, suffice it to say that it's a good idea; for any dynamic system
Perhaps at this stage an example is in order. Lets say you're creating your brilliant online portfolio (You know, the one that's going to inspire people to pay you in excess of 150k/year). You have a gallery section off this portfolio and instead of manually updating this every time you complete a new job - a tedious task in anyones book - you want to make it dynamic. So, first of all you create your database and PHP code to output a database query as XML. Lets say that the XML data which represents your gallery looks something like

If you have any experience with database technologies of any sort you'll see how this data could have been queried.
So with that XML document (which you'll see again in this tutorial) you would pass it through an XSLT stylesheet document and out would pop valid XHTML strict code which would render tothe users browser.
The advantages in this case would be that we could use the same data to represent a menu view, a multiple item view or a single item view without having to repeatedly query the database or write complex PHP parsers to represent different data on our website
Advantages of XSL
XSLT makes development of complex systems quicker by providing a way to develop the system responsible for data generation and the system responsible for rendering completely seperate. Create the data system first and never touch it again
In Java and PHP, XSLT is much quicker to render than regular print calls(PHP) or regular JSP(Java). Any of you who have experience with PHP4 will say; "how is this so?! XML is so slow?". This is true to a point, at least until you consider how fast XSLT parsing is when compared to slow and cumbersome print - or worse; echo - calls. This is greatly improved in PHP5, which provides far better XMLDom support
XSLT is easy to understand for anybody with experience of XML/XHTML. The syntax is essentually XML
And most importently, XSLT provides a way to seperat data from style. This makes it increibly flexible, extensible and very solid
Till next time... 2. Basic XSLT clientside example.

Original of the message was taken from http://www.graphic-forums.com/

Replies:

XSLT 2: XSLT on the client Lions and tigers and bears.

XSLT 3: XSLT and PHP5 A syntax for passing XSLT serverside.

XSLT 4: Introduction to XPath; retrieving nodes, attributes and meta-d...

XSLT 5: Looping, conditions and templates.

Reserved for - Advanced XSLT examples; Recursive template calls

thanx seems nice

Very very informative.


Other Topics of Graphic Forums:

...unable...

Best movies?

Some Of My Work

The Three Days Grace Mural

alooha! ;)

1

Centering

Halloween Vector

Hi!

Photo Help!

rat t-shirt

Breast Implants save life!

GF vs INOSTEVE 06 (IMAGES ONLY)

1

1

Take a look

Turning objects / humans into gold

Inspirational Blog - Designmensch.com

15 Min sig

another picture as fill in a logo

Mac to Windows Switch

New Verizon Billboard Advertisement

3D Radio Car

1

Panic: keerisen

1

W.i.p.

graphics in interior designing

mllanes

Load a Movie file in Flash ?

Goodbye everyone (and thanks for all the fish)

Sherbys Binding Book Thread

Creatures in the woods

Wish Me Luck!

Got a problem here

hey

sub7th vs Wendy W

pantone colour: spot or process

10 Deep Mock Clothing Ad

Qtvr

Photo Greeting Cards

The Adventurer


File Sharing Service  Image Sharing Service  Usenet Newsgroups Reader
Guide to Serials and Shows  English Subtitles For DivX Movies  Lyrics Catalogue
Over 5000 Cocktail Recipes  Hot News Archive  Funny Jokes and Anecdotes
Cooking Recipes Catalogue  Cool Online Encyclopedia  Computer Games Cheats
Pets Department  Spam Free Guestbook Service  Medical Catalogue


Free Web Stats