2017-06-29 3 views
0

Ich habe diese XML-Quelle, die 2 Namespaces verwendet.Verwenden Sie 2 verschiedene Namespaces in XSLT

<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> 

Die D-Elemente haben einen anderen Namespace, die ich in der XSLT erklären, wie online von anderen ähnlichen Beispielen ersichtlich:

<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> 

Dies ist die erforderliche Ausgabe. Das ExtensionDate1 wird nicht angezeigt. Sicher ist es etwas Einfaches, ich schätze jede Hilfe.

<?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> 

Antwort

1

Das UserArea Element ist im Namespace Sie an das Präfix gebunden haben my so, wo Sie es wählen möchten, müssen Sie my:UserArea verwenden und nicht nsWS:UserArea wie Sie versucht haben.

+0

danke für die Antwort! –

Verwandte Themen