1

Anyone can help me with this? I'm trying to transform the response from MAXIMO enterprise service with xsl mapping, and I have successfully transformed it but the problem is, it isn't returning any data when I submit a request.

Here's my xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <SyncX1POMATREC>
            <X1POMATRECSet>
                <PO>
                    <SITEID>
                        <xsl:value-of select="string($var1_resultof_first/*[local-name()='SITEID' and namespace-uri()=''])"/>
                    </SITEID>
                    <PONUM>
                        <xsl:value-of select="PONUM"/>
                    </PONUM>
                    <REVISIONNUM>
                        <xsl:value-of select="REVISIONNUM"/>
                    </REVISIONNUM>
                    <POID>
                        <xsl:value-of select="POID"/>
                    </POID>
                    <RECEIPT>
                        <POLINENUM>
                            <xsl:value-of select="POLINENUM"/>
                        </POLINENUM>
                        <ITEMNUM>
                            <xsl:value-of select="ITEMNUM"/>
                        </ITEMNUM>
                    </RECEIPT>
                </PO>
            </X1POMATRECSet>
    </SyncX1POMATREC>
</xsl:template>

Here's the response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <SyncX1POMATREC xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <X1POMATRECSet>
            <PO>
               <SITEID/>
               <PONUM/>
               <REVISIONNUM/>
               <POID/>
               <RECEIPT>
                  <POLINENUM/>
                  <ITEMNUM/>
               </RECEIPT>
            </PO>
         </X1POMATRECSet>
      </SyncX1POMATREC>
   </soapenv:Body>
</soapenv:Envelope>

EDITED

Here's the request XML from SOAP:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:max="http://www.ibm.com/maximo">
   <soapenv:Header/>
   <soapenv:Body>
      <max:SyncX1POMATREC>
         <max:X1POMATRECSet>
            <max:PO action="AddChange">
               <max:SITEID>BEDFORD</max:SITEID>
               <max:PONUM>TEST42</max:PONUM>
               <max:REVISIONNUM>0</max:REVISIONNUM>
            </max:PO>
         </max:X1POMATRECSet>
      </max:SyncX1POMATREC>
   </soapenv:Body>
</soapenv:Envelope> 
oycarlito
  • 97
  • 1
  • 13

2 Answers2

1

The input XML has following namespaces xmlns:max="http://www.ibm.com/maximo" and xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" which are not declared in the XSLT. You need to declare these namespaces in the XSLT to access the associated XML elements.

In the XSLT, the elements need to accessed using the prefix declared for the namespace, in this case, it would be max i.e. max:SITEID or max:PONUM and so on.

Below is the modified XSLT. Certain elements viz. POID, POLINENUM and ITEMNUM are not present in the input XML shared and hence no values appear in the output.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:max="http://www.ibm.com/maximo" exclude-result-prefixes="soapenv max">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*" />

    <xsl:template match="max:PO">
        <SyncX1POMATREC>
            <X1POMATRECSet>
                <PO>
                    <SITEID><xsl:value-of select="max:SITEID" /></SITEID>
                    <PONUM><xsl:value-of select="max:PONUM" /></PONUM>
                    <REVISIONNUM><xsl:value-of select="max:REVISIONNUM" /></REVISIONNUM>
                    <POID><xsl:value-of select="POID" /></POID>
                    <RECEIPT>
                        <POLINENUM><xsl:value-of select="POLINENUM" /></POLINENUM>
                        <ITEMNUM><xsl:value-of select="ITEMNUM" /></ITEMNUM>
                    </RECEIPT>
                </PO>
            </X1POMATRECSet>
        </SyncX1POMATREC>
    </xsl:template>
</xsl:stylesheet>

Output

<SyncX1POMATREC>
    <X1POMATRECSet>
        <PO>
            <SITEID>BEDFORD</SITEID>
            <PONUM>TEST42</PONUM>
            <REVISIONNUM>0</REVISIONNUM>
            <POID />
            <RECEIPT>
                <POLINENUM />
                <ITEMNUM />
            </RECEIPT>
        </PO>
    </X1POMATRECSet>
</SyncX1POMATREC>
Aniket V
  • 3,183
  • 2
  • 15
  • 27
  • 1
    I am not sure what issue you are facing but based on the input XML that you have shared the output received can be verified at following online tool. [http://xsltfiddle.liberty-development.net/94hvTyH](http://xsltfiddle.liberty-development.net/94hvTyH) – Aniket V Apr 02 '18 at 11:11
  • Thanks for the tips! Ill try to figure it out and then post the answer here. – oycarlito Apr 02 '18 at 11:45
1

Another option is to ignore the namespaces by using [local-name() =, which you had the start of in your original question, and going straight to the element with //*:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <SyncX1POMATREC>
            <X1POMATRECSet>
                <PO>
                    <SITEID>
                        <xsl:value-of select="//*[local-name() = 'SITEID']"/>
                    </SITEID>
                    <PONUM>
                        <xsl:value-of select="//*[local-name() = 'PONUM']"/>
                    </PONUM>
                    <REVISIONNUM>
                        <xsl:value-of select="//*[local-name() = 'REVISIONNUM']"/>
                    </REVISIONNUM>
                    <POID>
                        <xsl:value-of select="//*[local-name() = 'POID']"/>
                    </POID>
                    <RECEIPT>
                        <POLINENUM>
                            <xsl:value-of select="//*[local-name() = 'POLINENUM']"/>
                        </POLINENUM>
                        <ITEMNUM>
                            <xsl:value-of select="//*[local-name() = 'ITEMNUM']"/>
                        </ITEMNUM>
                    </RECEIPT>
                </PO>
            </X1POMATRECSet>
        </SyncX1POMATREC>
    </xsl:template>
</xsl:stylesheet>
craigcaulfield
  • 3,381
  • 10
  • 32
  • 40