xsl-list
[Top] [All Lists]

RE: CONTEST: How to implement "templates"? ;-)

2002-09-09 01:36:34
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(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com  


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>