Blog Archive

Friday, May 18, 2018

Preparing target xml strucutres easily with notepad++ reqular expression

OM




Thursday, May 17, 2018

flat file records sorting using filed of reocrd for next message mapping



Om

some times, we need to sort the records , so easy in message mapping logic apply







Tuesday, May 8, 2018

add or modify at specific xpath with disturbing existing payload with XSLT

Om








<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="SRecords/ivybase__Question__c/LastModifiedById">
     <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  <index><xsl:value-of select="concat(../LastModifiedDate,':''deviprasad1') "/></index>

</xsl:template>

</xsl:stylesheet>



--------------------------------------------------another example---------------------
Source payload
<?xml version="1.0" encoding="UTF-8"?>
<EmployeeDetails>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
    <Employee>
        <Name>TEST</Name>
    </Employee>
</EmployeeDetails>

XSLT LOGIC
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="Employee">
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:attribute name="id">
                <xsl:number/>
            </xsl:attribute>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
   
    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="@*|node()"/>
        </xsl:element>
    </xsl:template>
   
    <xsl:template match="@*">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
   
</xsl:stylesheet>

Target payload after generating

<?xml version="1.0"?>
<EmployeeDetails>
    <Employee id="1">
        <Name>TEST</Name>
    </Employee>
    <Employee id="2">
        <Name>TEST</Name>
    </Employee>
    <Employee id="3">
        <Name>TEST</Name>
    </Employee>
    <Employee id="4">
        <Name>TEST</Name>
    </Employee>
    <Employee id="5">
        <Name>TEST</Name>
    </Employee>
</EmployeeDetails>


Friday, May 4, 2018

XSLT practice example

Om

source xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
  <book style="autobiography">
    <author>
      <first-name>Joe</first-name>
      <last-name>Bob</last-name>
      <award>Trenton Literary Review Honorable Mention</award>
    </author>
    <price>12</price>
  </book>
  <book style="textbook">
    <author>
      <first-name>Mary</first-name>
      <last-name>Bob</last-name>
      <publication>Selected Short Stories of
        <first-name>Mary</first-name>
        <last-name>Bob</last-name>
      </publication>
    </author>
    <editor>
      <first-name>Britney</first-name>
      <last-name>Bob</last-name>
    </editor>
    <price>55</price>
  </book>
  <magazine style="glossy" frequency="monthly">
    <price>2.50</price>
    <subscription price="24" per="year"/>
  </magazine>
  <book style="novel" id="myfave">
    <author>
      <first-name>Toni</first-name>
      <last-name>Bob</last-name>
      <degree from="Trenton U">B.A.</degree>
      <degree from="Harvard">Ph.D.</degree>
      <award>Pulitzer</award>
      <publication>Still in Trenton</publication>
      <publication>Trenton Forever</publication>
    </author>
    <price intl="Canada" exchange="0.7">6.50</price>
    <excerpt>
      <p>It was a dark and stormy night.</p>
      <p>But then all nights in Trenton seem dark and
      stormy to someone who has gone through what
      <emph>I</emph> have.</p>
      <definition-list>
        <term>Trenton</term>
        <definition>misery</definition>
      </definition-list>
    </excerpt>
  </book>
  <my:book xmlns:my="uri:mynamespace" style="leather" price="29.50">
    <my:title>Who's Who in Trenton</my:title>
    <my:author>Robert Bob</my:author>
  </my:book>
</bookstore>

xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="bookstore">
        <bookstore>
            <xsl:for-each select="book"  >
                    <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                    </xsl:copy>
            </xsl:for-each>
        </bookstore>
    </xsl:template>
</xsl:stylesheet>

------------------------------------------------------------------------------------------
condition1




Thursday, May 3, 2018

Multi Mapping single source and more target xsd map in single message mapping

Om

one single file( of multiple messages) and target expects multiple files for reach row.


2 approaches




by using soap internal xi adapter.