Reputation: 109
I have this source XML, that is using 2 namespaces.
<SyncAssetMaster xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" languageCode="en-US" releaseID="9.2" systemEnvironmentCode="Production" versionID="2.8.0">
<ApplicationArea>
<CreationDateTime>2017-06-29T12:06:03Z</CreationDateTime>
</ApplicationArea>
<DataArea>
<AssetMaster>
<UserArea>
<D xmlns="http://schemas.datastream.net/MP_functions/MP0118_GetGridHeaderData_001_Result" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" n="380">SVP245</D>
<D xmlns="http://schemas.datastream.net/MP_functions/MP0118_GetGridHeaderData_001_Result" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" n="383">SVP245 v1</D>
</UserArea>
</AssetMaster>
</DataArea>
</SyncAssetMaster>
The D elements have a different namespace, which I declare in the XSLT, as seen from other similar examples online:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://schema.infor.com/InforOAGIS/2" xmlns:nsWS="http://schemas.datastream.net/MP_functions/MP0118_GetGridHeaderData_001_Result">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="//my:SyncAssetMaster">
<DataArea>
<CreationDateTime><xsl:value-of select="//my:CreationDateTime"/></CreationDateTime>
<ExtensionDate1><xsl:value-of select="//nsWS:UserArea/nsWS:D[@n='380']"/></ExtensionDate1>
</DataArea>
</xsl:template>
</xsl:stylesheet>
This is the required output. The ExtensionDate1 does not appear. Surely it's something simple, I appreciate any help.
<?xml version="1.0" encoding="UTF-8"?>
<DataArea xmlns:nsWS="http://schemas.datastream.net/MP_functions/MP0118_GetGridHeaderData_001_Result" xmlns:my="http://schema.infor.com/InforOAGIS/2">
<CreationDateTime>2017-06-29T12:06:03Z</CreationDateTime>
<ExtensionDate1>SVP245</ExtensionDate1>
</DataArea>
Upvotes: 0
Views: 211
Reputation: 167571
The UserArea
element is in the namespace you have bound to the prefix my
so where you want to select it you need to use my:UserArea
and not nsWS:UserArea
as you have tried.
Upvotes: 1