0

I have this original xml:

<Document xmlns="http://schema.infor.com/InforOAGIS/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.12.x/InforOAGIS/BODs/SyncCaptureDocument.xsd" releaseID="9.2" versionID="2.12.2">
    <Application>
        <Sender>
            <LogicalID>lid://infor.daf.1</LogicalID>
            <Code>OnError</Code>
        </Sender>
        <CreationDateTime>2021-06-10T23:07:36.193Z</CreationDateTime>
    </Application>
</Document>

My XSLT so far:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ns0="http://schema.infor.com/InforOAGIS/2 http://schema.infor.com/2.12.x/InforOAGIS/BODs/SyncCaptureDocument.xsd"
    exclude-result-prefixes="#all"
    version="3.0">

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:output method="xml" indent="yes" html-version="5"/>

  <xsl:template match="/">
        <Transaction xmlns="http://schema.infor.com/InforOAGIS/2"
                     languageCode="en-US"
                     releaseID="9.2"
                     systemEnvironmentCode="Production"
                     versionID="2.8.0">
            
            <ApplicationArea>
                <Sender>
                    <LogicalID>
                        <xsl:value-of select="ns0:Document/ns0:Application/ns0:Sender/ns0:LogicalID"/>
                    </LogicalID>
                    <Code>Add</Code>
                </Sender>
                <CreationDateTime>2021-06-10T23:07:36.193Z</CreationDateTime>
            </ApplicationArea>
            
        </Transaction>
    
  </xsl:template>
  
</xsl:stylesheet>

I cannot match the <LogicalID> node with the code above. I think it's because of the namespaces. Any help is appreciated. Link to the xslt: https://xsltfiddle.liberty-development.net/eieFA13/1

anhtle
  • 63
  • 9
  • For 757 other answers to this question, please search for "XSLT default namespace". – Michael Kay Jun 12 '21 at 07:17
  • I voted to close this question because it was caused by a typo, NOT because it is a duplicate. It would be better to actually read the question and the given answer before accusing others of not doing their homework. – michael.hor257k Jun 12 '21 at 09:28

1 Answers1

0

The namespace declaration in the XSLT is wrong, see the fix in https://xsltfiddle.liberty-development.net/eieFA13/2 to bind only the namespace name (e.g. xmlns:ns0="http://schema.infor.com/InforOAGIS/2") or https://xsltfiddle.liberty-development.net/eieFA13/3 to ease the task by using xpath-default-namespace (e.g. xpath-default-namespace="http://schema.infor.com/InforOAGIS/2").

On the other hand it sounds more as if you want to change the Sender/Code element:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xpath-default-namespace="http://schema.infor.com/InforOAGIS/2"
    exclude-result-prefixes="#all"
    version="3.0">

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="Sender/Code">
      <xsl:copy>Add</xsl:copy>
  </xsl:template>  
  
</xsl:stylesheet>

https://xsltfiddle.liberty-development.net/eieFA13/4

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110