在XSLT转换样式表中获取错误

时间:2013-10-21 22:01:49

标签: xslt

我有变换,这给了我关于样式表的错误。以下是我的XML:

<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03">
    <CstmrPmtStsRpt>
        <GrpHdr>
            <MsgId>M-ID-3543</MsgId>
            <CreDtTm>2013-10-15T11:44:14.0Z</CreDtTm>
            <InitgPty>
                <Id>
                    <OrgId>
                        <Othr>
                            <Id>JP Morgan</Id>
                            <SchmeNm>
                                <Cd>BANK</Cd>
                            </SchmeNm>
                        </Othr>
                    </OrgId>
                </Id>
            </InitgPty>
        </GrpHdr>
        <OrgnlGrpInfAndSts>
            <OrgnlMsgId>00014354</OrgnlMsgId>
            <OrgnlMsgNmId>pain.001</OrgnlMsgNmId>
            <OrgnlNbOfTxs>1</OrgnlNbOfTxs>
            <OrgnlCtrlSum>2414034.080</OrgnlCtrlSum>
            <GrpSts>ACSP</GrpSts>
            <NbOfTxsPerSts>
                <DtldNbOfTxs>1</DtldNbOfTxs>
                <DtldSts>ACSP</DtldSts>
                <DtldCtrlSum>2414034.080</DtldCtrlSum>
            </NbOfTxsPerSts>
            <NbOfTxsPerSts>
                <DtldNbOfTxs>0</DtldNbOfTxs>
                <DtldSts>RJCT</DtldSts>
                <DtldCtrlSum>0.000</DtldCtrlSum>
            </NbOfTxsPerSts>
        </OrgnlGrpInfAndSts>
        <OrgnlPmtInfAndSts>
            <OrgnlPmtInfId>AP0000000441</OrgnlPmtInfId>
            <TxInfAndSts>
                <OrgnlEndToEndId>AP0000000441</OrgnlEndToEndId>
                <TxSts>ACSP</TxSts>
                <AcctSvcrRef>4700000288JO0000</AcctSvcrRef>
                <OrgnlTxRef>
                    <Amt>
                        <InstdAmt Ccy="USD">2414034.08</InstdAmt>
                    </Amt>
                    <ReqdExctnDt>2013-10-16</ReqdExctnDt>
                </OrgnlTxRef>
            </TxInfAndSts>
        </OrgnlPmtInfAndSts>
    </CstmrPmtStsRpt>
</Document>

