This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: CONTEST: How to implement "templates"? ;-)
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 9 Sep 2002 09:36:34 +0100
- Subject: RE: [xsl] CONTEST: How to implement "templates"? ;-)
- Reply-to: xsl-list at lists dot mulberrytech dot com
> Here is a contest for those with too much time (you can
> only win the honor to be the one who came up with the
> best solution ;-):
>
> How can one implement "templates" with XSLT?
>
> Explanation:
>
> I have a XML file data.xml which contains lots of useful info:
>
> <root>
> <info id="info1">
> <title>This is the title of info1</title>
> ...
> </info>
> <info id="info2">
> ...
> </info>
> ...
> </root>
>
> Then I have a file layout.xml which descibes the layout of the
> result:
>
> <layout>
> <html>
> <head>
> <title><put-title-here/></title>
> </head>
> <body>
> ...
> </body>
> </html>
> </layout>
>
> And now the task: Write an XSLT script which creates one
> HTML page for every /root/info element in data.xml and
> uses the layout from layout.xml. Or to put it a different
> way: How can I control how the XSLT processor processes one
> file from another XML file?
>
The best solution to this, in my view, is to write a stylesheet that
converts layout.xml into an XSLT stylesheet, and then applies that
stylesheet to data.xml.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list