|
Subject: Re: [xsl] transformation does happen after copy-of? From: Mike Brown <mike@xxxxxxxx> Date: Sun, 21 Jul 2002 21:46:35 -0600 (MDT) |
Phillip Rhodes wrote:
> <xsl:template match="html">
> <xsl:copy-of select="."/>
> <xsl:apply-templates/>
> </xsl:template>
copy-of will copy an entire branch of the tree. So you asked for all of
the 'html' element, including its descendants, to be copied verbatim.
Your apply-templates along with the built-in templates sent you down
into the source tree, but your template for whitespace never matched
because you were looking for whitespace[lines] which means whitespace
element having at least 1 lines element child. @lines was what you
meant, but that's not helpful either.
This is the meat of the stylesheet you want -- an identity transform, with
overrides for whitespace elements:
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="whitespace">
<p/>
<p/>
</xsl:template>
I suspect you want the lines attribute of the whitespace element to determine
how many 'p' elements (or 'br' elements inside one 'p', probably) to insert?
In that case, a recursive template (untested, but should do the trick):
<xsl:template match="whitespace">
<p>
<xsl:call-template name="insert-brs">
<xsl:with-param name="num" select="number(@lines)"/>
</xsl:call-template>
</p>
</xsl:template>
<xsl:template name="insert-brs">
<xsl:param name="num"/>
<xsl:if test="$num > 0">
<br/>
<xsl:call-template name="insert-brs">
<xsl:with-param name="num" select="$num - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
- Mike
____________________________________________________________________________
mike j. brown | xml/xslt: http://skew.org/xml/
denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] transformation does happen af, Phillip Rhodes | Thread | Re: [xsl] transformation does happe, Phillip Rhodes |
| [xsl] Query re XMLSpy XPath engine, Michael Leditschke | Date | [xsl] Re: Query re XMLSpy XPath eng, Dimitre Novatchev |
| Month |