How to xsl:apply-templates while xsl:copy-of?
Alain Gilbert <[email protected]>
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'm using xalan-2.7.0 (the same applies to version 2.7.1) and I'd like the transform to apply-templates while copying a set of nodes from the template into the result document. I have attached the print.xsl template. Look at line 18 of print.xsl for the template "addInlineText" declaration and at line 10 for its call. At line 21, how to apply-templates while copying the template parameter? In other words, I'd like the template that match "html:p" to be applied when the template "addField" is called with the parameter "value" with a set of node as value. Is it possible to do it with XSLT 1.0? I'd like to avoid a second pass to apply the html:* templates. Thanks, Alain Gilbert
data.xml
(application/xml, 7 B)
<root/>
print.xsl
(text/xml, 1.5 KB)
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:html="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="html">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" />
<xsl:template name="fragment">
<fo:block>
<xsl:call-template name="addInlineText">
<xsl:with-param name="value">
<html:p>Testing HTML in labels</html:p>
</xsl:with-param>
</xsl:call-template>
</fo:block>
</xsl:template>
<xsl:template name="addInlineText">
<xsl:param name="value" />
<fo:block>
<xsl:copy-of select="$value" />
</fo:block>
</xsl:template>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4"
page-height="29.7cm" page-width="21cm" margin-top="2cm"
margin-bottom="2cm" margin-left="2cm"
margin-right="2cm">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<xsl:call-template name="fragment" />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="html:p">
<fo:block>
<xsl:value-of select="text()"/>
</fo:block>
</xsl:template>
<!-- The identity transformation. -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>