This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
excluding nodes from an xsl template
- To: XSL-List at mulberrytech dot com
- Subject: excluding nodes from an xsl template
- From: Kevin dot Hooke at iint dot com
- Date: Fri, 7 Jul 2000 08:33:22 -0700
- Reply-To: xsl-list at mulberrytech dot com
Hi - we need an XPATH expression for an XSL template that selects a set of nodes
from an XML document, but excludes some nodes from the results.
We are using this to transform an XHTML document to different outputs for
different devices, eg, HTML, WML, simple (HTML3.2) HTML etc. We are using Cocoon
to provide the XSLT transformation engine.
For example - if this is the XHTML:
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="../xsl/test_default.xsl" type="text/xsl"?>
<html>
<head>
<title>DM Work Management Logon</title>
</head>
<link rel="stylesheet" type="text/css" href="../css/style5.css"></link>
<body>
<xsp>
//do some java XSP here...
</xsp>
<p>some text in the page etc</p>
</body>
</html>
... and this is our default stylesheet that if the client is an HTML4.0 browser,
the XHTML is copied through to the output almost as is:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="* | text() | @*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
.... our problem is that if we embed XSP for dynamic content into our source
XHTML, then this content is being copied through to the output as well, andwe
need to exclude this output.
So we need to modify the template match pattern to exclude nodes like <xsp> from
the results set.
We've already tried things like
- <xsl:template match="* and self::not(xsp)">
- <xsl:template match="* and not(xsp)">
- <xsl:template match="node() and not(xsp)">
I think we're looking along the right lines, but we're struggling with the xpath
syntax for the match we need.
Can anyone help....!
Thanks,
Kevin Hooke
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list