Announcement

Collapse
No announcement yet.

XSL generieren

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSL generieren

    Bin gerade neu im Umfeld und suche ein XSL Transformation in meiner PI Mapping die aus zwei XML Strukturen ergibt - Eingang XML und Ausgang XML.

    Eingang XML
    <OrbisOperation xmlns:ns1="http://Orbis.Connector" Multiple="1">
    <LIST>
    <account operation="a">
    <accountid>001e7b3f-6ad9-eb11-bacb-000d3a2c341c</accountid>
    <orb_erpaccountshortnumber>1920750</orb_erpaccountshortnumber>
    <tes_modifiedinsapon>2021-06-30</tes_modifiedinsapon>
    <tes_modifiedinsapby>1000IT-MSCRM</tes_modifiedinsapby>
    <tes_deactivaterecordchk>false</tes_deactivaterecordchk>
    <orb_erpdeletemarker>false</orb_erpdeletemarker>
    <tes_transfertosapchk>0</tes_transfertosapchk>
    </account>
    </LIST>
    </OrbisOperation>

    Ausgang XML

    <accountList>
    <account operation="a">
    <accountid>001e7b3f-6ad9-eb11-bacb-000d3a2c341c</accountid>
    <orb_erpaccountshortnumber>1920750</orb_erpaccountshortnumber>
    <tes_modifiedinsapon>2021-06-30</tes_modifiedinsapon>
    <tes_modifiedinsapby>1000IT-MSCRM</tes_modifiedinsapby>
    <tes_deactivaterecordchk>false</tes_deactivaterecordchk>
    <orb_erpdeletemarker>false</orb_erpdeletemarker>
    <tes_transfertosapchk>0</tes_transfertosapchk>
    </account>
    </accountList>

    Ich habe leider kein Tool zur Hand wo ich es automatisch generieren kann, wäre super wenn jemand mir dabei helfen konnten !

    VG

  • #2
    Bis auf die Namensraumdeklaration ist das in XSLT 1 mittels:
    Code:
    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
    
      <xsl:template match="@* | node()">
        <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="OrbisOperation">
          <xsl:apply-templates/>
      </xsl:template>
    
      <xsl:template match="LIST">
          <accountList>
              <xsl:apply-templates/>
          </accountList>
      </xsl:template>
    
    </xsl:stylesheet>
    relativ einfach.

    In XSLT 2 oder 3 kann man zusätzlich das Kopieren das Namensraum einfach verhindern:

    Code:
    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="2.0">
    
      <xsl:template match="@* | node()">
        <xsl:copy copy-namespaces="no">
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="OrbisOperation">
          <xsl:apply-templates/>
      </xsl:template>
    
      <xsl:template match="LIST">
          <accountList>
              <xsl:apply-templates/>
          </accountList>
      </xsl:template>
    
    </xsl:stylesheet>
    Zuletzt editiert von Martin Honnen; 02.07.2021, 22:48.

    Comment

    Working...
    X