srini xslt mapping

 INPUT

<purchaseOrder isMonitoring="false"

               version="1.0"

               receiver="TA">

<header>

<customerName>ALLIANCE SANTE SAS|36130</customerName>

<deliveryAddress>PLACE MARCEL DASSAULT CS 20060 DEOLS-CEDEX 36131</deliveryAddress>

<orderDate>2020-09-14</orderDate>

<preferredDeliveryDate>2020-09-14</preferredDeliveryDate>

<purchaseOrderId>217 11 test</purchaseOrderId>

</header>

<orderRows>

<orderRow>

<productNumber>0034009</productNumber>

<numberOfUnits>1</numberOfUnits>

<UnitPrice>0.99</UnitPrice>

</orderRow>

</orderRows>

</purchaseOrder>



OUTPUT

<purchaseOrder isMonitoring="false"

               version="1.0"

               receiver="TA"

               xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

               xmlns:xsd="http://www.w3.org/2001/XMLSchema"

               xmlns="urn:schema:fi:ratiopharm:orders:1.0">

<header>

<customerName>ALLIANCE SANTE SAS|36130</customerName>

<deliveryAddress>PLACE MARCEL DASSAULT CS 20060 DEOLS-CEDEX 36131</deliveryAddress>

<orderDate>2020-09-14</orderDate>

<preferredDeliveryDate>2020-09-14</preferredDeliveryDate>

<purchaseOrderId>217 11 test</purchaseOrderId>

</header>

<orderRows>

<orderRow>

<productNumber>0034009</productNumber>

<numberOfUnits>1</numberOfUnits>

<UnitPrice>0.99</UnitPrice>

</orderRow>

</orderRows>

</purchaseOrder>


4:05<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="urn:schema:fi:ratiopharm:orders:1.0">


  <!-- Identity template - copies everything as is -->

  <xsl:template match="@* | node()">

    <xsl:copy>

      <xsl:apply-templates select="@* | node()"/>

    </xsl:copy>

  </xsl:template>


  <!-- Overrides the root element to add namespaces -->

  <xsl:template match="/purchaseOrder">

    <purchaseOrder isMonitoring="{@isMonitoring}" version="{@version}" receiver="{@receiver}">

      <xsl:attribute name="xmlns:soap">http://www.w3.org/2003/05/soap-envelope</xsl:attribute>

      <xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:attribute>

      <xsl:attribute name="xmlns:xsd">http://www.w3.org/2001/XMLSchema</xsl:attribute>

      <xsl:apply-templates select="node() | @*"/>

    </purchaseOrder>

  </xsl:template>


</xsl:stylesheet>


can you help with some xslt map for this

4:05

INPUT an d expected output

4:05

need to add namespace

-----------

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="urn:schema:fi:ratiopharm:orders:1.0">


  <!-- Identity template - copies everything as is -->

  <xsl:template match="@* | node()">

    <xsl:copy>

      <xsl:apply-templates select="@* | node()"/>

    </xsl:copy>

  </xsl:template>


  <!-- Overrides the root element to add namespaces -->

  <xsl:template match="/">

    <purchaseOrder 

      xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xmlns:xsd="http://www.w3.org/2001/XMLSchema"

      isMonitoring="{purchaseOrder/@isMonitoring}"

      version="{purchaseOrder/@version}"

      receiver="{purchaseOrder/@receiver}"

    >

      <xsl:apply-templates/>

    </purchaseOrder>

  </xsl:template>


</xsl:stylesheet>

---------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="urn:schema:fi:ratiopharm:orders:1.0">
    <xsl:output indent="yes"/>  <!-- Match the root element and recreate it with adjusted namespaces -->
  <xsl:template match="purchaseOrder">
    <purchaseOrder
      isMonitoring="{@isMonitoring}"
      version="{@version}"
      receiver="{@receiver}"
    >
      <xsl:apply-templates select="node()"/>
    </purchaseOrder>
  </xsl:template>  <!-- Copy elements without namespace -->
  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
  </xsl:template>  <!-- Copy text nodes and attributes -->
  <xsl:template match="text() | @*">
    <xsl:copy/>
  </xsl:template></xsl:stylesheet>

Popular posts from this blog

pss book : శ్రీకృష్ణుడు దేవుడా, భగవంతుడా completed , second review needed. 26th April 2024

pss book: గురు ప్రార్థనామంజరి . completed 21st july 2024

pss book: కధల జ్ఞానము read review pending. 25th june 2024