IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: trujillostm
About
User Name: trujillostm
Forum Rank: Newbie
Real Name:
Location
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Saturday, August 19, 2017
Last Visit: Saturday, August 19, 2017 1:01:31 PM
Number of Posts: 1
[0.01% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: XSL Transformation Solution
Posted: Saturday, August 19, 2017 12:42:42 PM
In my mapping project, I have a xsd based on this xml structure for source. Note the capitalized node names and attribute values:

<ROOT>
<INPUT>
<NODEA
ATT1="xxx"
ATT2="xxx" />
<NODEB
ATT1="xxx"
ATT2="xxx" />
</INPUT>
</ROOT>

And other xsd based on this xml for target. Note the lowercase names and element values:

<operation>
<input>
<nodea>
<att1>xxx</att1>
<att2>xxx</att2>
</nodea>
<nodeb>
<att1>xxx</att1>
<att2>xxx</att2>
</nodeb>
</input>
</operation>

How can I get an XSL transformation, grouping by tree nodes, similar like this, with Altova MapForce 2017? Note the node comments and the name of variables:

<xsl:template match="/ROOT">
<operation>
<input>
<xsl:for-each select="INPUT">
<!-- NODEA -->
<xsl:for-each select="NODEA">
<!-- ATT1 -->
<xsl:for-each select="@ATT1">
<xsl:variable name="v_ATT1" select="."/>
<att1>
<xsl:value-of select="string($v_ATT1)"/>
</att1>
</xsl:for-each>
<!-- ATT2 -->
<xsl:for-each select="@ATT2">
<xsl:variable name="v_ATT2" select="."/>
<att2>
<xsl:value-of select="string($v_ATT2)"/>
</att2>
</xsl:for-each>
</xsl:for-each>
<!-- NODEB -->
<xsl:for-each select="NODEB">
<!-- ATT1 -->
...
<!-- ATT2 -->
...
</xsl:for-each>
</xsl:for-each>
</input>
</operation>
</xsl:template>

The Altova MapForce creates this different solution:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_initial" select="."/>
<operation xmlns="...">
<xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">... file:///...xsd</xsl:attribute>
<input>
<xsl:for-each select="*[local-name()='ROOT' and namespace-uri()='']">
<xsl:variable name="var2_cur" select="."/>
<att1>
<xsl:value-of select="*[local-name()='INPUT' and namespace-uri()='']/*[local-name()='NODEA' and namespace-uri()='']/@ATT1"/>
</att1>
...
</xsl:for-each>
</input>
</operation>
</xsl:template>
</xsl:stylesheet>

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.