On Saturday, February 8, 2003, at 09:00 AM, Matt Sergeant wrote:
A strange XSLT thing is bugging me...That's a feature actually :-) Since it means that you'll always get valid XML as your output.
In XPathScript because it's not XML I can create unbalanced component pieces, so I can basically have:
1. TOP BIT
2. CUSTOM Per-Page BIT
3. content
4. CUSTOM Per-Page BIT
5. BOTTOM BIT
I can't do that in XSLT because everything has to be balanced (xml tag wise).
Yeah, but at the moment it's not how I'm doing it. I'm trying to avoid import and include since they create a strong coupling and therefore reduce reusability. Instead I've been using pipelining to acheive similar effects. Take this (heavily stripped) example from my new site, openict.net (btw, all the code is in SF.net cvs)So the question is - does this work?
index.html
------------------------------------------------------
<?xml-stylesheet type="text/xsl" href="/xsl/site.xsl" ?>
<page>
<title>OpenICT.net</title>
<xhtml>
<h1>Welcome to OpenICT.net</h1>
<p>yadayadayada</p>
</xhtml>
</page>
------------------------------------------------------
site.xsl
------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="sitemenu" select="document('//inc/sitemenu.inc')"/>
<xsl:template match="/page">
<html lang="en">
<xsl:call-template name="headTemplate"/>
<body>
<xsl:apply-templates select="$sitemenu"/>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!--process source XML-->
<xsl:template match="/page/title">
</xsl:template>
<xsl:template match="/page/xhtml">
<xsl:copy-of select="*"/>
</xsl:template>
<!--process document() XML-->
<xsl:template match="sitemenu">
<div id="sitemenu">
<!--[[xsl:apply-templates select="menu/title"/]]-->
<ul>
<xsl:apply-templates select="menu/item"/>
</ul>
</div>
</xsl:template>
<xsl:template match="menu/title">
<p><b><xsl:value-of select="."/></b></p>
</xsl:template>
<xsl:template match="menu/item">
<li><a href="{@url}"><xsl:value-of select="."/></a></li>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------------
Now that axkit: is solid, I'm going to actually switch to this:
<xsl:variable name="sitemenu" select="document('axkit://inc/sitemenu.inc')"/>
and do the processing of that document in a separate xslt that's PI'd from sitemenu.inc ... giving even more code abstraction yay! :-)
Notice also I don't even have a root-only template for "/" ... you don't need one, since I've got two source docs here it's safer to leave it out.
simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
