Jump to content
Sign in to follow this  
winkimjr2

How do I get output for required elements

Recommended Posts

My xslt code is returning correct output when TransactionTypeText='Charge', TransactionTypeText='Payment', TransactionTypeText='Credit', and TransactionTypeText='Disbursement'.
However if the xml document has TransactionTypeText that is other than these 4, I am getting an error.
For example, when TransactionTypeText='Adjustment', I am getting an error Unknown transaction type. Adjustment.
I would like to add code so I also get the output when TransactionTypeText is other than Charge, Payment, Credit or Disbursement.
When the TranscationTypeText is not any of the 4, I would like to get the amounts from any of the source columns from the xml document.
For each row, only one of the sourse columns should have a non-zero value. If a row has more than one non-zero source columns, I return an exception which is in my xslt stylesheet
How do I modify my xslt code to handle all TransactionTypeText=xyz?
Here is my output for xml document without Adjustment element. This is correct or expected output
<FinancialDetail>
	<FinancialTransaction>
		<TransactionID>1639560336</TransactionID>
		<TransactionTypeText>Charge</TransactionTypeText>
		<TransactionDate>2016-07-11</TransactionDate>
		<TransactionFeeDetail>
			<FeeDetailID>1650110685</FeeDetailID>
			<FeeDetailFeeCodeText code="REST">Restitution</FeeDetailFeeCodeText>
			<FeeDetailFeeAmount>500</FeeDetailFeeAmount>
		</TransactionFeeDetail>
		<TransactionCommentText/>
		<TransactionPaymentCreditTypeText/>
	</FinancialTransaction>
</FinancialDetail>

xslt code
<xsl:stylesheet version="1.0" xmlns="http://www.courts.state.mn.us/CourtXML/3" xmlns:msc="http://www.courts.state.mn.us/CourtXML/3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mscef="courts.state.mn.us/extfun" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="mscef msxsl msc">
	<xsl:output method="xml" encoding="UTF-8"/>
	<xsl:template name="FinancialDetailType">
		<xsl:for-each select="ancestor::Integration/FinancialDetail/Transaction[count(TransactionFeeDetail[FeeDetailFeeCode='REST'])>0]">
			<FinancialTransaction>
				<TransactionID>
					<xsl:value-of select="TransactionID"/>
				</TransactionID>
				<TransactionTypeText>
					<xsl:value-of select="TransactionTypeText"/>
				</TransactionTypeText>
				<TransactionDate>
					<xsl:value-of select="substring(TransactionDate,1,10)"/>
				</TransactionDate>
				<xsl:for-each select="TransactionFeeDetail[FeeDetailFeeCode='REST']">
					<TransactionFeeDetail>
						<FeeDetailID>
							<xsl:value-of select="FeeDetailID"/>
						</FeeDetailID>
						<FeeDetailFeeCodeText>
							<xsl:attribute name="code">
								<xsl:value-of select="FeeDetailFeeCode"/>
							</xsl:attribute>
							<xsl:value-of select="FeeDetailFeeCodeText"/>
						</FeeDetailFeeCodeText>
						<FeeDetailFeeAmount>
							<xsl:choose>
								<xsl:when test="../TransactionTypeText='Charge'">
									<xsl:value-of select="mscef:formatCurrency(string(ChargeAmount))"/>
								</xsl:when>
								<xsl:when test="../TransactionTypeText='Payment'">
									<xsl:value-of select="mscef:formatCurrency(string(PaymentAmount))"/>
								</xsl:when>
								<xsl:when test="../TransactionTypeText='Credit'">
									<xsl:value-of select="mscef:formatCurrency(string(CreditAmount))"/>
								</xsl:when>
								<xsl:when test="../TransactionTypeText='Disbursement'">
									<xsl:value-of select="mscef:formatCurrency(string(DisbursementAmount))"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:message terminate="yes">Unknown transaction type. <xsl:value-of select="../TransactionTypeText"/>
									</xsl:message>
								</xsl:otherwise>
							</xsl:choose>
						</FeeDetailFeeAmount>
					</TransactionFeeDetail>
				</xsl:for-each>
				<TransactionCommentText>
					<xsl:value-of select="TransactionCommentText"/>
				</TransactionCommentText>
				<TransactionPaymentCreditTypeText>
					<xsl:value-of select="TransactionPaymentCreditTypeText"/>
				</TransactionPaymentCreditTypeText>
			</FinancialTransaction>
		</xsl:for-each>
	</xsl:template>
	<msxsl:script language="JScript" implements-prefix="mscef">
	<![CDATA[
		
		function formatCurrency(asCurrency){
			asCurrency = asCurrency.replace("\$","");
			asCurrency = asCurrency.replace("\,","");
			return parseFloat(asCurrency);
		}
		function formatTwoDecimalCurrency(asCurrency){
		    if(asCurrency.length==0){
			return "";
			}
			asCurrency = asCurrency.replace("\$","");
			asCurrency = asCurrency.replace("\,","");
			return parseFloat(asCurrency).toFixed(2);
		}
	]]></msxsl:script>
</xsl:stylesheet>

My xml document

