Jump to content

Trying To Display Xml Values Horizontally With Descriptions


oracan1

Recommended Posts

I've only been working with .xml and .xsl for a couple weeks and have the following question. How can I display the taxable gross values from the EmployeeTax node on the same row in different columns? The catch to this is each .xml file may not have the same tax values. For example, in the attached .xml file, there is a TaxCount = 4. Tomorrow the count could be 0, 2 or 3. How can I display what is there in the EmployeeTax node and label the column heading with the Tax Descriptions? Here is the desired output with -space- used only for illustration purposes: FED-space--space- FICA-space--space- MEDICARE-space--space- MI2,247.88-space- 2,378.00--space---space- 2,378.00-space- --space- 2,247.88 Thanks for the help! Here is the condensed version of the xml input file: <?xml version="1.0" encoding="utf-8"?><ROOT xmlns:nss="urn:nss"><Header EmployeeInfoFlag="True" BenefitInfoFlag="False" DeductionInfoFlag="True" EarningsInfoFlag="True" AccrualHourInfoFlag="True" DirectDepositInfoFlag="True" CompanyName="CITY OF ANYTOWN - TEST (1/28/2010)" CompanyAddressLineOne="500 My Street" CompanyAddressLineTwo="ANYTOWN, MI 48027" CompanyAddressLineThree="" CompanyAddressLineFour="" TransactionType="1"> <CheckHeader Sequence="1" PaymentNumber="40621" EmployeeNameLastFirstMiddle="JOHN DOE" EmployeeNameFirstMiddleLast="JOHN DOE " Suffix="" EmployeeAddressLineOne="33 MY ROAD" EmployeeAddressLineTwo="My City, MI 48027" </CheckHeader Sequence> <EmployeeTax TaxCount="4" TotalTaxAmount="$474.77" YTDTotalTaxAmount="$2,017.04" TotalTaxAmountNoSign="474.77" YTDTotalTaxAmountNoSign="2017.04"> <EmployeeTaxCode TaxCode="FED" TaxDescription="Federal Income Tax" TaxableGross="2,247.88" TaxAmount="195.07" YTDTaxAmount="952.88" YTDTaxableGross="8,510.68" /> <EmployeeTaxCode TaxCode="FICA" TaxDescription="FICA" TaxableGross="2,378.00" TaxAmount="147.44" YTDTaxAmount="562.42" YTDTaxableGross="9,071.30" /> <EmployeeTaxCode TaxCode="MEDICARE" TaxDescription="Medicare" TaxableGross="2,378.00" TaxAmount="34.48" YTDTaxAmount="131.53" YTDTaxableGross="9,071.30" /> <EmployeeTaxCode TaxCode="MI" TaxDescription="MI Inc Tax" TaxableGross="2,247.88" TaxAmount="97.78" YTDTaxAmount="370.21" YTDTaxableGross="8,510.68" /> </EmployeeTax> <Deduction DeductionCount="6" TotalDeductionAmount="$136.82" YTDTotalDeductionAmount="$899.67" TotalDeductionAmountNoSign="136.82" YTDTotalDeductionAmountNoSign="899.67"> <DeductionCode DeductionCode="DEF COMP" DeductionDescription="Deferred Compensation" DeductionGross="0.00" DeductionAmount="75.00" YTDDeductionAmount="225.00" YTDDeductionGross="0.00" /> <DeductionCode DeductionCode="WRS EE 00" DeductionDescription="Flower Fund" DeductionGross="0.00" DeductionAmount="0.20" YTDDeductionAmount="0.60" YTDDeductionGross="0.00" /> <DeductionCode DeductionCode="WRS EE 03C" DeductionDescription="Life Insurance" DeductionGross="0.00" DeductionAmount="6.50" YTDDeductionAmount="19.10" YTDDeductionGross="0.00" /> <DeductionCode DeductionCode="WRS EE 09" DeductionDescription="Medical Class HAP" DeductionGross="0.00" DeductionAmount="0.00" YTDDeductionAmount="36.68" YTDDeductionGross="0.00" /> <DeductionCode DeductionCode="WRS EE 10" DeductionDescription="Medical Class HAP HMO FC" DeductionGross="0.00" DeductionAmount="0.00" YTDDeductionAmount="282.67" YTDDeductionGross="0.00" /> <DeductionCode DeductionCode="PEN DC CLASS" DeductionDescription="Pension Defined Contrib CLASS" DeductionGross="1,378.00" DeductionAmount="55.12" YTDDeductionAmount="335.62" YTDDeductionGross="8,390.65" /> </Deduction> <BroadcastMessage BroadcastMessage="" /> </CheckHeader></Header><ReportCriteria> <BMPFile ImageCount="1" Secure="True"></BMPFile> <NWRFile></NWRFile> <PrintImageFlag>False</PrintImageFlag> <FormID>746</FormID> <EchoXSL>PRCK_CityofANYTOWN</EchoXSL> <RendererToUse>2</RendererToUse> <DocumentPath>C:\Program Files\my company\App.NET\FileStorage\Documents\</DocumentPath> <EchoOptimizedPageHeader>Header/CheckHeader</EchoOptimizedPageHeader></ReportCriteria></ROOT>

Link to comment
Share on other sites

Hi. Please try this. The mode attribute of the template select statement allows you create multiple templates for the same XPath, that is my crude understanding anyway. I hope it helps you.

<?xml version = '1.0' encoding = 'ISO-8859-1'?><xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="html" omit-xml-declaration="yes"/><xsl:template match="/"><html lang="en"><head></head><body><table border="1"><xsl:apply-templates select="ROOT/EmployeeTax/EmployeeTaxCode" mode="column-title"/><tr><xsl:apply-templates select="ROOT/EmployeeTax/EmployeeTaxCode" mode="gross"/></tr></body></html></xsl:template> <xsl:template match="EmployeeTaxCode" mode="column-title"><th><xsl:value-of select="@TaxDescription"/></th></xsl:template>  <xsl:template match="EmployeeTaxCode" mode="gross"><td><xsl:value-of select="@TaxableGross"/></td></xsl:template></xsl:stylesheet> 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...