Re: [xsl] xsl/xslt coding standard

Subject: Re: [xsl] xsl/xslt coding standard
From: Steve Ball <Steve.Ball@xxxxxxxxx>
Date: Mon, 19 Aug 2002 10:44:37 +1000
Hi Jeni,

You wrote:
If exclude-result-prefixes works OK, why introduce something new?

exclude-result-prefixes doesn't work OK, or at least it doesn't work OK if (a) you want to put documentation *within* templates and (b) you don't want to have to nest it inside an instruction that guarantees it won't be processed [such as an xsl:if test="false()" or an xsl:for-each select="/.."].

OK. I understand the problem now.


How about another approach to the problem?  Generalise the
whitespace stripping process to also strip nominated
elements?  This may even have the benefit of improving
runtime performance by not having to skip over embedded
documentation elements during processing.

Proposal: In addition to <xsl:strip-space>, allow <xsl:strip-nodes>
This element requires a 'select' attribute.  Any node matching the
XPath expression given by the 'select' attribute is stripped
from the stylesheet, including its descendants.  The default
value is 'processing-instruction()|
text()[string-length(normalize-space()) = 0]'.  xsl:strip-space
and xsl:preserve-space modify the nodes to be stripped in the
obvious manner.

For example, to specify that embedded DocBook elements get
stripped:

<xsl:stylesheet version='1.0'
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:doc='http://www.docbook.org/documentation/1.0'>

<xsl:strip-nodes select='doc:book|doc:article'/>

  <xsl:template match='/'>
    <p>This appears in the result</p>
    <doc:book xmlns=''>
      <title>Embedded Doco</title>
      <p>This does not appear in the result</p>
    </doc:book>
  </xsl:template>

</xsl:stylesheet>

--
Steve Ball            |   XSLT Standard Library   | Training & Seminars
Zveno Pty Ltd         |     Web Tcl Complete      |   XML XSL Schemas
http://www.zveno.com/ |      TclXML TclDOM        | Tcl, Web Development
Steve.Ball@xxxxxxxxx  +---------------------------+---------------------
Ph. +61 2 6242 4099   |   Mobile (0413) 594 462   | Fax +61 2 6242 4099


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



Current Thread