<?xml version="1.0" encoding="UTF-8"?>
<Pipeline xmlns="">
	<SourceXML>
		<Integration>
			<Case InternalID="1612988653" ID="5226206" xmlns:user="http://tylertechnologies.com">
			</Case>
			<FinancialDetail>
				<Transaction>
					<TransactionID>1621246445</TransactionID>
					<TransactionTypeText>Charge</TransactionTypeText>
					<TransactionDate>2010-06-30T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1624242662</FeeDetailID>
						<FeeDetailFeeCode>CRMTRAF5</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Crim/Traffic Surcharge 2005</FeeDetailFeeCodeText>
						<ChargeAmount>72.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242663</FeeDetailID>
						<FeeDetailFeeCode>LAWLIBCR</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Law Library Criminal</FeeDetailFeeCodeText>
						<ChargeAmount>10.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242664</FeeDetailID>
						<FeeDetailFeeCode>MUNICCTY</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Municipal Fines-County Share</FeeDetailFeeCodeText>
						<ChargeAmount>233.3800</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242665</FeeDetailID>
						<FeeDetailFeeCode>10CHAS23</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Chaska (0300) 2/3</FeeDetailFeeCodeText>
						<ChargeAmount>466.6200</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242666</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>3.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242667</FeeDetailID>
						<FeeDetailFeeCode>PROSCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Prosecution Costs</FeeDetailFeeCodeText>
						<ChargeAmount>700.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
				</Transaction>
				<Transaction>
					<TransactionID>1621279946</TransactionID>
					<TransactionTypeText>Charge</TransactionTypeText>
					<TransactionDate>2010-07-06T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1624281693</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>20.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
				</Transaction>
				<Transaction>
					<TransactionID>1621541452</TransactionID>
					<TransactionTypeText>Payment</TransactionTypeText>
					<TransactionDate>2010-08-06T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1624242664</FeeDetailID>
						<FeeDetailFeeCode>MUNICCTY</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Municipal Fines-County Share</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>32.2800</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242665</FeeDetailID>
						<FeeDetailFeeCode>10CHAS23</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Chaska (0300) 2/3</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>64.5400</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242666</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.4100</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624281693</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>2.7700</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
				</Transaction>
				<Transaction>
					<TransactionID>1621746487</TransactionID>
					<TransactionTypeText>Disbursement</TransactionTypeText>
					<TransactionDate>2010-09-01T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1624242664</FeeDetailID>
						<FeeDetailFeeCode>MUNICCTY</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Municipal Fines-County Share</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>32.2800</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242665</FeeDetailID>
						<FeeDetailFeeCode>10CHAS23</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Chaska (0300) 2/3</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>64.5400</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624242666</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.4100</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
					<TransactionFeeDetail>
						<FeeDetailID>1624281693</FeeDetailID>
						<FeeDetailFeeCode>CRTCOSTS</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Court Costs</FeeDetailFeeCodeText>
						<ChargeAmount>0.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>2.7700</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
						<RecipientAccountID>1610014856</RecipientAccountID>
						<NameLast>MN Department of Finance</NameLast>
					</TransactionFeeDetail>
				</Transaction>
				<Transaction>
					<TransactionID>1639560336</TransactionID>
					<TransactionTypeText>Charge</TransactionTypeText>
					<TransactionDate>2016-07-11T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1650110685</FeeDetailID>
						<FeeDetailFeeCode>REST</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Restitution</FeeDetailFeeCodeText>
						<ChargeAmount>500.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
					</TransactionFeeDetail>
				</Transaction>
				<Transaction>
					<TransactionID>1639560337</TransactionID>
					<TransactionCommentText>Testing</TransactionCommentText>
					<TransactionTypeText>Adjustment</TransactionTypeText>
					<TransactionDate>2016-07-11T00:00:00</TransactionDate>
					<TransactionFeeDetail>
						<FeeDetailID>1650110685</FeeDetailID>
						<FeeDetailFeeCode>REST</FeeDetailFeeCode>
						<FeeDetailFeeCodeText>Restitution</FeeDetailFeeCodeText>
						<ChargeAmount>-500.0000</ChargeAmount>
						<CreditAmount>0.0000</CreditAmount>
						<DisbursementAmount>0.0000</DisbursementAmount>
						<PaymentAmount>0.0000</PaymentAmount>
					</TransactionFeeDetail>
				</Transaction>
			</FinancialDetail>
		</Integration>
	</SourceXML>
	<CourtXML/>
	<CaseOptions xmlns="http://www.courts.state.mn.us/CourtXML/3">
		<FinancialSummary>
			<SelectedIndicator>true</SelectedIndicator>
		</FinancialSummary>
		<FinancialDetail>
			<SelectedIndicator>true</SelectedIndicator>
		</FinancialDetail>
	</CaseOptions>
</Pipeline>

Share this post


Link to post
Share on other sites

The part of the code that is doing that is here:

<xsl:choose>
  <xsl:when test="../TransactionTypeText='Charge'">
    <xsl:value-of select="mscef:formatCurrency(string(ChargeAmount))"/>
  </xsl:when>
  <xsl:when test="../TransactionTypeText='Payment'">
    <xsl:value-of select="mscef:formatCurrency(string(PaymentAmount))"/>
  </xsl:when>
  <xsl:when test="../TransactionTypeText='Credit'">
    <xsl:value-of select="mscef:formatCurrency(string(CreditAmount))"/>
  </xsl:when>
  <xsl:when test="../TransactionTypeText='Disbursement'">
    <xsl:value-of select="mscef:formatCurrency(string(DisbursementAmount))"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:message terminate="yes">Unknown transaction type. <xsl:value-of select="../TransactionTypeText"/>
    </xsl:message>
  </xsl:otherwise>
</xsl:choose>

Share this post


Link to post
Share on other sites

Hello Foxy Mod,

 

You are right. However I am not sure how to add more code so that for example the code handles all TransactionTypeText other than the 4 being handled currently. E.g <TransactionTypeText>Adjustment</TransactionTypeText> is generating an error.

Share this post


Link to post
Share on other sites

You just need to add another <xsl:when> condition.

<xsl:when test="../TransactionTypeText='Adjustment'">

Do you understand XSL? If not, you should go through the XSL tutorials at W3schools.com.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×