XSLT 1:1 transformation?

Communication: asynchronous between SPROXY => XI => 3rd Party Webervice.
I've huge XML response with a lot of tags. I just want to have on SPROXY 1:1 response. I've imported from XSD structure of response. I've created message types and message interfaces. I need now to create message mappings between 3rd_party_response and sproxy_response. As I wrote XML has a huge tags (c.a. different 500 tags). Creating those mapping manually is a madness. How can I do this automatically? I guess I can use for that XSLT transformation. Do you have maybe and example of XSLT 1:1 transformation or maybe there is a simplier solution?
Helping answers => a lot of points

Hello ,
You can go with XSLT....
follow these links,
Follow these links.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2ea3bb983c1
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9692eb84-0601-0010-5ca0-923b4fb8674a
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/006aa890-0201-0010-1eb1-afc5cbae3f15
Some scenarios
/people/sap.user72/blog/2005/03/15/using-xslt-mapping-in-a-ccbpm-scenario
/people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
*************8Reward points,if found useful

Similar Messages

  • XSLT mapping - Which transformation engine is used in PI 7.0

    Hi,
    In my favorite xslt tool I can choose which transformation engine I want to use while executing the xsl.
    Which Transformation engine is used in PI 7.0 ?
    (Nice to test with the same as PI have....)
    Br, Martin

    Hi ,
    as per my knowledge PI 7.0 uses XALAN parcer to execute XSLT Mapping programs,its available in in PI server it slelf.
    Regards,
    Raj

  • XML to Internal table using XSLT by CALL TRANSFORMATION error

    Dear experts,
    I have to fetch the data from an XML file using XSLT into internal tables. The XML file is very big as following:-
    <?xml version="1.0" standalone="yes" ?>
    - <Shipment>
      <shipmentID>25091203S000778</shipmentID>
      <manifestDateTime>2009-12-03T20:16:52.00</manifestDateTime>
      <shipmentFacilityNumber>025</shipmentFacilityNumber>
      <shipmentFacilityAbbreviation>CHI</shipmentFacilityAbbreviation>
      <shipmentFacilityAddress1>810 KIMBERLY DRIVE</shipmentFacilityAddress1>
      <shipmentFacilityAddress2 />
      <shipmentFacilityCity>CAROL STREAM</shipmentFacilityCity>
      <shipmentFacilityState>IL</shipmentFacilityState>
      <shipmentFacilityPostalCode>601880000</shipmentFacilityPostalCode>
      <shipmentTruckCarrierCode>X150</shipmentTruckCarrierCode>
      <shipmentSourceCode>T</shipmentSourceCode>
      <userID>CAMPOSG</userID>
    - <Delivery>
      <primaryCustomerNumber>954371</primaryCustomerNumber>
      <primaryCustomerName>MIDWEST OFFICE SUPPLY</primaryCustomerName>
      <primaryCustomerAddress1 />
      <primaryCustomerAddress2>4765 INDUSTRIAL DR</primaryCustomerAddress2>
      <primaryCustomerCity>SPRINGFIELD</primaryCustomerCity>
      <primaryCustomerState>IL</primaryCustomerState>
      <primaryCustomerPostalCode>627030000</primaryCustomerPostalCode>
      <primaryCustomerPhoneNumber>2177535555</primaryCustomerPhoneNumber>
      <shuttleStopFacilityNumber />
      <billOfLadingNumber>25HZK99</billOfLadingNumber>
      <carrierProNumber />
      <shipmentTotalCartonCount>6</shipmentTotalCartonCount>
      <shipmentTotalWeight>266</shipmentTotalWeight>
    - <order>
      <orderNumber>25HZK99</orderNumber>
      <subOrderNumber />
      <dateProcessed>2009-12-03</dateProcessed>
      <primaryOrderNumber />
      <shipTruckCode>X150</shipTruckCode>
      <shipTruckDescription>UDS - ADDISON</shipTruckDescription>
      <shipTruckPriorityCode>01</shipTruckPriorityCode>
      <shipTruckGroupCode>01</shipTruckGroupCode>
      <shipTruckDepartureTime>20.00.00</shipTruckDepartureTime>
      <shipTruckDockID>07</shipTruckDockID>
      <ldpFacilityAbbreviation />
      <shuttleAvailableIndicator>N</shuttleAvailableIndicator>
      <shuttleMessageText />
      <crossDockFacilityCode />
      <crossDockTruckCode />
      <crossDockID />
      <subsidizedFreightTruckID />
      <customerPurchaseOrderNumber>623559</customerPurchaseOrderNumber>
      <headerTypeCode>P</headerTypeCode>
      <orderTypeID>RG</orderTypeID>
      <deliveryTypeID>DS</deliveryTypeID>
      <deliveryMethodCode />
      <customerBarCode />
      <customerReferenceData>25HZK99</customerReferenceData>
      <customerReferenceText />
      <customerRouteData>ZNED UNTED</customerRouteData>
      <customerRouteText>ROUTE</customerRouteText>
      <endConsumerPurchaseOrderNumber />
      <endConsumerPurchaseOrderText />
      <endConsumerName>CHARLESTON TRANS. FACILITY</endConsumerName>
      <endConsumerAddress1>HOMEWOOD DT PROGRAM DEPT. 3</endConsumerAddress1>
      <endConsumerAddress2>17341 PALMER BLVD.</endConsumerAddress2>
      <endConsumerAddress3 />
      <endConsumerCity>HOMEWOOD</endConsumerCity>
      <endConsumerState>IL</endConsumerState>
      <endConsumerPostalCode>60430</endConsumerPostalCode>
      <endConsumerCountryCode />
      <fillFacilityNumber>025</fillFacilityNumber>
      <shpFacilityNumber>025</shpFacilityNumber>
      <homeFacilityAbbrCode>STL</homeFacilityAbbrCode>
      <homeFacilityNumber>015</homeFacilityNumber>
      <multiCartonIndicator>Y</multiCartonIndicator>
      <primaryCustomerIndicator>Y</primaryCustomerIndicator>
      <shipToCustomerNumber>954371001</shipToCustomerNumber>
      <customerCompanyID>01</customerCompanyID>
      <customerTruckID>U888</customerTruckID>
      <customerTruckDescription>UDS - ADDISON</customerTruckDescription>
      <customerTruckDockID>13</customerTruckDockID>
      <thirdPartyBillCarrier />
      <thirdPartyBillID />
      <thirdPartyBillType />
      <qualityCheckIndicator>N</qualityCheckIndicator>
      <warehouseLaydownID />
      <packListPosition>I</packListPosition>
      <preferredPackingType>CTN</preferredPackingType>
      <preferredPackingMaterial>PAPER</preferredPackingMaterial>
      <preferedPackingInstructions />
      <totalOrderCartonQty>6</totalOrderCartonQty>
      <convertAddressIndicator>N</convertAddressIndicator>
      <dealerInstructionIndicator>Y</dealerInstructionIndicator>
      <dealerinstructions1>CPO#: 623559</dealerinstructions1>
      <dealerinstructions2>ATTN: DANA GRIFFIN</dealerinstructions2>
      <dealerinstructions3>INFO: 612</dealerinstructions3>
      <dealerinstructions4>ROUTE: ZNED UNTED</dealerinstructions4>
      <dealerinstructions5 />
      <dealerinstructions6 />
      <shippingInstructionsIndicator>N</shippingInstructionsIndicator>
      <shippingInstructions1 />
      <shippingInstructions2 />
      <shippingInstructions3 />
      <shippingInstructions4 />
      <shippingInstructions5 />
      <shippingInstructions6 />
      <specialInstructionsIndicator>N</specialInstructionsIndicator>
      <specialInstructions1 />
      <specialInstructions2 />
      <customeContainerDesc />
    - <carton>
      <deliveryCartonID>253370905995</deliveryCartonID>
      <shipIndicator>Y</shipIndicator>
      <deliveryPalletID>X150</deliveryPalletID>
      <consolidatedDeliveryCartonID />
      <scanDateTime>2009-12-03T19:36:12.00</scanDateTime>
      <cartonWeight>52</cartonWeight>
      <dropShipFlag>1</dropShipFlag>
      <carrierTrackingNumber />
      <carrierZoneID>0</carrierZoneID>
      <codAmount />
      <customerPackageAmount />
      <declaredValue />
      <residentialDeliveryIndicator />
      <serviceTypeCode>00</serviceTypeCode>
      <ssccCode>006860244400829393</ssccCode>
    - <Item>
      <shipPrefix>UNV</shipPrefix>
      <shipStockNumber>21200</shipStockNumber>
      <itemDescription>PAPER XERO/DUP WE LTR 20#</itemDescription>
      <orderQuantity>1</orderQuantity>
      <originalShipQuantity>1</originalShipQuantity>
      <shipQuantity>1</shipQuantity>
      <inventoryUnitCode>CT</inventoryUnitCode>
      <inventoryWeightQuantity>52.000</inventoryWeightQuantity>
      <upcNumber>00000000000000</upcNumber>
      <upcRetailCode>087547212004</upcRetailCode>
      <hazmatIndicator>N</hazmatIndicator>
      <serialRequiredIndicator>N</serialRequiredIndicator>
      <dealerMemoPO>S</dealerMemoPO>
      <cartonLineNumber>1</cartonLineNumber>
      <orderLineNumber>11</orderLineNumber>
      <originalOrderPrefix>UNV</originalOrderPrefix>
      <originalOrderStockNumber>21200</originalOrderStockNumber>
      <reasonCode />
    - <Item_Serial>
      <serialNumber />
      </Item_Serial>
        </Item>
      </carton>
       </order>
      </Delivery>
      </Shipment>
    This is not the complete XML file as it exceeds the 15000 characters and then I cann't post here. So I have deleted much part of it.
    The hierarchy is as following: Shipment->Delivery->Order->Carton->Item.
    I have created a XSLT for it which is working fine.
    But when I execute my report program it gives CX_SY_XSLT_FORMAT_ERROR saying that
    Transformation error:  Non-canonical structure of element name XML_OUTPUT.

    Dear experts,
    My report program is as following:-
    *& Report  Z_ASNTRNS
    REPORT  Z_ASNTRNS.
    *& Report  Z_ASNTRNS
    TYPE-POOLS: abap, ixml.
    TABLES: ZASN_SHIPMENT,ZASN_DELIVERY,ZASN_ORDER,ZASN_CARTON,ZASN_ITEM.
    *CONSTANTS gs_file TYPE string VALUE 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
    This is the structure for the data from the XML file
    TYPES: BEGIN OF ts_item,
          ZSHIPMENT LIKE ZASN_ITEM-ZSHIPMENT,
          VBELN LIKE ZASN_ITEM-VBELN,
          ORDER_NUMBER LIKE ZASN_ITEM-ORDER_NUMBER,
          CARTON_ID LIKE ZASN_ITEM-CARTON_ID,
           ITEM LIKE ZASN_ITEM-ITEM,
           CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
           CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
          AEDAT(8),
          AEZET(6),
           ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
           ORD_QTY(16),
           ORIGINAL_SHIP(16),
           SHIP_QTY(16),
           UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
           DEALER_MEMO_PO(5),
           ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
          STATUS LIKE ZASN_ITEM-STATUS,
           END OF ts_item.
    TYPES: BEGIN OF ts_carton,
          ZSHIPMENT LIKE ZASN_CARTON-ZSHIPMENT,
          VBELN LIKE ZASN_CARTON-VBELN,
          ORDER_NUMBER LIKE ZASN_CARTON-ORDER_NUMBER,
           CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
          AEDAT(8),
          AEZET(6),
           SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
           TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
           ZZCARTON_WGT(18),
           Item type ts_item,
           END OF ts_carton.
    TYPES: BEGIN OF ts_order,
          ZSHIPMENT LIKE ZASN_ORDER-ZSHIPMENT,
          VBELN LIKE ZASN_ORDER-VBELN,
           ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
          AEDAT(8),
          AEZET(6),
           SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
           ORDER_DATE(8),
           PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
           CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
           PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
           SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
          ANZPK(5),
           carton type ts_carton,
           END OF ts_order.
    TYPES: BEGIN OF ts_delivery,
          ZSHIPMENT LIKE ZASN_DELIVERY-ZSHIPMENT,
          VBELN LIKE ZASN_DELIVERY-VBELN,
          AEDAT(8) TYPE C,
          AEZET(6) TYPE C,
           PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
           BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
           CARTON_COUNT(5),
           TOTAL_WEIGHT(18),
           order type ts_order,
           END OF ts_delivery.
    TYPES: BEGIN OF ts_shipment,
           ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
           MANIFEST_DATE_TIME(25),
          AEDAT(8) TYPE C,
          AEZET(6) TYPE C,
          SDATE(8) TYPE C,
          STIME(6) TYPE C,
           SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
           ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
           Delivery type ts_delivery,
           END OF ts_shipment.
    TYPES: BEGIN OF ts_shipment1,
           ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
           MANIFEST_DATE_TIME(25),
           SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
           ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
           PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
           BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
           CARTON_COUNT(5),
           TOTAL_WEIGHT(18),
           ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
           SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
           ORDER_DATE(8),
           PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
           CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
           PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
           SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
           CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
           SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
           TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
           ZZCARTON_WGT(18),
           ITEM LIKE ZASN_ITEM-ITEM,
           CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
           CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
           ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
           ORD_QTY(16),
           ORIGINAL_SHIP(16),
           SHIP_QTY(16),
           UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
           DEALER_MEMO_PO(5),
           ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
           END OF ts_shipment1.
    TYPES: BEGIN OF t_xml_line,
                 data(256) TYPE x,
               END OF t_xml_line.
    *Typdefinition für Airplus
    *READ THE DOCUMENTATION "LASG_XML_INVOICE_BTM"!!!
    VARs beginning with "a_" are ATTRIBUTES
    DATA: l_ixml            TYPE REF TO if_ixml,
          l_streamfactory   TYPE REF TO if_ixml_stream_factory,
          l_parser          TYPE REF TO if_ixml_parser,
          l_istream         TYPE REF TO if_ixml_istream,
          l_ostream         TYPE REF TO if_ixml_ostream,
          l_document        TYPE REF TO if_ixml_document,
          l_node            TYPE REF TO if_ixml_node,
          l_xml TYPE REF TO cl_xml_document,
          l_xmldata         TYPE string.
    DATA: l_xml_table       TYPE TABLE OF t_xml_line,
             l_xml_line        TYPE t_xml_line,
             l_xml_table_size  TYPE i.
    DATA: l_filename        TYPE string.
    DATA: xml_out TYPE string ,
          size type i.
    DATA: l_xml_x1   TYPE xstring.
    DATA: l_len      TYPE i,
              l_len2     TYPE i,
              l_tab      TYPE tsfixml,
              l_content  TYPE string,
              l_str1     TYPE string,
              c_conv     TYPE REF TO cl_abap_conv_in_ce.
             l_itab     TYPE TABLE OF string.
    DATA: BEGIN OF l_itab occurs 0,
          data(256) type c,
          end of l_itab.
    TYPES : BEGIN OF TY_TEXT,
              data(255) type C,
            END OF TY_TEXT.
    DATA: F_XML TYPE STRING.
    DATA : LT_TEXT_OUT type table of TY_TEXT with header line.
    tables
    DATA: it_shipment    TYPE STANDARD TABLE OF ts_shipment,
          wa_shipment    TYPE  ts_shipment.
    *Errorvariables
    DATA: xslt_err   TYPE REF TO cx_xslt_exception,
          err_string TYPE string.
    PARAMETERS: pa_file TYPE localfile OBLIGATORY
    DEFAULT 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
    START-OF-SELECTION.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
        PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
    here we use the CALL TRANSFORMATION method which calls
    the XSLT program "z_asnfile"
    TRY.
        CALL TRANSFORMATION ('Z_ASNFILE')
          SOURCE xml LT_TEXT_OUT[]
          RESULT xml_output = it_shipment
    catch any error, very helpful if the XSLT isn't correct
        CATCH cx_xslt_exception INTO xslt_err.
        err_string = xslt_err->get_text( ).
        WRITE: / 'Transformation error: ', err_string.
        EXIT.
      ENDTRY." setting a breakpoint to watch the workarea
    by the internal table "it_airplus"
           break-point.
      LOOP AT it_shipment INTO wa_shipment.
      ENDLOOP.
    *&      Form  get_xml_table
      FORM get_xml_table CHANGING l_xml_table_size TYPE i
                                  l_xml_table      TYPE STANDARD TABLE.
        l_filename = pa_file.
      upload a file from the client's workstation
        CALL METHOD cl_gui_frontend_services=>gui_upload
          EXPORTING
            filename   = l_filename
            filetype   = 'BIN'
          IMPORTING
            filelength = l_xml_table_size
          CHANGING
            data_tab   = l_xml_table
          EXCEPTIONS
            OTHERS     = 19.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Convert binary to text.
    CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
      EXPORTING
        INPUT_LENGTH          = 70000
                FIRST_LINE            = 0
                LAST_LINE             = 0
                APPEND_TO_TABLE       = ' '
                MIMETYPE              = ' '
        WRAP_LINES            = 'X'
              IMPORTING
                OUTPUT_LENGTH         =
      TABLES
        BINARY_TAB            = l_xml_table
        TEXT_TAB              = LT_TEXT_OUT
              EXCEPTIONS
                FAILED                = 1
                OTHERS                = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    "get_xml_table

  • XSLT and ABAP Transformation Deep Structure

    Hello Everyone,
    While I've read the forums and the links of a number of folks doing the same thing. I am stuck in that I cannot figure out how to populate a deep structure via XSLT.  Not sure what is going wrong, but I suspect it is obvious. The simple problem is that my structure is not getting populated. It is blank.  The transformation works in testing STRANS (and in Stylus Studio). 
    I cannot figure out what is wrong that makes the t_pexr2002 table blank.  Thanks for any insight. 
    Greg
    The simple program is:
    TYPES: BEGIN OF ty_head,
              sndprn TYPE string,
              bgmref TYPE string,
              moabetrh TYPE string,
              create_date TYPE string,
              settlement_date TYPE string,
              no_lines TYPE string,
           END OF ty_head.
    TYPES: BEGIN OF ty_pricing,
            moabetr TYPE string,
           END OF ty_pricing.
    TYPES: BEGIN OF ty_item,
              docname TYPE string,
              docnummr TYPE string,
              pricing TYPE ty_pricing,
            END OF ty_item.
    TYPES: BEGIN OF ty_summary,
              status_message TYPE string,
           END OF ty_summary.
    TYPES: BEGIN OF ty_mn,
            header_data  TYPE ty_head,
            item_data    TYPE ty_item,
            summary_data TYPE ty_summary,
           END OF ty_mn.
    DATA: t_pexr2002 TYPE STANDARD TABLE OF ty_mn.
    DATA: xml_doc TYPE REF TO cl_xml_document, xml TYPE string.
    CREATE OBJECT xml_doc.
    CALL METHOD xml_doc->import_from_file
      EXPORTING
        filename = 'C:\temp\2640273.xml'.
    CALL METHOD xml_doc->render_2_string
      EXPORTING
        pretty_print = 'X'
      IMPORTING
        stream       = xml.
    CALL TRANSFORMATION zusl_pexr2002_v1
    SOURCE XML xml
    RESULT output = t_pexr2002.
    Edited by: Thomas Zloch on Jun 9, 2010 6:05 PM

    Here is my XSLT:
    Here is the transformation: Also pretty simple...
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... >
      <xsl:strip-space elements="*"/>
      <xsl:template match="/PEXR2002/IDOC">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <OUTPUT>
                <HEADER_DATA>
                  <SNDPRN>
                    <xsl:value-of select="EDI_DC40/SNDPRN"/>
                  </SNDPRN>
                  <BGMREF>
                    <xsl:value-of select="E1IDKU1/BGMREF"/>
                  </BGMREF>
                  <MOABETRH>
                    <xsl:value-of select="E1IDKU5/MOABETR"/>
                  </MOABETRH>
                  <CREATE_DATE>
                    <xsl:value-of select="EDI_DC40/CREDAT"/>
                  </CREATE_DATE>
                  <SETTLEMENT_DATE>
                    <xsl:value-of select="E1EDK03/DATUM"/>
                  </SETTLEMENT_DATE>
                  <NO_LINES>
                    <xsl:value-of select="count(E1IDPU1)"/>
                  </NO_LINES>
                </HEADER_DATA>
                <ITEM_DATA>
                  <xsl:for-each select="E1IDPU1">
                    <DOCNAME>
                      <xsl:value-of select="DOCNAME"/>
                    </DOCNAME>
                    <DOCNUMMR>
                      <xsl:value-of select="DOCNUMMR"/>
                    </DOCNUMMR>
                    <PRICING_DATA>
                      <xsl:for-each select="E1IDPU5[MOAQUAL = '006']">
                        <MOABETR>
                          <xsl:value-of select="MOABETR"/>
                        </MOABETR>
                      </xsl:for-each>
                    </PRICING_DATA>
                  </xsl:for-each>
                </ITEM_DATA>
                <SUMMARY_DATA>
                  <xsl:for-each select="EDI_DS40">
                    <STATUS_MESSAGE>
                      <xsl:value-of select="STAPA1"/>
                    </STATUS_MESSAGE>
                  </xsl:for-each>
                </SUMMARY_DATA>
            </OUTPUT>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:transform>
    Edited by: Thomas Zloch on Jun 9, 2010 6:05 PM

  • Writing XSLT to perform transformation from XML to ABAP

    Hi,
    I've been struggling quite a bit with XSLT. I read several old discussions regarding transformations using ST and XSLT but I haven't been able to solve my problem.
    I have a requirement to build a program to convert XML to an internal table.
    I've been able to do it for smaller XMLs, but whenever I try to apply the same logic to a bigger XML it simply just doesn't work. I'm almost certain it has something to do with the way I wrote the XSLT but I haven't been able to figure out what.
    The XML I have to read from goes something like this:
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    -<AuditFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
         -<Header xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
              <AuditFileVersion>1.02_01</AuditFileVersion>
                   <CompanyID>50002</CompanyID>
                   <TaxRegistrationNumber>5000</TaxRegistrationNumber>
                   <TaxAccountingBasis>F</TaxAccountingBasis>
                   <CompanyName>Company</CompanyName>
                   <BusinessName>Business</BusinessName>
                   -<CompanyAddress>
                        <AddressDetail>Address</AddressDetail>
                        <City>city</City>
                        <PostalCode>333333</PostalCode>
                        <Country>PT</Country>
                   </CompanyAddress>
                   <FiscalYear>2013</FiscalYear>
                   <StartDate>2013-07-01</StartDate>
                   <EndDate>2013-07-31</EndDate>
                   <CurrencyCode>EUR</CurrencyCode>
                   <DateCreated>2013-08-02</DateCreated>
                   <TaxEntity>Global</TaxEntity>
                   <ProductCompanyTaxID>00</ProductCompanyTaxID>
                   <SoftwareCertificateNumber>00</SoftwareCertificateNumber>
                   <ProductID>product</ProductID>
                   <ProductVersion>00</ProductVersion>
                  <Email>email@com</Email>
                   <Website>www.s.pt</Website>
         </Header>
         -<MasterFiles xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
              -<Customer>
                   <CustomerID>1</CustomerID>
                   <AccountID>ID</AccountID>
                   <CustomerTaxID>999999990</CustomerTaxID>
                   <CompanyName>Desconhecido</CompanyName>
                   -<BillingAddress>
                        <AddressDetail>Desconhecido</AddressDetail>
                        <City>Desconhecido</City>
                        <PostalCode>0000-000</PostalCode>
                        <Country>PT</Country>
                   </BillingAddress>
                   <SelfBillingIndicator>0</SelfBillingIndicator>
              </Customer>
              -<Customer>
                   <CustomerID>2</CustomerID>
                   <AccountID>Desconhecido</AccountID>
                   <CustomerTaxID>571</CustomerTaxID>
                   <CompanyName>Company</CompanyName>
                   -<BillingAddress>
                        <AddressDetail>detail</AddressDetail>
                        <City>city</City>
                        <PostalCode>0000-000</PostalCode>
                       <Country>PT</Country>
               </BillingAddress>
              <SelfBillingIndicator>0</SelfBillingIndicator>
         </Customer>
    ...and so on
    And the XSLT I've written so far is something like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
       <xsl:strip-space elements="*"/>
       <xsl:template match="/">
         <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
           <asx:values>
             <ICUSTOMER>
               <xsl:apply-templates select="//Customer"/>
             </ICUSTOMER>
           </asx:values>
         </asx:abap>
       </xsl:template>
       <xsl:template match="Customer">
         <item>
           <CUSTOMER_ID>
             <xsl:value-of select="CustomerID"/>
           </CUSTOMER_ID>
           <ACCOUNT_ID>
             <xsl:value-of select="AccountID"/>
           </ACCOUNT_ID>
           <CUSTOMERTAX_ID>
             <xsl:value-of select="CustomerTaxID"/>
           </CUSTOMERTAX_ID>
           <COMPANYNAME>
             <xsl:value-of select="CompanyName"/>
           </COMPANYNAME>
           <ADDRESSDETAIL>
             <xsl:value-of select="BillingAddress/AddressDetail"/>
           </ADDRESSDETAIL>
           <CITY>
             <xsl:value-of select="BillingAddress/City"/>
           </CITY>
            <POSTALCODE>
             <xsl:value-of select="BillingAddress/PostalCode"/>
           </POSTALCODE>
            <COUNTRY>
             <xsl:value-of select="BillingAddress/Country"/>
           </COUNTRY>
           <SELFBILLINGINDICATOR>
             <xsl:value-of select="SelfBillingIndicator"/>
           </SELFBILLINGINDICATOR>
         </item>
       </xsl:template>
    </xsl:transform>
    Like I said, I'm almost certain that the problem is with the XSLT, as it returns an empty table / ALV. I've used this method before and it worked...
    Any thoughts?
    Thank you

    Hello Goncalo,
    I think, there are two problems:
    1) The xmlns declaration within your xml is a problem for the SAP XSLT Processor.
    2) I have written a similar XSLT-report, which performs directly with your data. Perhaps this is not necessary if 1) is solved:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
       <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
       <xsl:strip-space elements="*"/>
       <xsl:template match="AuditFile">
         <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
           <asx:values>
              <xsl:apply-templates select="MasterFiles"/>
           </asx:values>
         </asx:abap>
       </xsl:template>
       <xsl:template match="MasterFiles">
             <ICUSTOMER>
               <xsl:apply-templates select="./Customer"/>
             </ICUSTOMER>
       </xsl:template>
       <xsl:template match="Customer">
           <CUSTOMER_ID>
             <xsl:value-of select="CustomerID"/>
           </CUSTOMER_ID>
           <ACCOUNT_ID>
             <xsl:value-of select="AccountID"/>
           </ACCOUNT_ID>
           <CUSTOMERTAX_ID>
             <xsl:value-of select="CustomerTaxID"/>
           </CUSTOMERTAX_ID>
       </xsl:template>
    </xsl:transform>
    Kind regards,
    Hendrik

  • XSLT help to transform an XML

    I need help writing and XSLT to transform an XML in InDesign.  I am new to XML and have no idea how to write an XSLT.
    We are trying to bring in data from a database using a query language that is having trouble creating the image tags the way we need it to.  Basically, I need to take this:
    <Project href="file://C:\My test phot.jpg">
    and transform it into this:
    <Project> <image href="file://C:\My test phot.jpg" />
    Can anyone help me with this?
    Thanks!

    Not sure I can help you with this, as my understanding of XSL is very limited.
    However, as a matter of trial and error, I find that if I transform this XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
         <Project href="file://C:\My test phot1.jpg">The first bit of textual content here</Project>
         <Project href="file://C:\My test phot2.jpg">The second bit of textual content here</Project>
         <Project href="file://C:\My test phot3.jpg">The third bit of textual content here</Project>
         <Project href="file://C:\My test phot4.jpg">The fourth bit of textual content here</Project>
         <Project href="file://C:\My test phot5.jpg">The fifth bit of textual content here</Project>
    </Root>
    ...with this XSLT:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:template match="/">
         <Root>
             <xsl:for-each select="/Root/Project">
               <Project>
                 <image><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></image>
                 <xsl:value-of select="."/>
               </Project>
             </xsl:for-each>
         </Root>
       </xsl:template>
    </xsl:stylesheet>
    ...I end up with this XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
    <Project><image href="file://C:\My test phot1.jpg"/>The first bit of textual content here</Project>
    <Project><image href="file://C:\My test phot2.jpg"/>The second bit of textual content here</Project>
    <Project><image href="file://C:\My test phot3.jpg"/>The third bit of textual content here</Project>
    <Project><image href="file://C:\My test phot4.jpg"/>The fourth bit of textual content here</Project>
    <Project><image href="file://C:\My test phot5.jpg"/>The fifth bit of textual content here</Project>
    </Root>
    ...which seems what you're looking for.
    [I edited the original solution slightly by removing a wildcard.]

  • XSLT and Call transformation

    Hi
    Using <b>XSLT</b> and <b>Call transformation</b> (XSLT scheme) to convert XML file to html the problem is that line breaks in xml are ignored when passing the call tranformation.
    <b>Note in xml look like:</b>
    <com:Note><![CDATA[
    Serie 87% 0,000000
    Amount in this period 01-01-2006 - 01-07-2006 - 180 days
    Currency 16.267.117,38 DKK
    Loan DKK 14.332.700,00
    Debt 7.358.534,23
    Indexsfactor 226,230
    ]]></com:Note>
    <b>When HTML displayed in sap, - note is just a long string which continue out of the screen. Note looks like:</b>Serie 87% 0,000000Amount in this period 01-01-2006 - 01-07-2006 - 180 daysCurrency 16.267.117,38 DKKDebt 7.358.534,23Indexsfactor 226,230
    What to do ? Any ideas ?

    hi Jan,
    Check out the link
    http://www.topxml.com/code/default.asp?p=3&id=v20031025170911&ms=20&l=xsl&sw=categ
    This link contains a file that contains an importable xslt stylesheet with two templates. The first is a text wrap template that breaks texts at carriage returns. You need to modify the xslt.
    [code]<xsl:template name="text.wrap">
            <xsl:param name="texttowrap"/>
            <xsl:variable name="textlength" select="string-length($texttowrap)"/>
            <!-- don't waste time if no text supplied or remaining from recursion-->
            <xsl:if test="$textlength > 0">
                <xsl:choose>
                    <xsl:when test="contains($texttowrap,$CR)">
                        <!-- get the text before the first instance of a carriage return character-->
                        <xsl:variable name="<span  style="background-color:yellow;color:red;font-weight:bold;">line</span>beforefirst<span  style="background-color:yellow;color:red;font-weight:bold;">break</span>" select="substring-before($texttowrap,$CR)"/>
    .................[/code]
    Hope this helps.
    Regards,
    Richa

  • Default XSLT Stylesheet to transform BW XML Data?

    I'm currently working on a deafult XSLT Stylesheet to convert a BW XML Query Result Set into an html grid.
    [code]
    <!--
    #==========================================================================
    XSL Transformation that displays
    Template Properties, List of Data Providers and List of Items
    #==========================================================================
    -->
    <xml id="xsl_transform_1">
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:variable name="header">
    <tr bgcolor="white"> <xsl:for-each select="//RRWS_SX_TUPLE[1]/*">
      <td>
      <xsl:value-of select="local-name()"/>
      </td>
    </xsl:for-each>
    </tr>
    </xsl:variable>
    <xsl:template match="/">
    <table bgcolor="gold" border="1">
    TESTVALUE -
    <tr>
      <xsl:copy-of select="$header" /> <xsl:apply-templates />
    </tr>
    <xsl:for-each select="//RRWS_SX_TUPLE">
          <tr>
            <td><xsl:value-of select="TUPLE_ORDINAL"/></td>
              <xsl:for-each select="//RRWS_S_CELL">           
              <td><xsl:value-of select="CELL_ORDINAL"></td>
              </xsl:for-each>
            <td><xsl:value-of select="TUPLE_ORDINAL"/></td>
            <td><xsl:value-of select="CHANM"/></td>
            <td><xsl:value-of select="CAPTION"/></td>
            <td><xsl:value-of select="CHAVL"/></td>
            <td><xsl:value-of select="CHAVL_EXT"/></td>
            <td><xsl:value-of select="NIOBJNM"/></td>
            <td><xsl:value-of select="TLEVEL"/></td>
            <td><xsl:value-of select="DRILLSTATE"/></td>
            <td><xsl:value-of select="OPT"/></td>
            <td><xsl:value-of select="SIGN"/></td>                    
            <td><xsl:value-of select="ATTRIBUTES"/></td>     
          </tr>
    <xsl:for-each select="//RRWS_S_CELL">
         <tr>     
            <td><xsl:value-of select="CELL_ORDINAL"/></td> 
            <td><xsl:value-of select="VALUE"/></td>            
            <td><xsl:value-of select="FORMATTED_VALUE"/></td> 
            <td><xsl:value-of select="VALUE_TYPE"/></td> 
            <td><xsl:value-of select="CURRENCY"/></td> 
            <td><xsl:value-of select="UNIT"/></td> 
            <td><xsl:value-of select="MWKZ"/></td> 
            <td><xsl:value-of select="NUM_SCALE"/></td> 
            <td><xsl:value-of select="NUM_PREC"/></td> 
            <td><xsl:value-of select="CELL_STATUS"/></td> 
            <td><xsl:value-of select="BACK_COLOR"/></td> 
         </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    <xsl:template match="RRWS_S_CELL/*">
    <td> <xsl:value-of select="." /> </td>
    </xsl:template></xsl:stylesheet>
    </xml>
    [/code]
    I've started this, but I need to join the top tree with the bottom. Right now I'm just flattening the tree. Does anyone know if any work has been done in this area? I'm looking to create these XSLT Transforms. Also, I'd like to create generic javascript functions that I can use as an include, such as
    function join_BW_Table(table1, table2, fieldtojoin, typeofjoin)
    This would allow anyone to generically combine BW Data from multiple sources all on the FrontEnd and render it all as an html table. My ultimate goal would be have all this in includes and available for all BW Reporting. Anyone have any thoughts on:
    1. Has this been done before?
    2. If it hasn't, anyone have comments on how I can combine the 2 tables that I'm rendering with the attached XSLT transform?
    I'm running these transforms via a javscript function on the load of the html page.
    Prakash

    Prakash,
    did you ever compile the Stylesheet?  I am looking for an alternative way to format the pre-compiled XML file from the Report Designer.  The more complex my report is, the less robust the application becomes.
    Your insight would be greatly appreciated.
    Thank you

  • XSLT 2.0 transformations in BPEL?

    I'm using BPEL 10.1.3.1.0, and I want to execute a simple xslt 2.0 stylesheet, that takes two dateTime variables from the inputVariable payload, subtracts them to get a duration, and put this duration back into the outputVariable payload...
    Stylesheet:
    <xsl:stylesheet version="2.0"
                    xmlns:ns1="http://xmlns.oracle.com/durationTest"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:fo="http://www.w3.org/1999/XSL/Format"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    xmlns:fn="http://www.w3.org/2005/xpath-functions"
                    exclude-result-prefixes="xsl ns1 xs fn fo">
      <xsl:template match="/">
        <ns1:durationTestProcessResponse>
          <ns1:result>
            <xsl:value-of select="/ns1:durationTestProcessRequest/ns1:date2 - /ns1:durationTestProcessRequest/ns1:date1"/>
          </ns1:result>
        </ns1:durationTestProcessResponse>
      </xsl:template>
    </xsl:stylesheet>This is a snippet from our BPEL process (transform activity):
    <assign name="subtractDates">
                <bpelx:annotation>
                    <bpelx:pattern>transformation</bpelx:pattern>
                </bpelx:annotation>
                <copy>
                    <from expression="ora:processXSLT('Transformation_1.xsl',bpws:getVariableData('inputVariable','payload'))"/>
                    <to variable="outputVariable" part="payload"/>
                </copy>
            </assign>My input variable XSD is:
    <schema attributeFormDefault="unqualified"
               elementFormDefault="qualified"
               targetNamespace="http://xmlns.oracle.com/durationTest"
               xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="durationTestProcessRequest">
         <complexType>
              <sequence>
                   <element name="date1" type="dateTime"/>
                   <element name="date2" type="dateTime"/>
              </sequence>
         </complexType>
    </element>
    <element name="durationTestProcessResponse">
         <complexType>
              <sequence>
                   <element name="result" type="duration"/>
              </sequence>
         </complexType>
    </element>
    </schema>This stylesheet works without any problems if I try it in XMLSpy. However, when I execute my BPEL process, the payload of the outputVariable is empty. I do not get any errors... Anyone know why my stylesheet isn't properly executed? If I change the xslt version to 1.0 the result gets filled with 'NaN', which is logical...
    TIA,
    Bas

    For anyone that's interested, I got it to work... The solution was to add dateTime() around the XPath locations to the variables:
    <xsl:value-of select="dateTime(/ns1:durationTestProcessRequest/ns1:date2) - dateTime(/ns1:durationTestProcessRequest/ns1:date1)"/>

  • How to manually write log file when tranform xslt by using Transformer?

    I want to ask experts that are there any way to write the information(such as template name or number of template used) into log file while performing transformation with javax.xml.transform.Transformer.
    Below is my sample code
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    // declare and assign value of transform, source, and result
    transformer.transform(source, result);
    Thanks for advance

    I think it will be from FDM, if I remember correctly FDM will generate a text file in the background and then load data into essbase using the text file.
    The codes at each line are standard essbase generated codes which relate to an operation e.g. 1013162 = Received Command [Calculate] from user [%s] using [%s]
    If you have a search on the web you will be able to find a full list of codes from numerous locations.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • XML file to Internal table through XSLT - Call Transformation

    Hi Friends,
    I am trying to work a scenario where i have a simple XML file and i need to convert the data in to an internal table. When i execute the XSLT seperately, it works fine. I get the output, but when it is invoked through a ABAP program, i am getting the error "The called method START_XSLT_DEBUGGER of the calss CL_WB_XSLT_DEBUGGER returned the exception CX_XSLT_FORMAT_ERROR"
    I feel my XSLT program is not correct, but i am unable to find out what the issue is. Any help is really apreciated. I have gone through the SDN forum replies. But could not figure out what is wrong with my program
    Below given are the details.
    My XML File:
    <?xml version="1.0" encoding="utf-8"?>
    <List>
      <ITEM>
        <ITEMQUALF>ITEM1</ITEMQUALF>
        <MATERIAL>MAT1</MATERIAL>
      </ITEM>
      <ITEM>
        <ITEMQUALF>ITEM2</ITEMQUALF>
        <MATERIAL>MAT2</MATERIAL>
      </ITEM>
      <ITEM>
        <ITEMQUALF>ITEM3</ITEMQUALF>
        <MATERIAL>MAT3</MATERIAL>
      </ITEM>
    </List>
    My XSLT program:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" xmlns:asx="http://www.sap.com/abapxml" exclude-result-prefixes="asx" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
      <!--xsl:template match="/"-->
      <xsl:template match="List">
        <asx:abap version="1.0">
          <asx:values>
            <T_ACTUAL>
              <xsl:for-each select="*">
                <ITEMQUALF>
                  <xsl:value-of select="ITEMQUALF" />
                </ITEMQUALF>
                <MATERIAL>
                  <xsl:value-of select="MATERIAL" />
                </MATERIAL>
              </xsl:for-each>
            </T_ACTUAL>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:transform>
    In my ABAP program:
    REPORT  z_xslt_abap_2.
    TYPES:
      BEGIN OF ty_actual,
        itemqualf   TYPE char50,
        material    TYPE char50,
      END OF ty_actual,
      line_t(4096)  TYPE x,
      table_t       TYPE STANDARD TABLE OF line_t,
      ty_t_actual   TYPE STANDARD TABLE OF ty_actual.
    DATA:
      t_actual    TYPE ty_t_actual,
      t_srctab    TYPE table_t,
      v_filename  TYPE string.
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    v_filename = 'D:\XML\xslt_test.xml'.
    * Function call
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename = v_filename
        filetype = 'BIN'
      TABLES
        data_tab = t_srctab
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    * Call Transformation
    TRY.
        CALL TRANSFORMATION (`ZXSLT_RAM`)
                SOURCE XML t_srctab
                RESULT     t_actual = t_actual.
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY .
    IF t_actual IS NOT INITIAL.
      WRITE: 'Success'.
    ENDIF.
    When i run the XSLT program seperately, this is the output that i get:
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <asx:values>
        <T_ACTUAL>
          <ITEMQUALF>ITEM1</ITEMQUALF>
          <MATERIAL>MAT1</MATERIAL>
          <ITEMQUALF>ITEM2</ITEMQUALF>
          <MATERIAL>MAT2</MATERIAL>
          <ITEMQUALF>ITEM3</ITEMQUALF>
          <MATERIAL>MAT3</MATERIAL>
        </T_ACTUAL>
      </asx:values>
    </asx:abap>
    I have been stuck with this for more than two days. If anyone can help me out with this, it would be really great. Please let me know, where i am going wrong.
    Thanks in advance.
    Best Regards,
    Ram.

    Hi,
    You can try this sample program, hopefully will help you.
    <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/readdatafromXMLfileviaXSLT+program&">Read Data From XML</a>.
    Regards,

  • Error while transforming XSLT by calling function with Reflection API

    Hi,
    I'm new to Reflection API. I want to call function from the jar file which is not in my application context. So I have loaded that jar ( say XXX.jar) file at runtime with URLClassLoader and call the function say [ *myTransform(Document document)* ]. Problem is that when I want to transform any XSLT file in that function it throws exception 'Could not compile stylesheet'. All required classes are in XXX.jar.
    If I call 'myTransform' function directly without reflection API then it transformation successfully completed.
    Following is code of reflection to invoke function
            ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
            URLClassLoader loader = new URLClassLoader(jarURLs, contextCL);
            Class c = loader.loadClass(fullClasspath);
            Constructor constructor = c.getDeclaredConstructor(constructorParamsClasses);
            Object instance = constructor.newInstance(constructorParams);
            Method method = c.getDeclaredMethod("myTransform", methodParamsClasses);
            Object object = method.invoke(instance, methodParams);Following is function to be called with reflection API.
    public Document myTransform ( Document document ) {
    // Reference of Document (DOM NODE) used to hold the result of transformation.
                Document doc = null ;
                // DocumentBuilderFactory instance which is used to initialize DocumentBuilder to create newDocumentBuilder.
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance () ;
                // Reference of DocumentBuilder used to create new Document (DOM NODE).
                DocumentBuilder builder;
                try {
                      // Initialize DocumentBuilder by using DocumentBuilderFactory instance.
                      builder = factory.newDocumentBuilder ();
                      // Initialize new document instance by using DocumentBuilder instance.
                      doc = builder.newDocument () ;
                      // Creates new DOMSource by using document (DOM NODE) which is coming through current transform() method parameter.
                      DOMSource domsource = new DOMSource ( document ) ;
                      // Creates new instance of TransformerFactory.
                      TransformerFactory transformerfactory = TransformerFactory.newInstance () ;
                      // Creates new Transformer instance by using TransformerFactory which holds XSLT file.
                      Transformer transformer = null;
    ********* exception is thrown from here onward ******************
                      transformer = transformerfactory.newTransformer (new StreamSource (xsltFile));
                      // Transform XSLT on document (DOM NODE) and store result in doc (DOM NODE).
                      transformer.transform ( domsource , new DOMResult ( doc ) ) ;
                } catch (ParserConfigurationException ex) {
                      ex.printStackTrace();
                } catch (TransformerConfigurationException ex) {
                      ex.printStackTrace();
                } catch (TransformerException ex) {
                     ex.printStackTrace();
                } catch (Exception ex) {
                     ex.printStackTrace();
                //holds result of transformation.
                return doc ;
    }Following is full exception stacktrace
    ERROR:  'The first argument to the non-static Java function 'myBeanMethod' is not a valid object reference.'
    FATAL ERROR:  'Could not compile stylesheet'
    javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:829)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:623)
            at com.actl.dxchange.utilities.Transformation.transform(Transformation.java:83)
            at com.actl.dxchange.base.BaseConnector.transform(BaseConnector.java:330)
            at com.actl.dxchange.connectors.KuoniConnector.doRequestProcess(KuoniConnector.java:388)
            at com.actl.dxchange.connectors.KuoniConnector.hotelAvail(KuoniConnector.java:241)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            ...........

    Hi,
    Thanks for response.
    Following is code for setting 'methodParamsClasses' array object. I do ensure that Document is not null and valid. My application is web application.
    Document requestObj = /* my code for generating Document object*/
    Object[] methodParams = new Object[]{requestObj}
    Class[] methodParamsClasses = new Class[]{};
                if (methodParams != null) {
                    methodParamsClasses = new Class[methodParams.length];
                    for (int i = 0; i < methodParams.length; i++) {
                        if (methodParams[i] instanceof Document) {
    /************** if parameter is instance of Document then I set class type as "Document.class" ***********/
                            methodParamsClasses[i] = Document.class;
                        } else {
                            methodParamsClasses[i] = methodParams.getClass();

  • XSLT Transform in XML Signature: Exception

    Hello,
    I have following problem with an XSLT tranform in my XML signature. Here is the code I use to add XSLT to signature:
    main() {
    DOMStructure stylesheet = new DOMStructure( getStylesheet() );
    XSLTTransformParameterSpec spec = new XSLTTransformParameterSpec( stylesheet );
    transforms.add( fac.newTransform( Transform.XSLT, spec ) );
    private Element getStylesheet() throws Exception {
         String stylesheet = //"<?xml version=\"1.0\"?>" +
                        "<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
                        " <xsl:include href=\"http://extern XSLT\" />\n" +
                        " <xslt:template match=\"/\">" +
                        " <xsl:apply-imports />" +
                        " </xslt:template>" +
                        "</xslt:stylesheet>\n";
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         //dbf.setValidating( true );
         return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
    I get following exception:
    javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.dsig.TransformException: com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
    Original Exception was com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
         at org.jcp.xml.dsig.internal.dom.DOMReference.transform(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMReference.digest(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.digestReference(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(Unknown Source)
    In google I cannot find any details what can be wrong.
    Any suggestions?
    Thanks in advance,
    errno

    Thanks for your response. Sorry - I tried both versions with xslt and xsl - doesn't worked -> the error in my post is actually caused through the multiple changes of this part of code. Here once again:
    private Element getStylesheet() throws Exception {
              String stylesheet = //"<?xml version=\"1.0\"?>" +
                                       "<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
                                       " <xslt:include href=\"external XSLTl\" />\n" +
                                       " <xslt:template match=\"/\">" +
                                       " <xslt:apply-imports />" +
                                       " </xslt:template>" +
                                       "</xslt:stylesheet>\n";
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              //dbf.setValidating( true );
              return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
    Thanks,
    errno

  • XSLT-ABAP using Call Transformation

    Hello Friends,
    I am new to this XSLT-ABAP transformation. I went through the blogs and forums and got a fair bit of idea on this. Now, i am trying to create a simple program/ xslt transformation to test the scenario. Once this is successfull i need to implement this in our project.
    I am not sure, where and what i am doing wrong. Kindly check the below given XSLT/ XML/ ABAP Program and correct me.
    My XML File looks as given below:
      <?xml version="1.0" encoding="utf-8" ?>
    - <List>
    - <ITEM>
      <ITEMQUALF>ITEM1</ITEMQUALF>
      <MATERIAL>MAT1</MATERIAL>
      </ITEM>
    - <ITEM>
      <ITEMQUALF>ITEM2</ITEMQUALF>
      <MATERIAL>MAT2</MATERIAL>
      </ITEM>
    - <ITEM>
      <ITEMQUALF>ITEM3</ITEMQUALF>
      <MATERIAL>MAT3</MATERIAL>
      </ITEM>
      </List>
    My XSLT Transformation looks as given below:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:template match="*">
        <List>
          <xsl:for-each select="ITEM">
            <xsl:element name="ITEM">
              <xsl:element name="ITEMQUALF">
                <xsl:value-of select="ITEMQUALF"/>
              </xsl:element>
              <xsl:element name="MATERIAL">
                <xsl:value-of select="MATERIAL"/>
              </xsl:element>
            </xsl:element>
          </xsl:for-each>
        </List>
      </xsl:template>
    </xsl:transform>
    My ABAP program looks as below:
    REPORT  ztest_ram.
    TYPES:
      BEGIN OF ty_test,
        itemqualf TYPE char10,
        material  TYPE char10,
      END OF ty_test,
      ty_t_test TYPE STANDARD TABLE OF ty_test.
    DATA:
      l_xml       TYPE REF TO cl_xml_document,
      t_test      TYPE ty_t_test,
      wa_person   TYPE LINE OF ty_t_test,
      t_xml_out   TYPE string,
      v_retcode   TYPE sy-subrc,
      v_totalsize TYPE i.
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Create object
    CREATE OBJECT l_xml.
    * Call method to import data from file
    CALL METHOD l_xml->import_from_file
      EXPORTING
        filename = 'C:\xml\xml_test.xml'
      RECEIVING
        retcode  = v_retcode.
    * Call method to Render into string
    CALL METHOD l_xml->render_2_string
      IMPORTING
        retcode = v_retcode
        stream  = t_xml_out
        size    = v_totalsize.
    * Call Transformation
    TRY.
        CALL TRANSFORMATION (`ZXSLT_RAM`)
                SOURCE XML t_xml_out
                RESULT     outtab = t_test.
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    When i run this ABAP program to fetch the data from XML in to Internal table, i get the error message:
    Incorrect element List for XML-ABAP transformation
    I am really not sure how to proceed further. Could any one help me on this?
    Note: Please do not paste the same links, as i have gone through most of them.
    Thank you.
    Best Regards,
    Ram.

    UPDATE, works now.
    ABAP:
    method IF_HTTP_EXTENSION~HANDLE_REQUEST.
    *THIS METHOD IS AN HTTP INTERFACE FOR A
    *SICF WEB SERVICE HANDLER. IT RECEIVES AN XML PAYLOAD,
    *READS IT INTO AN XSTRING, THEN TRANSFORMS THE
    *XSTRING INTO ABAP DATA USING AN ABAP XSLT
    *TRANSFORMATION PROGRAM
    *Process incoming xml Request
         data: lxs_request TYPE xstring.
         lxs_request = server->request->get_data( ).
    *BUILD DATA TYPES
    TYPES: BEGIN OF ccw_line,
       field11 TYPE STRING,
       field22 TYPE STRING,
       END OF ccw_line.
    TYPES: BEGIN OF ccw_head,
       field1 TYPE STRING,
       field2 TYPE STRING,
       lines TYPE STANDARD TABLE OF ccw_line WITH DEFAULT KEY,
       END OF ccw_head.
    DATA: ccw_heads type STANDARD TABLE OF ccw_head,
           xccw_heads TYPE ccw_head.
    DATA: ccw_lines TYPE STANDARD TABLE OF ccw_line,
           zccw_lines TYPE ccw_line.
    DATA: lr_transformation_error TYPE REF TO cx_transformation_error.
    DATA: err_text TYPE string.
    *CALL TRANSFORMATION
    TRY.
       CALL TRANSFORMATION zccwpayload_prg
       SOURCE XML lxs_request
       RESULT OUTPUT = ccw_heads.   "RESULT PARAMETER ("OUTPUT") NAME MUST EQUAL TRANSFORMED XML ROOT eg <OUTPUT>XML DATA...</OUTPUT>
    * RESULT XML my_xml_result.    "THIS CAN BE USED IF YOU WANT TO RETURN XML INSTEAD OF ABAP DATA
       CATCH cx_xslt_exception INTO lr_transformation_error.
       err_text = lr_transformation_error->get_text( ).
       server->response->set_cdata( err_text ).
    ENDTRY.
    *SAVE TO DATABASE
    *BUILD RESPONSE
    call METHOD server->response->set_cdata
         EXPORTING
             DATA = err_text.
    endmethod.
    XML SOURCE:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <HEADS> <!--MATCH ON THIS IN XSLT!!!-->
          <HEAD><!-- FOR-EACH ON THIS-->
                <headval1>myHeader</headval1>
                <LINES>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                </LINES>
          </HEAD>
          <HEAD>
                <headval1>myHeader</headval1>
                <LINES>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                </LINES>
          </HEAD>
          <HEAD>
                <headval1>myHeader</headval1>
                <LINES>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                      <Line>
                            <lineval1>myLine</lineval1>
                      </Line>
                </LINES>
          </HEAD>
    </HEADS>
    XSLT PROGRAM:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
       <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
       <xsl:template match="/HEADS"><!--This should be the root name of your source XML eg <HEADS>xml data...</HEADS> if you don't have a single root match on "/" -->
         <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
           <asx:values>
             <OUTPUT><!--MUST be all caps, MUST match CALL TRANSFORMATION RESULTS parameter name (RESULTS OUTPUT = myABAPDataStructure), and MUST not contain an underscore!!!-->
               <xsl:for-each select="HEAD">
                 <HEAD>            <!--ALL CAPS!!!-->
                   <FIELD1>
                     <xsl:value-of select="headval1"/>
                   </FIELD1>
                   <FIELD2>
                     <xsl:value-of select="headval1"/>
                   </FIELD2>
                   <LINES>
                     <xsl:for-each select="LINES/Line">
                       <LINE>
                         <FIELD11>
                           <xsl:value-of select="lineval1"/>
                         </FIELD11>
                         <FIELD22>
                           <xsl:value-of select="lineval1"/>
                         </FIELD22>
                       </LINE>
                     </xsl:for-each>
                   </LINES>
                 </HEAD>
               </xsl:for-each>
             </OUTPUT>
           </asx:values>
         </asx:abap>
       </xsl:template>
    </xsl:transform>
    SAMPLE OF TRANSFORMED XML (MATCHES ABAP DATA STRUCTURE):
    IF YOU TEST () YOUR TRANSFORMATION (IN XSLT_TOOL) WITH THE SAMPLE FILE AND IT DOESN'T LOOK LIKE THIS, YOUR TRANSFORMATION WILL FAIL. TAGS MUST BE ALL CAPS!!!!
    <?xml version="1.0" encoding="UTF-8"?>
    <asx:abap version = "1.0" xmlns:asx = "http://www.sap.com/abapxml">
          <asx:values>
                <OUTPUT>
                      <HEAD>
                            <FIELD1>myHeader</FIELD1>
                            <FIELD2>myHeader</FIELD2>
                            <LINES>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                            </LINES>
                      </HEAD>
                      <HEAD>
                            <FIELD1>myHeader</FIELD1>
                            <FIELD2>myHeader</FIELD2>
                            <LINES>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                            </LINES>
                      </HEAD>
                      <HEAD>
                            <FIELD1>myHeader</FIELD1>
                            <FIELD2>myHeader</FIELD2>
                            <LINES>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                                  <LINE>
                                        <FIELD11>myLine</FIELD11>
                                        <FIELD22>myLine</FIELD22>
                                  </LINE>
                            </LINES>
                      </HEAD>
                </OUTPUT>
          </asx:values>
    </asx:abap>

  • XML Transformation using XSLT

    Hi,
    I have a scenario where I need to perform an XML to XML transformation and I need to do this using XSLT mapping.
    I am using XMLSpy.
    Could somebody help me on this issue?Any weblogs that can help me on this?
    regards,
    Prashanth

    Hi Prashanth,
    You can do the xsl transformation in XMLSpy itself.First create your source xml file in XMLSpy by selecting file type as xml.After that create your xslt program file by selecting file type as xslt.
    Then you can use the xslt program for transformation of source xml into target xml by choosing menu XSL/XQuery->XSL Transformation.
    sample xsl code for an example:
    source xml structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
         <header>
              <detail>
    Detail1
    </detail>
              <detail>
    Detail2
    </detail>
         </header>
         <header>
              <detail>
    Detail3
    </detail>
         </header>
    </root>
    xsl program:
    <xsl:stylesheet version = '1.0'
         xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    <xsl:template match="/">
         <root>
         <xsl:for-each select="//header">
               <idoc>
                <xsl:for-each select="detail">
                    <detail>
                          <xsl:value-of select="."/>
                       </detail>
                       </xsl:for-each>
                   </idoc>
              </xsl:for-each>
         </root>
    </xsl:template>
    </xsl:stylesheet>
    target xml structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
         <idoc>
              <detail>
    Detail1
    </detail>
              <detail>
    Detail2
    </detail>
         </idoc>
         <idoc>
              <detail>
    Detail3
    </detail>
         </idoc>
    </root>
    Hope this would help.
    Rgds
    Sudhakar.

Maybe you are looking for