Using <with-param> in <xsl:apply-templates> (and not in <xsl:call-templates/>)
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 15
- Joined: Fri Mar 29, 2019 12:25 am
Using <with-param> in <xsl:apply-templates> (and not in <xsl:call-templates/>)
Hello,
I am transforming an XML-TEI document and want to pass on some parameters. It works in <xsl:call-template>, but not in <xsl:apply-templates/> with a @mode.
Oxygen version: <oXygen/> XML Editor 21.1, build 2019120214
Saxon HE 9.8.0.12
the following templates do not
The template works so far that <hi/> elements are replaced, but the parameters are not passed on, and instead of a copy-of $p, I get only
If I have an <xsl:call-template/> with parameters,
I have the right results
Is there a mistake or is it a bug?
I am transforming an XML-TEI document and want to pass on some parameters. It works in <xsl:call-template>, but not in <xsl:apply-templates/> with a @mode.
Oxygen version: <oXygen/> XML Editor 21.1, build 2019120214
Saxon HE 9.8.0.12
the following templates do not
Code: Select all
<xsl:template match="p" mode="add-facs">
<xsl:variable name="p" select="."/>
<xsl:variable name="coord" select="someSelection"/>
<<xsl:choose>
<xsl:when test="pb">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates mode="add-facs">
<xsl:with-param name="p" select="$p"></xsl:with-param>
<xsl:with-param name="coord-toBe-Used" select="$coord"></xsl:with-param>
</xsl:apply-templates>
</xsl:copy>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
<xsl:template match="hi" mode="add-facs">
<xsl:param name="p"></xsl:param>
<xsl:param name="coord"></xsl:param>
<testElement>
<xsl:copy-of select="$p"></xsl:copy-of>
<xsl:copy-of select="$coord-toBe-Used"></xsl:copy-of>
</testElement>
</xsl:template>
Code: Select all
<testElement xmlns="" xmlns:tei="http://www.tei-c.org/ns/1.0"> </testElement >
Code: Select all
<xsl:template match="p" mode="add-facs">
<xsl:variable name="p" select="."/>
<xsl:choose>
<xsl:when test="pb">
<xsl:variable name="coord-toBeUsed" select="someSelection"/>
<xsl:copy>
<xsl:call-template name="add-facs">
<xsl:with-param name="p" select="$p"></xsl:with-param>
<xsl:with-param name="coord" select="$coord"></xsl:with-param>
</xsl:call-template>
</xsl:copy>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
<xsl:template name="add-facs">
<xsl:param name="p"></xsl:param>
<xsl:param name="coord-toBe-Used"></xsl:param>
<testElement>
<xsl:copy-of select="$p"></xsl:copy-of>
<xsl:copy-of select="$coord-toBe-Used"></xsl:copy-of>
</testElement>
</xsl:template>
Code: Select all
<testElement xmlns="" xmlns:tei="http://www.tei-c.org/ns/1.0">
<p xmlns="http://www.tei-c.org/ns/1.0" part="N">
<pb n="4r" facs="#BnF_fr_1_zone1"/> [...] </p>
[someSelection]
</testElement>
-
- Posts: 9420
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Using <with-param> in <xsl:apply-templates> (and not in <xsl:call-templates/>)
Hi,
This should work also when you have templates in various modes.
Here's what I'm testing on my side:
XML:
XSL:
You can also use Oxygen's XSLT debugger to get a better idea about how various templates are called.
Regards,
Radu
This should work also when you have templates in various modes.
Here's what I'm testing on my side:
XML:
Code: Select all
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<text>
<body>
<p>Some <pb/>
text <hi>HI THERE</hi>here.</p>
</body>
</text>
</TEI>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
version="2.0">
<xsl:template match="/">
<xsl:apply-templates mode="add-facs"/>
</xsl:template>
<xsl:template match="p" mode="add-facs">
<xsl:variable name="p" select="."/>
<xsl:variable name="coord" select="someSelection"/>
<xsl:choose>
<xsl:when test="pb">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates mode="add-facs">
<xsl:with-param name="p" select="$p"></xsl:with-param>
<xsl:with-param name="coord-toBe-Used" select="$coord"></xsl:with-param>
</xsl:apply-templates>
</xsl:copy>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
<xsl:template match="hi" mode="add-facs">
<xsl:param name="p"></xsl:param>
<xsl:param name="coord"></xsl:param>
<testElement>
<xsl:copy-of select="$p"></xsl:copy-of>
<xsl:copy-of select="$coord"></xsl:copy-of>
</testElement>
</xsl:template>
</xsl:stylesheet>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service