<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method = "xml" indent = "yes" />
<!--
This is a transform to create an XML file from the ANX file output by the Debt Collection HotDocs intake.
-->
<xsl:template match="/AnswerSet">
<xsl:element name="OnlineIntake">
.
.
.
<xsl:for-each select="//Answer[@name='Factor']/RptValue/MCValue">
<xsl:variable name="getfactors" select="position()"/>
<xsl:element name="Factors">
<xsl:element name="Factor">
<xsl:value-of select="//Answer[@name='Factor']//MCValue[$getfactors]"/>
</xsl:element>
<xsl:element name="FactorAmt">
<xsl:value-of select="//Answer[@name='FactorAmount']//NumValue[$getfactors]"/>
</xsl:element>
</xsl:element> <!-- Factors -->
</xsl:for-each> <!-- end of foreach for Factors -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AnswerSet title="" version="1.1">
<Answer name="(ANSWER FILE HISTORY)">
<TextValue>Debt Collection Intake : May 6, 2015, 15:15
Maintenance Interview : February 18, 2015, 15:34
</TextValue>
.
.
.
<Answer name="Factor">
<RptValue>
<MCValue>
<SelValue>Child Care/Work-Related</SelValue>
</MCValue>
<MCValue>
<SelValue>Current income taxes</SelValue>
</MCValue>
<MCValue>
<SelValue>Mortgage payments</SelValue>
</MCValue>
<MCValue>
<SelValue>Rent</SelValue>
</MCValue>
<MCValue>
<SelValue>Transportation Expenses/Work-Related</SelValue>
</MCValue>
<MCValue>
<SelValue>Tools & Equipment/Work-Related</SelValue>
</MCValue>
<MCValue unans="true"/>
</RptValue>
</Answer>
<Answer name="Factor">
<RptValue>
<MCValue>
<SelValue>Child Care/Work-Related</SelValue>
</MCValue>
<MCValue>
<SelValue>Current income taxes</SelValue>
</MCValue>
<MCValue>
<SelValue>Mortgage payments</SelValue>
</MCValue>
<MCValue>
<SelValue>Rent</SelValue>
</MCValue>
<MCValue>
<SelValue>Transportation Expenses/Work-Related</SelValue>
</MCValue>
<MCValue>
<SelValue>Tools & Equipment/Work-Related</SelValue>
</MCValue>
<MCValue unans="true"/>
</RptValue>
</AnswerSet>
And the output looks like this<Factors>
<Factor>Child Care/Work-Related</Factor>
<FactorAmt>100.0000000</FactorAmt>
</Factors>
<Factors>
<Factor>Current income taxes</Factor>
<FactorAmt>250.0000000</FactorAmt>
</Factors>
<Factors>
<Factor>Mortgage payments</Factor>
<FactorAmt>600.0000000</FactorAmt>
</Factors>
<Factors>
<Factor>Rent</Factor>
<FactorAmt>0.0000000</FactorAmt>
</Factors>
<Factors>
<Factor>Transportation Expenses/Work-Related</Factor>
<FactorAmt>100.0000000</FactorAmt>
</Factors>
<Factors>
<Factor>Tools & Equipment/Work-Related</Factor>
<FactorAmt>75.0000000</FactorAmt>
</Factors>
<Factors>
<Factor/>
<FactorAmt/>
</Factors>
The output should not have the last empty <Factors> elements. Everything I've tried so far either crashes the transform or skips the Factors output. I can't change the input file, so can one of you experts help?
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE