0

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>

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.