I need to read attribute values in XSLT from top node, but I have no luck there. I think that I only use @attributName, but it's not working I am doing it thru C# program with Saxon.
Here is my input xml:
<Report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="FPPD4_MOPRG.srdl" xsi:schemaLocation="FPPD4_MOPRG.srdl http://czdmv204.llpdemo.local/ReportServer?%2FSunSystems%2FExample%20Reports%2FProcess%2FFPPD4_MOPRG.srdl&rs%3AFormat=XML&rc%3ASchema=True" Name="FPPD4_MOPRG.srdl" TextBox_4="FPPD4_MOPRG.srdl" businessUnit_param_label="Business Unit:" businessUnit_param="PK1" PrintDatetime_label="Print DateTime:" PrintDatetime_1="03/05/2023 09:39" storeOutput_param_label="Store Output:" storeOutput_param="True" outputFormat_param_label="Output Format:" outputFormat_param="XML" outputFileName_param_label="Output Filename:" outputFileName_param="FPPD4_MOPRG" Locale_param_label="Report Locale:" Locale_param="en-GB" endOfReport="END OF REPORT">
<AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode_List>
<AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode_Collection>
<AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode OwnBankSortCode="0100" BankSortCode_label="Bank Sort Code:" linesPerPage="0040" OwnBankAccountNumber="234230452034502" accountCode_label="Account Code:" accountCode="PK181009" BankAccountNumber_label_1="Bank Account Number:" OwnBankAccountName="Test WSRE OWN account" BankAccountName_label_1="Bank Account Name:" paymentAccount="BANK" BankTransactionReference_param="" BankTransactionReference_param_label="Bank Transaction Reference:" description_label_1="Description:" description="Froggit & Jones" bankAccountName="" bankAccountName_label="Bank Account Name:" bankAccountNumber="" bankAccountNumber_label="Bank Account Number:" baseAmount_label="Base Amount:" baseAmount_amount="-375.00" Description1="" Description1_label="Extension Description 1:" date="Date:" Today="2023-05-03" SwiftCode="" SwiftCode_label="Extension Swift Code:" Description2="" supplierName_label="Supplier Name:" supplierName="Froggit & Jones" Description2_label="Extension Description 2:" Description3="" Description3_label="Extension Description 3:" addressLine2_label="Address Line 2:" addressLine4_label="Address Line 4:" addressLine3_label="Address Line 3:" addressLine5_label="Address Line 5:" addressLine1_label="Address Line 1:" addressLine1="Unit 8 Haverlock Way" addressLine3="line4" addressLine2="line 3" addressLine4="Birmingham RG5 5BJ" addressLine5="UK" Description4="" Description4_label="Extension Description 4:" OwnBankDetailsCode_label="Own Bank Details Code:" OwnBankDetailsCode="52200" SupplierMiscReference2="" SupplierMiscReference2_label="Supplier Misc Reference 2:" OwnBankDetailsSubCode_label="Own Bank Details Sub Code:" OwnBankDetailsSubCode="" BankSortCode_label_2="Bank Sort Code:" BankSortCode="" BankProcessDate_param_label="Bank Process Date:" BankProcessDate_param="" DirectDebitTransactionType_Code_label="Direct Debit Transaction Type Code" ddt="" TownCity_label="Town/City:" TownCity="Birmingham" State_label="State:" State="CzechRepublic" StateCode_label="State Code:" StateCode="" PostalCode_label="Postal Code:" PostalCode="RG5 5BJ" Country_label="Country:" Country="UK" document="Document:" TextBox_1="000038" PayTotal="375.00DR" BankSortCode_label_1="Bank Sort Code:" BankSortCode_1="" TotalLines="5" LastLine="5" baseAmount_baseCreditAmount_2="375.00" accountCode_label_1="Account Code:" accountCode_1="81009" baseAmount_baseDebitAmount_2="0.00">
<AccountPaymentDocsReportingInterface_currencyCode_List>
<AccountPaymentDocsReportingInterface_currencyCode_Collection>
<AccountPaymentDocsReportingInterface_currencyCode currencyCode="GBP" currencyCode_label_1="Currency Code:" DocumentNumber="000038" docNumberAndVendor="000038PK181009" total="Total:" currencyCode_label="Currency Code:" currencyCode_1="GBP" baseAmount_baseDebitAmount_1="0.00" journalNumber_1="539" journalLineNumber_1="230" baseAmount_baseCreditAmount_1="375.00" baseDC="D" TxnDC="D" baseAmount_amount_20="-375.00" txnAmount_amount_20="-375.00" baseAmount_amount_99="375000" txnAmount_amount_99="375000">
<Detail_2_1>
<Detail_2_1_Group_Collection>
<Item RowNumber="1" transactionDate="2004-01-01" description_1="PO ?? FY 2021 ??????????????" transactionReference="401TELE007" baseAmount_baseCreditAmount="75.00" baseAmount_baseDebitAmount="0.00" baseAmount_amount_10="-75.00" baseAmount_amount_1="75.00"/>
<Item RowNumber="2" transactionDate="2004-03-01" description_1="Private line" transactionReference="403TELE007" baseAmount_baseCreditAmount="75.00" baseAmount_baseDebitAmount="0.00" baseAmount_amount_10="-150.00" baseAmount_amount_1="150.00"/>
<Item RowNumber="3" transactionDate="2004-04-01" description_1="Private line" transactionReference="404TELE007" baseAmount_baseCreditAmount="75.00" baseAmount_baseDebitAmount="0.00" baseAmount_amount_10="-225.00" baseAmount_amount_1="225.00"/>
<Item RowNumber="4" transactionDate="2004-05-01" description_1="Private line" transactionReference="405TELE007" baseAmount_baseCreditAmount="75.00" baseAmount_baseDebitAmount="0.00" baseAmount_amount_10="-300.00" baseAmount_amount_1="300.00"/>
<Item RowNumber="5" transactionDate="2004-06-01" description_1="Private line" transactionReference="406TELE007" baseAmount_baseCreditAmount="75.00" baseAmount_baseDebitAmount="0.00" baseAmount_amount_10="-375.00" baseAmount_amount_1="375.00"/>
</Detail_2_1_Group_Collection>
</Detail_2_1>
</AccountPaymentDocsReportingInterface_currencyCode>
</AccountPaymentDocsReportingInterface_currencyCode_Collection>
</AccountPaymentDocsReportingInterface_currencyCode_List>
</AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode>
</AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode_Collection>
</AccountPaymentDocsReportingInterface_1_ledgerLine_1_account_1_supplier_accountCode_List>
</Report>
Here is my XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="FPPD4_MOPRG.srdl"
exclude-result-prefixes="ns1">
<xsl:output method="xml"/>
<xsl:template match="ns1:Report">
<Document>
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>
<xsl:value-of select="@PrintDateTime_1"/>
</MsgId>
</GrpHdr>
</CstmrCdtTrfInitn>
</Document>
</xsl:template>
</xsl:stylesheet>
And here is my output:
<Document>
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId />
</GrpHdr>
</CstmrCdtTrfInitn>
</Document>
But output xml I want should be like this:
<Document>
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>03/05/2023 09:39</MsgId>
</GrpHdr>
</CstmrCdtTrfInitn>
</Document>
XML is case-sensitive: PrintDateTime_1
is not the same thing as PrintDatetime_1
.