Below are the XSLs that we have developed. We tried to use for:each in the XSL but we were not able to map it.
Is there a better way to map using for:each or any other sytnax available.
Here if XMLs have huge repeating data(we have only showed 3 repeatitions) then XSL will become huge. We want to reduce the XSL
Is there a better way of mapping inorder to reduce the size of XSL. Here there are 3 CompanyId and ReservationControlNumber , but it can increase. So our mapping also becomes complex. Please suggest a better approach if any.
Subject:XSL mapping for XMLs having different XML element names in input and output XMLs Author:James Durning Date:12 Jul 2007 02:08 PM
I'm pretty sure I answered this question before, but to restate and put into context of your current xml:
first to second:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<RCI>
<xsl:for-each select="ReservationControlInformationSegment/CompanyId">
<xsl:variable name="number">
<xsl:number format="00"/>
</xsl:variable>
<xsl:variable name="basename">RCI<xsl:value-of select="$number"/></xsl:variable>
<xsl:element name="{concat($basename, '-ReservationControlInformation')}">
<xsl:element name="{concat($basename, '01-CompanyIdentification')}">
<xsl:value-of select="."/>
</xsl:element>
<xsl:element name="{concat($basename, '02-ReservationControlNumber')}">
<xsl:value-of select="following-sibling::ReservationControlNumber[1]"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</RCI>
</xsl:template>
</xsl:stylesheet>
Subject:XSL mapping for XMLs having different XML element names in input and output XMLs Author:James Durning Date:12 Jul 2007 02:29 PM Originally Posted: 12 Jul 2007 02:12 PM
making second to first dynamic is quite a bit uglier:
Again, this is best guess based on what you have provided.
If there are multiple repeating nodes inside your other node, (as hinted by your previous topic) then the xslt might have to change somewhat.