Home xstl apply-template (call tempalate) with variable and use in xsl:evaluate
Reply: 0

xstl apply-template (call tempalate) with variable and use in xsl:evaluate

user3693 Published in May 24, 2018, 3:59 pm

I have the following xml:

<pi:Payroll_Extract_Employees xmlns:pi="urn:com.workday/picof">
         <pi:name>John Andrews</pi:name>

I am using this transformation:

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pi="urn:com.workday/picof">
    <xsl:output method="text"/>
    <xsl:template match="pi:Payroll_Extract_Employees/pi:company">
        <xsl:variable name="tabsNames">
                <spreadSheetName>Payroll Data for Taiwan</spreadSheetName>
                        <header>Chinese Name</header>
        <xsl:variable name="currentNode" select="."/>
        <xsl:for-each select="$tabsNames/entry">
            <xsl:variable name="dataValues" select="values/value/data"/>

            <xsl:call-template name="employeeRows">
                <xsl:with-param name="rows" select="$dataValues" as="element()*"/>
                <xsl:with-param name="currentNode" select="$currentNode" as="element()"/>

    <xsl:template name="employeeRows">
        <xsl:param name="rows" select="."/>
        <xsl:param name="currentNode" select="."/>

        <xsl:for-each select="$currentNode/pi:Employee">
            <xsl:variable name="employee" select="." as="element()"/>
            <xsl:for-each select="$rows">
                <xsl:variable name="path" select="."/>
                    <xsl:evaluate xpath="$employee || $path" context-item="."/>
                    <!--<xsl:value-of select="$employee/pi:name"/>-->


Here I am creating a map $tabNames and the would like to pass map together with current node to employeeRows template. Instead of data values for "rows" parameter I get entire map and instead of current node (pi:Payroll_Extract_Employees/pi:company) for currentNode parameter I receive the same map as for the "rows" parameter. The second problem is that xsl:evaluates changes $employee to a value I would like following to give me the same output

<xsl:evaluate xpath="$employee || $path" context-item="."/>

as this

<xsl:value-of select="$employee/pi:Name"/>

What I have so far throws an error here:

<xsl:evaluate xpath="$employee || $path" context-item="."/>

Error message:

System ID: C:\Users\przemekb\AppData\Local\Temp\Untitled4.xsl Severity: fatal Description: Static error in XPath expression supplied to xsl:evaluate: Unexpected token name "Andrews" beyond end of expression. Expression: { John Andrews 23 4000 Accounting pi:Name} Start location: 36:42 Length: 1

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.385739 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO