Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging data from 2 XSLT files

Status
Not open for further replies.
Dec 11, 2009
60
US
I have the below scenario:

RA......
RE......
RW......

All my RW information lists and then my

RS....

This is what I need the file to print out as

RA....
RE....
RW....
RS....
RW....
RS....

I need the RS row to follow after the RW row? How can I acheive this?

Both RS and RW are in 2 separate XSLT files. I need to merge the 2 so that they print out as indicated above?

Below is my RW code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:date=" extension-element-prefixes="date">
<xsl:eek:utput method="text" />
<xsl:decimal-format name="us" decimal-separator="." grouping-separator=","/>

<!-- Parameters -->
<xsl:param name="Char"> </xsl:param>
<xsl:param name="newline"><xsl:text>
</xsl:text></xsl:param>

<!-- Template Matching -->
<xsl:template match="/">
<xsl:for-each select="NewDataSet/Table">
<xsl:text>RW</xsl:text>
<xsl:value-of select="substring(SocSecNo,1,9)" />
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="9 - string-length(SocSecNo)" />
<xsl:with-param name="Char" select="0"/>
</xsl:call-template>
<xsl:value-of select="substring(firstname,1,15)" />
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="15 - string-length(substring(firstname,1,15))" />
<xsl:with-param name="Char" select="' '"/>
</xsl:call-template>
<xsl:value-of select="substring(middlename,1,15)" />
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="15 - string-length(substring(middlename,1,15))" />
<xsl:with-param name="Char" select="' '"/>
</xsl:call-template>
<xsl:value-of select="substring(lastname,1,20)" />
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="20 - string-length(substring(lastname,1,20))" />
<xsl:with-param name="Char" select="' '"/>
</xsl:call-template>


<xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:template>

<!-- Custom template to support fixed-width column formatting -->
<xsl:template name="fillSpace">
<xsl:param name="Cnt"/>
<xsl:param name="Char"/>
<xsl:if test="$Cnt > 0"><xsl:value-of select="$Char"/></xsl:if>
<xsl:if test="$Cnt > 1">
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="$Cnt - 1"/>
<xsl:with-param name="Char" select="$Char"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Below is my RS code:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:date=" extension-element-prefixes="date">
<xsl:eek:utput method="text" />
<xsl:decimal-format name="us" decimal-separator="." grouping-separator=","/>

<!-- Parameters -->
<xsl:param name="Char"> </xsl:param>
<xsl:param name="newline"><xsl:text>
</xsl:text></xsl:param>

<!-- Template Matching -->
<xsl:template match="/">
<xsl:for-each select="NewDataSet/Table">
<xsl:text>RS</xsl:text>
<xsl:text>55</xsl:text>
<!-- State Taxable Wages -->
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="11 - string-length(translate(StateWages,'\.',''))" />
<xsl:with-param name="Char" select="0"/>
</xsl:call-template>
<xsl:value-of select="translate(StateWages,'\.','') " />
<!-- State Income Tax Withheld -->
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="11 - string-length(translate(StateTax,'\.',''))" />
<xsl:with-param name="Char" select="0"/>
</xsl:call-template>
<xsl:value-of select="translate(StateTax,'\.','') " />
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="215" />
<xsl:with-param name="Char" select="' '"/>
</xsl:call-template>


<xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:template>

<!-- Custom template to support fixed-width column formatting -->
<xsl:template name="fillSpace">
<xsl:param name="Cnt"/>
<xsl:param name="Char"/>
<xsl:if test="$Cnt > 0"><xsl:value-of select="$Char"/></xsl:if>
<xsl:if test="$Cnt > 1">
<xsl:call-template name="fillSpace">
<xsl:with-param name="Cnt" select="$Cnt - 1"/>
<xsl:with-param name="Char" select="$Char"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Any help on merging the 2 is GREATLY appreciated!!!
 
The plot out would be something like this.
[tt]
<!-- Template Matching -->
<xsl:template match="/">
<xsl:for-each select="NewDataSet/Table">
[blue]<xsl:call-template name="procRW" />
<xsl:call-template name="procRS" />[/blue]
</xsl:for-each>
</xsl:template>
<xsl:template name="procRW">
<xsl:text>RS</xsl:text>
<xsl:text>55</xsl:text>
<!-- State Taxable Wages -->
[blue]<!-- etc etc... -->[/blue]
<xsl:value-of select="$newline"/>
</xsl:template>
<xsl:template name="procRS">
<xsl:text>RS</xsl:text>
<xsl:text>55</xsl:text>
<!-- State Taxable Wages -->
[blue]<!-- etc etc... -->[/blue]
<xsl:value-of select="$newline"/>
</xsl:template>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top