xsl-list
[Top] [All Lists]

Re: [xsl] Copy-per-default

2011-04-20 10:57:58
Fredrik Bengtsson wrote:

<xsl:template match="/d:book">
   <!-- ignoring root, page-sequence etc for brevity -->
   <xsl:apply-templates />
</xsl:template>

<xsl:template match="d:chapter">
   <xsl:apply-templates />
</xsl:template>

<xsl:template match="d:chapter/d:title">
   <fo:block>  ... ...</fo:block>
</xsl:template>


Then for some reason the titleabbrev appears in the output even though I have 
not made any rule explicitly matching it. It is caught along with the title 
inside the apply-templates under d:chapter. I thought that this would not 
happen, unless I really added a matching template of some sort, for example an 
identity transform.

Well in your template for chapter you do apply-templates meaning you process all child nodes. Then there is a built-in template that does the same for any element nodes not having a template in your stylesheet and there is a built-in template for text nodes that does xsl:value-of, thus the contents of the titleabbrev is copied to the output.

You can remedy this by either only selecting the title element with your apply-templates in the chapter template

<xsl:template match="d:chapter">
  <xsl:apply-templates select="d:title"/>
</xsl:template>

or by suppressing text output with

  <xsl:template match="text()"/>


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>