Since XSLT has started winning the war against XPathScript and since I
have had to hack XPathScript to get it to do what I want, I am considering
making the move to XSLT but have to validate that I can do what I need to.
Essentially we have a component driven site. Each part of a page is
described by a separate XML file plus there are XML files that relate to
the url that is being accessed, we call these the primary page.
eg
we have xml files for primary pages: /home/index.xml, /home/signin.xml
etc
and
we have xml files for components: /components/menu.xml,
/components/header.xml etc
Any primary page xml or component xml file can "require" (by means of
<include/> tags that another component is loaded. The various component
xml files are then combined to form one long XML file that is first
processed by XSP and then by XPathScript.
Each component that was loaded has a stylesheet attached to it and I have
hacked XPathScript to process each component with its own stylesheet.
so the XML document looks a bit like this...
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="application/x-xsp" href="."?
<?xml-stylesheet type="application/x-xpathscript"
href="/stylesheets/main.xps"
?>
<xsp:page...>
<page>
<home>
<index stylesheet="home.xsp">
.. contents of home/index.xml...
</index>
</home>
<components>
<header stylesheet="header.xsp">
.. contents of header.xml..
</header>
<menu stylesheet="menu.xsp">
.. contentns of menu.xml..
</menu>
<footer stylesheet="footer.xsp">
.. contentns of menu.xml..
</footer>
</components>
</page>
</xsp:page>
---------
Then after the XSP processing, XPathScript uses the main.xps file to
transform this page. The stylesheet looks like this..
<html>
<body>
<%= insert("/components/header"); %>
<table>
<tr>
<td>
<%= insert("/components/menu"); %>
</td>
<td>
<%= insert($AxKit::Apache::request->uri); %>
</td>
</tr>
</table>
<%= insert("/components/footer"); %>
</body>
</html>
-----
The insert() method takes an XPATH as a parameter and attempts to locate
the node from the XPATH and then applies the stylesheet specified by the
stylesheet= attribute.
The beauty of this is that the stylesheet is not "loading" components.
Everything is compiled in advance. The stylesheet simply determines where
things go and what they should look like. It also allows us to assign
stylesheets to each component of a page and keep things well structured.
--------------
My first question is,
Is there a way to do this using XSLT?
I've seen Barrie Slaymakers tutorial on XSP, Taglibs and Pipelines
(http://www.perl.com/pub/a/2002/04/16/axkit.html) which shows an example
pipeline where a weather report goes through 2 XSLT transformations, first
transforming the weather XML and then laying out the whole page. What
happens when you want to pull in a header.xml and footer.xml and have
them rendered by separate XSL stylesheets, ideally with the results of
individual components being cached so that only "dynamic" components of
the page are regenerated each time.
The way I pull together the various "components" of the page is through
the use of a custom apache handler that runs prior to AxKit as part of a
Apache::Filter chain. I've thought that maybe it would be better to use an
AxKit Provider handler to do this but I cant find much info about making
Providers.
Ideally it would be nice to be able to do this.
1) Request comes in for somefile.xml
2) Something decides that somefile.xml, header.xml, menu.xml, footer.xml
are all required components.
3) It is determined that footer.xml also requires submenu.xml.
4) All 5 components are processed by XSP (in a given order) and cached
where possible.
5) The resulting xml of the 5 components are then processed by their
individual stylesheets. (which ideally inherit from the main page's
stylesheet, in this case somefile.xml ) submenu should be transformed
and included in a nested fashion within the footer.
The results of the 4 components are combined in 1 XML document that might
look like this...
<?xml.. ?
<data>
<!--various stuff about the page-->
<url></url>
<colour></colour>
<component href="/somefile.xml" primary>
(cached) html output of somefile.xml transformed by somefile.xsl
</components>
<component href="/header.xml>
(cached) html output of header.xml transformed by header.xsl
</component>
<component href="/menu.xml>
(cached) html output of menu.xml transformed by menu.xsl
</component>
<component href="/footer.xml>
(cached) html output of footer.xml transformed by footer.xsl
including the resulting output of submenu.xml transformed by submenu.xsl
</component>
</data>
......................
6) this final page is then transformed by a default xsl stylesheet, say
default.xsl :) which provides the common structure of the page.
Can anyone offer a means of achieving this using XSLT, or an alternative
that offers the same advantages. Namely,
* Components that can be individually defined
* Separate stylesheets for each component, which inherit from the parent
component at run time.
* Ability to drive what appears on the page from at the XSP stage (ie, if
the component is in the XML then its shown, otherwise it isnt. Not the
usual case of pulling in components from the stylesheet)
* Individual caching of components at XSP,XML and final HTML level
any help much appreciated,
Tom Howe
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]