Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Capture process XML variable in XSLT template?

Avatar

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
BjornEricsson1
Level 3

Likes

2 likes

Total Posts

48 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
BjornEricsson1
Level 3

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)

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,127 likes

Total Posts

6,121 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,127 likes

Total Posts

6,121 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

26-08-2019

ashu4pmamjb54261515Mayank Gandhi   Any suggestions?

Avatar

Avatar
Validate 1
Level 2
lsmurph
Level 2

Like

1 like

Total Posts

42 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Validate 1
Level 2
lsmurph
Level 2

Like

1 like

Total Posts

42 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Boost 1
Affirm 3
Affirm 1
View profile
lsmurph
Level 2

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>