Capture process XML variable in XSLT template?

BjornEricsson1

28-04-2017

I can't figure out how to capture an AEM Forms process XML variable and use it in an XSLT template. The capture part works, but somehow the processor removes the tags in the variable and only outputs the values (1 2 3) as if I would have used value-of instead of copy-of. Using a local variable as a reference works fine.

This is my XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="insertedXML"><insert_data>1</insert_data></xsl:variable>
<xsl:variable name ="dummyXML">'{$/process_data/BlankettXML$}'</xsl:variable>

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="FormSpecifics">
    <xsl:copy-of select="$dummyXML"/>
    <xsl:apply-templates select="node()|@*"/>
</xsl:template>

<xsl:template match="/*/*/*[last()]">
    <xsl:copy> 
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
    <xsl:copy-of select="$insertedXML"/>
</xsl:template>

 

This is my input:
<ContainerRoot>
<DocumentList>
    <Document name="second">
        <FormRef>2222_2</FormRef>
        <FormSpecifics>
            <name>Björn</name>
            <date>2017-01-01</date>
        </FormSpecifics>
    </Document>
    <Document>
        <FormSpecifics>
            <address>Home street 12</address>
            <zip>123 45</zip>
            <state>Alabama</state>
        </FormSpecifics>
    </Document>
</DocumentList>

 

This is my process variable (blankettXML)
    <insert_root>
        <insert_data>1</insert_data>
        <insert_data>2</insert_data>
        <insert_data>3</insert_data>
    </insert_root>


This is my output:
    <ContainerRoot>
    <DocumentList>
        <Document name="second">
            <FormRef>2222_2</FormRef>
              1  2  3
                <name>Björn</name>
                <date>2017-01-01</date>

        </Document>
        <Document>
              1  2  3
                <address>Home street 12</address>
                <zip>123 45</zip>
                <state>Alabama</state>

        </Document>
<insert_data>1</insert_data>
    </DocumentList>
</ContainerRoot>


How would you solve this?

Accepted Solutions (0)

Answers (2)

Answers (2)

lsmurph

12-10-2018

Were you able to solve this problem? Is it possible to pass process variables to an xslt transform activity in AEM Workbench? If I hard code inDepartment I get results but the below code returns nothing.

<xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output omit-xml-declaration="yes" indent="yes"/>

    <xsl:strip-space elements="*"/>

<xsl:variable name ="inDepartment">'{$/process_data/@inDepartment$}'</xsl:variable>

    <xsl:template match="/MunisInfo">

      

        <xsl:copy>

            <xsl:copy-of select="MunisOrg[Department = $inDepartment]/OrgCode"/>

        </xsl:copy>

    </xsl:template>

</xsl:stylesheet>