我的XSLT是:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:ons="http://www.w3.org/1999/XSL/Transform"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03" version="1.0">
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="ons:CstmrPmtStsRpt">
        <PAYMENT_ACKNOWLEDGE>
            <FieldTypes>
                <PMT_ACK_HEADER class="R">
                    <PMT_ACK_FILE_ID type="CHAR"/>
                    <ACK_FILE_STATUS type="CHAR"/>
                    <BANK_FILE_ID type="CHAR"/>
                    <BANK_SEND_DTTM type="DATETIME"/>
                    <FORMAT_ID type="CHAR"/>
                    <OUTPUT_TYPE type="CHAR"/>
                    <PMT_FILE_PATH type="CHAR"/>
                    <FILENAME type="CHAR"/>
                    <CREATE_DTTM type="DATETIME"/>
                    <CREATED_BY_USER type="CHAR"/>
                    <PMT_CRYPTO_ID type="CHAR"/>
                    <PUBNODE type="CHAR"/>
                    <MSGNAME type="CHAR"/>
                    <APMSGVER type="CHAR"/>
                    <CHNLNAME type="CHAR"/>
                    <PUBID type="NUMBER"/>
                    <EVENT_TRACKING_ID type="NUMBER"/>
                    <BANK_SETID type="CHAR"/>
                    <BANK_CD type="CHAR"/>
                    <BANK_ID_QUAL type="CHAR"/>
                    <BNK_ID_NBR type="CHAR"/>
                    <DFI_ID_NUM type="CHAR"/>
                    <DFI_ID_QUAL type="CHAR"/>
                    <BIC_ID type="CHAR" />
                </PMT_ACK_HEADER>
                <PMT_ACK_ERR class="R">
                    <PMT_ACK_FILE_ID type="CHAR"/>
                    <PYMNT_REF_ID type="CHAR"/>
                    <SEQ_NUM type="NUMBER"/>
                    <ERROR_CODE type="CHAR"/>
                    <ERROR_MESSAGE type="CHAR"/>
                </PMT_ACK_ERR>
                <PMT_FILE_ACK class="R">
                    <PMT_ACK_FILE_ID type="CHAR"/>
                    <HEADER_ID type="CHAR"/>
                    <FILE_ACK_STATUS type="CHAR"/>
                    <NUM_PMTS_ACCEPTED type="NUMBER"/>
                    <NUM_PMTS_IN_ERROR type="NUMBER"/>
                    <ORIG_MSG_NAME type="CHAR"/>
                    <ORIG_NUM_TRAN type="NUMBER"/>
                    <ORIG_CTRL_SUM type="NUMBER"/>
                </PMT_FILE_ACK>
                <PMT_ACK class="R">
                    <PMT_ACK_FILE_ID type="CHAR"/>
                    <PYMNT_REF_ID type="CHAR"/>
                    <PMT_STATUS type="CHAR"/>
                    <BANK_REF_ID type="CHAR"/>
                </PMT_ACK>
                <PMT_FILE_ERR class="R">
                    <PMT_ACK_FILE_ID type="CHAR"/>
                    <HEADER_ID type="CHAR"/>
                    <SEQ_NUM type="NUMBER"/>
                    <ERROR_CODE type="CHAR"/>
                    <ERROR_MESSAGE type="CHAR"/>
                </PMT_FILE_ERR>
                <PSCAMA class="R">
                    <LANGUAGE_CD type="CHAR"/>
                    <AUDIT_ACTN type="CHAR"/>
                    <BASE_LANGUAGE_CD type="CHAR"/>
                    <MSG_SEQ_FLG type="CHAR"/>
                    <PROCESS_INSTANCE type="NUMBER"/>
                    <PUBLISH_RULE_ID type="CHAR"/>
                    <MSGNODENAME type="CHAR"/>
                </PSCAMA>
            </FieldTypes>
            <MsgData>
                <Transaction>
                    <PMT_ACK_HEADER class="R">
                        <xsl:apply-templates select="ons:GrpHdr"/>
                        <xsl:apply-templates select="ons:OrgnlGrpInfAndSts"/>
                        <xsl:apply-templates select="ons:TxInfAndSts"/>
                    </PMT_ACK_HEADER>
                    <PSCAMA class="R">
                        <LANGUAGE_CD>ENG</LANGUAGE_CD>
                        <AUDIT_ACTN/>
                        <BASE_LANGUAGE_CD>ENG</BASE_LANGUAGE_CD>
                        <MSG_SEQ_FLG/>
                        <PROCESS_INSTANCE>0</PROCESS_INSTANCE>
                        <PUBLISH_RULE_ID/>
                        <MSGNODENAME/>
                    </PSCAMA>
                </Transaction>
            </MsgData>
        </PAYMENT_ACKNOWLEDGE>
    </xsl:template>
    <xsl:template match="ons:GrpHdr">
        <PMT_ACK_HEADER class="R">
            <PMT_ACK_FILE_ID/>
            <ACK_FILE_STATUS IsChanged="Y">P</ACK_FILE_STATUS>
            <BANK_FILE_ID>
                <xsl:apply-templates select="ons:MsgId"/>
            </BANK_FILE_ID>
            <BANK_SEND_DTTM>
                <xsl:apply-templates select="ons:CreDtTm"/>
            </BANK_SEND_DTTM>
            <FORMAT_ID/>
            <OUTPUT_TYPE/>
            <PMT_FILE_PATH/>
            <FILENAME/>
            <CREATE_DTTM/>
            <CREATED_BY_USER/>
            <PMT_CRYPTO_ID/>
            <PUBNODE/>
            <MSGNAME/>
            <APMSGVER/>
            <CHNLNAME/>
            <PUBID>0</PUBID>
            <EVENT_TRACKING_ID>0</EVENT_TRACKING_ID>
            <BANK_SETID/>
            <BANK_CD/>
            <BANK_ID_QUAL/>
            <BNK_ID_NBR/>
            <DFI_ID_NUM/>
            <DFI_ID_QUAL/>
            <BIC_ID>
                <xsl:apply-templates select="ons:BIC"/>
            </BIC_ID>
        </PMT_ACK_HEADER>
    </xsl:template>
    <xsl:template match="ons:OrgnlGrpInfAndSts">
        <PMT_FILE_ACK class="R">
            <PMT_ACK_FILE_ID/>
            <HEADER_ID>
                <xsl:apply-templates select="ons:OrgnlMsgId"/>
            </HEADER_ID>
            <xsl:variable name="group_status" select="ons:GrpSts"/>
            <xsl:choose>
                <xsl:when test="$group_status='ACSP'">
                    <FILE_ACK_STATUS>A</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='ACSC'">
                    <FILE_ACK_STATUS>A</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='ACCP'">
                    <FILE_ACK_STATUS>A</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='PART'">
                    <FILE_ACK_STATUS>W</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='RJCT'">
                    <FILE_ACK_STATUS>E</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='RCVD'">
                    <FILE_ACK_STATUS>R</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='PDNG'">
                    <FILE_ACK_STATUS>R</FILE_ACK_STATUS>
                </xsl:when>
                <xsl:when test="$group_status='ACTC'">
                    <FILE_ACK_STATUS>R</FILE_ACK_STATUS>
                </xsl:when>
            </xsl:choose>
            <NUM_PMTS_ACCEPTED/>
            <NUM_PMTS_IN_ERROR/>
            <ORIG_MSG_NAME>
                <xsl:apply-templates select="OrgnlMsgNmId"/>
            </ORIG_MSG_NAME>
            <ORIG_NUM_TRAN>
                <xsl:apply-templates select="OrgnlNbOfTxs"/>
            </ORIG_NUM_TRAN>
            <ORIG_CTRL_SUM>
                <xsl:apply-templates select="OrgnlCtrlSum"/>
            </ORIG_CTRL_SUM>
            <xsl:variable name="error_code" select="ons:Rsn"/>
            <xsl:if test='string-length($error_code) >
                0'>
                <PMT_FILE_ERR class="R">
                    <PMT_ACK_FILE_ID/>
                    <HEADER_ID>
                        <xsl:apply-templates select="ons:OrgnlMsgId"/>
                    </HEADER_ID>
                    <SEQ_NUM>1</SEQ_NUM>
                    <ERROR_CODE>
                        <xsl:apply-templates select="ons:Rsn"/>
                    </ERROR_CODE>
                    <xsl:call-template name="StatusReasonMsg">
                        <xsl:with-param name="error_code">
                            <xsl:apply-templates select="ons:Rsn"/>
                        </xsl:with-param>
                    </xsl:call-template>
                </PMT_FILE_ERR>
            </xsl:if >
        </PMT_FILE_ACK>
    </xsl:template>
    <xsl:template match="ons:TxInfAndSts">
        <PMT_ACK class="R">
            <PMT_ACK_FILE_ID/>
            <PYMNT_REF_ID>
                <xsl:apply-templates select="ons:OrgnlEndToEndId"/>
            </PYMNT_REF_ID>
            <xsl:variable name="tx_status" select="ons:TxSts"/>
            <xsl:choose>
                <xsl:when test="$tx_status='ACCP'">
                    <PMT_STATUS>P</PMT_STATUS>
                </xsl:when>
                <xsl:when test="$tx_status='ACSC'">
                    <PMT_STATUS>P</PMT_STATUS>
                </xsl:when>
                <xsl:when test="$tx_status='ACSP'">
                    <PMT_STATUS>R</PMT_STATUS>
                </xsl:when>
                <xsl:when test="$tx_status='ACTC'">
                    <PMT_STATUS>R</PMT_STATUS>
                </xsl:when>
                <xsl:when test="$tx_status='PDNG'">
                    <PMT_STATUS>R</PMT_STATUS>
                </xsl:when>
                <xsl:when test="$tx_status='RJCT'">
                    <PMT_STATUS>E</PMT_STATUS>
                </xsl:when>
            </xsl:choose>
            <BANK_REF_ID></BANK_REF_ID>
            <xsl:variable name="error_code" select="Rsn"/>
            <xsl:if test='string-length($error_code) >
                0'>
                <PMT_ACK_ERR class="R">
                    <PMT_ACK_FILE_ID/>
                    <PYMNT_REF_ID>
                        <xsl:apply-templates select="ons:PmtId/EndToEndId"/>
                    </PYMNT_REF_ID>
                    <SEQ_NUM>1</SEQ_NUM>
                    <ERROR_CODE>
                        <xsl:apply-templates select="ons:Rsn"/>
                    </ERROR_CODE>
                    <xsl:call-template name="StatusReasonMsg">
                        <xsl:with-param name="error_code">
                            <xsl:apply-templates select="ons:Rsn"/>
                        </xsl:with-param>
                    </xsl:call-template>
                </PMT_ACK_ERR>
            </xsl:if >
        </PMT_ACK>
    </xsl:template>
    <xsl:template name="StatusReasonMsg">
        <xsl:param name="error_code"/>
        <xsl:choose>
            <xsl:when test="$error_code='AC01'">
                <ERROR_MESSAGE>Format of the account number specified is not correct.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AC04'">
                <ERROR_MESSAGE>Account number specified has been closed on the Receivers books.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AC06'">
                <ERROR_MESSAGE>Account specified is blocked, prohibiting posting of transactions against it.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AG01'">
                <ERROR_MESSAGE>Transaction forbidden on this type of account.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AG02'">
                <ERROR_MESSAGE>Bank Operation code specified in the transaction message is not valid for Receiver.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM01'">
                <ERROR_MESSAGE>Specified transaction message amount is equal to zero.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM02'">
                <ERROR_MESSAGE>Specified transaction message amount is greater than allowed maximum.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM03'">
                <ERROR_MESSAGE>Specified transaction message amount is in an non processable currency outside of existing agreement.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM04'">
                <ERROR_MESSAGE>Amount of funds available to cover specified transaction message amount is insufficient.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM05'">
                <ERROR_MESSAGE>This transaction message appears to have been duplicated.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM06'">
                <ERROR_MESSAGE>Specified transaction amount is less than agreed minimum.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM07'">
                <ERROR_MESSAGE>Amount specified in transaction message has been blocked by regulatory authorities.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM09'">
                <ERROR_MESSAGE>Amount received is not the amount agreed or expected.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='AM10'">
                <ERROR_MESSAGE>Sum of instructed amounts does not equal the control sum.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='BE01'">
                <ERROR_MESSAGE>Specification of creditor is not consistent with associated account number.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='BE04'">
                <ERROR_MESSAGE>Specification of creditors address, which is required for payment, is missing/not correct.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='BE05'">
                <ERROR_MESSAGE>Party who initiated the transaction message is not recognised by the end customer.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='DT01'">
                <ERROR_MESSAGE>Invalid date (e.g. wrong settlement date).</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='ED01'">
                <ERROR_MESSAGE>Correspond bank not possible.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='ED03'">
                <ERROR_MESSAGE>Balance of payments complementary info is requested.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='ED05'">
                <ERROR_MESSAGE>Settlement of the transaction has failed.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MS01'">
                <ERROR_MESSAGE>Reason has not been specified due to sensitivities.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD01'">
                <ERROR_MESSAGE>Mandate is cancelled or invalid.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD02'">
                <ERROR_MESSAGE>Mandate related information data required by the scheme is missing.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD03'">
                <ERROR_MESSAGE>File format incomplete or invalid.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD04'">
                <ERROR_MESSAGE>File format incorrect in terms of grouping indicator.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD06'">
                <ERROR_MESSAGE>Return of funds requested by end customer.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MD07'">
                <ERROR_MESSAGE>End customer is deceased.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='MS02'">
                <ERROR_MESSAGE>Reason has not been specified by end customer.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='NARR'">
                <ERROR_MESSAGE>Reason is provided as narrative information in the additional reason information.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='RC01'">
                <ERROR_MESSAGE>Bank identifier code specified in the message has an incorrect format.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='RF01'">
                <ERROR_MESSAGE>Transaction reference is not unique within the message.</ERROR_MESSAGE>
            </xsl:when>
            <xsl:when test="$error_code='TM01'">
                <ERROR_MESSAGE>Associated transaction message was received after agreed processing cut-off time.</ERROR_MESSAGE>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

虽然我已在样式表中提供了所有内容

1 个答案:

答案 0 :(得分:0)

看起来你在XSLT中声明了你的命名空间错误。

改变这个:

<xsl:stylesheet 
xmlns:ons="http://www.w3.org/1999/XSL/Transform"   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03" 
version="1.0">

对此:

<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:ons="urn:iso:std:iso:20022:tech:xsd:pain.002.001.03" 
version="1.0">