Rank: Newbie
Joined: 8/19/2017 Posts: 1
|
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>
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 564
|
First, you can't influence MapForce's generated XSLT to that extent. MapForce will generate the XSLT necessary to create the output you see in its' Output Preview view. If it's not necessary to wrap every level in a for-each, MapForce won't do that, and the same goes for variables.
|