Using XML and XSLT for multiple documents with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a home-grown PHP framework that I use for rapid site production
for my clients.  I've been fascinated with XML/XPath/XSLT for quite a
while and with the new XML transformation capabilities packaged with
PHP5 I have decided to rewrite the framework using PHP's DomDocument
and XsltProcessor classes.  Most of the conversion has gone smoothly,
but I have been running into problems combining multiple XML documents
and running them through the XsltProcessor.

The system used to use a custom-written templating engine that breaks
down the XHTML and CSS into Site, Module, and View levels that nest
into one another.  I have a whole collection of classes that are used
as Components (basically classes that handle data-binding from the UI
to the Model and the Database that can render themselves into XHTML). 
So each of the Site, Model, and View can contain Components, and all
of the above can contain links to external CSS files.  I am basically
going through and replacing all of the render() methods and HTML
template files with XML and XSLT files.

There are multiple steps to the rendering process, since a finished
HTML doc can only have one <head> element which must contain all of
the <link>s to the CSS files, which are kept locally by the renderable
classes.  There is a single CSS file to go with the Site, there is one
for each Module, and one for each View, but if any of these contain
components then the HTML for that must be sucked in along with the CSS
link.  All of the <link> elements need to end up in the <head> block
in the finished document, while the cascading HTML snippets need to
end up in the <body> block.

I start by running an XSL Transformation on the Site to pull in the
Site-level Components, then do the same individually for the requested
Module and View.  Right now I am leaving placeholder tags in the
resulting HTML docs so that they can be cross-matched when it is time
to blend these three files into the final page.  This is where I am
stuck.

Of course I could always use PHP string-replacement functions to cut
the files together, but I'd prefer to use the same method all the way
through the rendering (transformation) process.  Is there anybody out
there with experience in this that might be able to point me in the
right direction?  Thanks for your time.

--James Adams
viascape.php@xxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux