I am receiving XML from a third party that conforms to NIEM standards. I need to translate it into a flat text file for another application to use. I've done this before using XSLT in another project, but not with quite so many namespaces. The XML document I'm receiving contains 5 namespaces and each element is individually prefixed with the required namespace. I'm having a hard time figuring out how to access the data with all the different namespaces. Any help to get me started would be appreciated.
Partial XML File Sample
<?xml version="1.0" encoding="UTF-8"?>
<asap:ReportTransmission xmlns:asap="http://www.asapnet.org/pmp/4.2/exchange"
xmlns:asap-code="http://www.asapnet.org/pmp/4.2/extension/code"
xmlns:asap-ext="http://www.asapnet.org/pmp/4.2/extension"
xmlns:asap-meta="http://www.asapnet.org/pmp/4.2/extension/meta"
xmlns:nc="http://release.niem.gov/niem/niem-core/3.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.asapnet.org/pmp/4.2/exchange ../schemas/exchange/pmp_exchange.xsd">
<asap-meta:TransactionHeader>
<asap-meta:ReleaseNumberText>4.2</asap-meta:ReleaseNumberText>
<asap-meta:ControlNumberText>857463</asap-meta:ControlNumberText>
<asap-code:TransactionKindCode>01</asap-code:TransactionKindCode>
<asap-meta:TransactionDate>2009-10-15</asap-meta:TransactionDate>
<asap-meta:TransactionTime>10:45:00</asap-meta:TransactionTime>
<asap-code:FileKindCode>P</asap-code:FileKindCode>
</asap-meta:TransactionHeader>
... continues
</asap:ReportTransmission>
I have set up my stylesheet based on this example on MSDN ("XSLT and Namespaces" section): https://msdn.microsoft.com/en-us/library/ms950779.aspx?f=255&MSPPError=-2147217396
The accepted answer to this question is very similar to the MSDN example and seems to confirm how it should be done: XSLT with multiple namespaces
Current Stylesheet
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asap="http://www.asapnet.org/pmp/4.2/exchange"
xmlns:asap-code="http://www.asapnet.org/pmp/4.2/extension/code"
xmlns:asap-ext="http://www.asapnet.org/pmp/4.2/extension"
xmlns:asap-meta="http://www.asapnet.org/pmp/4.2/extension/meta"
xmlns:nc="http://release.niem.gov/niem/niem-core/3.0/"
exclude-result-prefixes="asap asap-code asap-ext asap-meta nc">
<xsl:output method="text" omit-xml-declaration="yes" indent="no" />
<xsl:template match="asap:ReportTransmission">
<xsl:apply-templates select="asap-meta:TransactionHeader"/>
</xsl:template>
<xsl:template match="asap-meta:TransactionHeader">
<xsl:value-of select="asap-meta:ReleaseNumberText"/>
<xsl:value-of select="ReleaseNumberText"/>
</xsl:template>
</xsl:stylesheet>
I'm not getting a transformed result at all, the source XML is echoed back as the result.
What is the proper way to match and select data with so many namespaces?
<xsl:value-of select="ReleaseNumberText"/>yields nothing as expected) Please provide a more representative example.