I have an xml file sent by an external provider in the below format:
The topmost element looks like this, defining all the namespaces:
<VocaDocument xmlns="http://ift.tt/W1Ln1j" xmlns:cmn="http://ift.tt/1r4NAFk" xmlns:iso="http://ift.tt/1w2xxIs" xmlns:env="http://ift.tt/1w2xxIx" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/W1Ln1j http://ift.tt/1pDSPMY">
when I exclude this namespace declaration xmlns="http://ift.tt/W1Ln1j" my xsl works fine and outputs what I want. But as soon as I include that namespace declaration in my XML, it stops working and returns nothing..and it makes no diifference if I add it in my XSL Stylesheet
With help from michael.hor257k on this post, I have a working XSL file, but I need to include these namespaces in my xsl.
I have tried the below in my xsl stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR" xmlns="http://ift.tt/W1Ln1j" xmlns:cmn="http://ift.tt/1r4NAFk"> <xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="VocaDocument/Data/Document/DDIVouchers/Voucher">
<xsl:value-of select="../../StreamStart/Stream/BankName" />
<xsl:value-of select="TransactionCode" />
<xsl:value-of select="OriginatorIdentification/ServiceUserNumber" />
<xsl:value-of select="ContactDetails/PhoneNumber" />
<xsl:value-of select="ContactDetails/FaxNumber" />
<xsl:value-of select="ContactDetails/Address/cmn:AddresseeName" />
<xsl:value-of select="ContactDetails/Address/cmn:PostalName" />
<xsl:value-of select="ContactDetails/Address/cmn:AddressLine" />
<xsl:value-of select="ContactDetails/Address/cmn:TownName" />
<xsl:value-of select="ContactDetails/Address/cmn:CountyIdentification" />
<xsl:value-of select="ContactDetails/Address/cmn:CountryName" />
<xsl:value-of select="ContactDetails/Address/cmn:ZipCode" />
<xsl:value-of select="ProcessingDate" />
<xsl:value-of select="BankAccount/FirstLastVoucherCode" />
<xsl:value-of select="BankAccount/AgencyBankCode" />
<xsl:value-of select="BankAccount/SortCode" />
<xsl:value-of select="BankAccount/AccountNumber" />
<xsl:value-of select="BankAccount/TotalVouchers" />
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
but nothing is returned (I am using the XSL TryItOut Editor from W3Schools.
Once I have an XSL file working correctly then I can build an Excel VBA tool to transform files as they are received from the provider.
What can I do to handle that namespace which seems to be causing all the trouble?
No comments:
Post a Comment