ABAP XSLT transformation - XML to deep structure/nested standard table

Hi all,
I was struggling with this topic recently and couldn't find a single working example or description of a possible solution. So now that I've sorted it out, I did a quick example to elustrate how it works. Here is the code with XML embeded in it and the XSLT follows:
<HR>
<PRE>
*& Report  Z_XML2ABAP
*& Author: Jayanta Roy
*& Date: 03/02/2010
REPORT  z_xml2abap.
DATA input_xml TYPE string.
TYPES: BEGIN OF t_address,
        house_no TYPE string,
        street_name TYPE string,
        city_name TYPE string,
        phone_no TYPE string,
      END OF t_address.
TYPES: t_addresses TYPE STANDARD TABLE OF t_address with NON-UNIQUE KEY house_no.
TYPES: BEGIN OF t_person,
        firstname TYPE string,
        surname TYPE string,
        addresses TYPE t_addresses,
      END OF t_person.
input_xml = '&lt;Friends&gt;' &&
  '&lt;People&gt;' &&
    '&lt;FirstName&gt;Homer&lt;/FirstName&gt;' &&
    '&lt;Surname&gt;Simpson&lt;/Surname&gt;' &&
      '&lt;Address&gt;' &&
        '&lt;HouseNo&gt;123&lt;/HouseNo&gt;' &&
        '&lt;Street&gt;Evergreen Terrace&lt;/Street&gt;' &&
        '&lt;City&gt;Springfield&lt;/City&gt;' &&
        '&lt;PhoneNo&gt;011212321&lt;/PhoneNo&gt;' &&
      '&lt;/Address&gt;' &&
      '&lt;Address&gt;' &&
        '&lt;HouseNo&gt;7G&lt;/HouseNo&gt;' &&
        '&lt;Street&gt;Neuclear Power Plant&lt;/Street&gt;' &&
        '&lt;City&gt;Spring Field&lt;/City&gt;' &&
        '&lt;PhoneNo&gt;911&lt;/PhoneNo&gt;' &&
      '&lt;/Address&gt;' &&
  '&lt;/People&gt;' &&
  '&lt;People&gt;' &&
     '&lt;FirstName&gt;Bart&lt;/FirstName&gt;' &&
     '&lt;Surname&gt;Simpson&lt;/Surname&gt;' &&
       '&lt;Address&gt;' &&
         '&lt;HouseNo&gt;123x&lt;/HouseNo&gt;' &&
         '&lt;Street&gt;Evergreen Terracex&lt;/Street&gt;' &&
         '&lt;City&gt;Springfieldx&lt;/City&gt;' &&
         '&lt;PhoneNo&gt;011212321x&lt;/PhoneNo&gt;' &&
       '&lt;/Address&gt;' &&
   '&lt;/People&gt;' &&
'&lt;/Friends&gt;' .
DATA lt_person TYPE STANDARD TABLE OF t_person.
TRY.
    CALL TRANSFORMATION xslt_person
    SOURCE XML input_xml
    RESULT  all_people = lt_person.
  CATCH cx_root.
    WRITE 'Problemo!'.
ENDTRY.
WRITE 'Now, debug the program to see the values read from the XML'.
</PRE>
<HR>
and here is the XSLT Transformation program (xslt_person):
<HR>
<PRE>
&lt;xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:sap="http://www.sap.com/sapxsl" version="1.0"&gt;
  &lt;xsl:strip-space elements="*"/&gt;
  &lt;xsl:template match="/"&gt;
    &lt;asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"&gt;
      &lt;asx:values&gt;
        &lt;ALL_PEOPLE&gt;
          &lt;xsl:apply-templates select="//People"/&gt;
        &lt;/ALL_PEOPLE&gt;
      &lt;/asx:values&gt;
    &lt;/asx:abap&gt;
  &lt;/xsl:template&gt;
  &lt;xsl:template match="People"&gt;
    &lt;ALLMYFRIENDS&gt;  &lt;!This element name is not relevent... needed to just group the loop&gt;
      &lt;FIRSTNAME&gt;
        &lt;xsl:value-of select="FirstName"/&gt;
      &lt;/FIRSTNAME&gt;
      &lt;SURNAME&gt;
        &lt;xsl:value-of select="Surname"/&gt;
      &lt;/SURNAME&gt;
      &lt;ADDRESSES&gt;
        &lt;xsl:for-each select="Address"&gt;
          &lt;ADDRESS&gt; &lt;!This element name is not relevent... needed to just group the loop&gt;
            &lt;HOUSE_NO&gt;
              &lt;xsl:value-of select="HouseNo"/&gt;
            &lt;/HOUSE_NO&gt;
            &lt;STREET_NAME&gt;
              &lt;xsl:value-of select="Street"/&gt;
            &lt;/STREET_NAME&gt;
            &lt;CITY_NAME&gt;
              &lt;xsl:value-of select="City"/&gt;
            &lt;/CITY_NAME&gt;
            &lt;PHONE_NO&gt;
              &lt;xsl:value-of select="PhoneNo"/&gt;
            &lt;/PHONE_NO&gt;
          &lt;/ADDRESS&gt;
        &lt;/xsl:for-each&gt;
      &lt;/ADDRESSES&gt;
    &lt;/ALLMYFRIENDS&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:transform&gt;
</PRE>
<HR>
HTH,
Jayanta.

thanks a LOT Jayanta..
I was looking for an XSLT example for some time.. this one atleast got me started in the right direction..
THANKS

Similar Messages

  • Using XSLT Transformation to Load Deep Structure

    Greetings!
    I have the need to load data from an XML file into a structure that contains a nested table.   I've written the XSLT to load the basic structure but I'm not familiar enough with XSLT to know how to populate the nested table.  I've searched SDN and can't find a suitable example.
    Any help would be most appreciated!  Thanks!

    This might help.  These are the structures and the XML data file I'm using.  I can get all of the nodes to load except for the internal table (TS_PERSON-LIFE_PLANS).  I tried using an XSLT:FOR-EACH but without any success.  Honestly, I'm just shooting in the dark. 
    All I need to do is get that internal table loaded.
    ABAP Structures
    TYPES:
          BEGIN OF ts_lifeplan,
            begda   TYPE pa0168-begda,
            endda   TYPE pa0168-endda,
            bplan   TYPE pa0168-bplan,
            ercost  TYPE char9,
          END OF ts_lifeplan.
    DATA: lt_lifeplans TYPE TABLE OF ts_lifeplan.
    TYPES:
          BEGIN OF ts_person,
            ssn       TYPE pa0002-perid,
            lastname  TYPE pa0002-nachn,
            firstname TYPE pa0002-vorna,
            midname   TYPE pa0002-midnm,
            dob       TYPE char8,
            gender    TYPE pa0002-gesch,
            address1  TYPE pa0006-stras,
            address2  TYPE pa0006-locat,
            city      TYPE pa0006-ort01,
            state     TYPE pa0006-state,
            county    TYPE pa0006-zcounty,
            zip       TYPE pa0006-pstlz,
            homephone TYPE pa0006-telnr,
            workphone TYPE pa0006-num01,
            email     TYPE pa0105-usrid_long,
            hiredate  TYPE char8,
            eligdate  TYPE char8,
            retidate  TYPE char8,
            life_plans LIKE lt_lifeplans,
           END OF ts_person.
    XML
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <BENEFIT_ADJUSTMENTS>
         <ADJUSTMENT>
              <SSN>123456789</SSN>
              <LASTNAME>King</LASTNAME>
              <FIRSTNAME>Steve</FIRSTNAME>
              <MIDNAME>Mark</MIDNAME>
              <DOB>09111972</DOB>
              <GENDER>1</GENDER>
              <ADDRESS1>125 Allison Circle</ADDRESS1>
              <ADDRESS2>Suite 100</ADDRESS2>
              <CITY>Nicholasville</CITY>
              <STATE>KY</STATE>
              <COUNTY>036</COUNTY>
              <ZIP>40356     </ZIP>
              <HOMEPHONE>8594331541</HOMEPHONE>
              <WORKPHONE>5025645529</WORKPHONE>
              <HIREDATE>01012010</HIREDATE>
              <ELIGDATE>03012010</ELIGDATE>
              <RETIDATE>01012050</RETIDATE>
              <LIFE_PLANS>
                   <BEGDA>01012010</BEGDA>
                   <ENDDA>12319999</ENDDA>
                   <BPLAN>A100</BPLAN>
                   <ERCOST>50</ERCOST>
              </LIFE_PLANS>
         </ADJUSTMENT>
    </BENEFIT_ADJUSTMENTS>
    XSLT:

  • How to read  xml with deep  structure into intarnal table.

    Hi,
    Could you pls any body provide xslt code for deep structure  convert into internal table.
    sample xml file:
    - <ns0:CREATIONOFCONTRACT xmlns:ns0="http://BPCreationXSD.CreationOfContract">
    - <CREATIONOFCONTRACTDATA>
      <RequestType>L0011</RequestType>
      <ApplicationId>AN-12</ApplicationId>
      <LoanId>QO-22</LoanId>
    - <Borrowerguarantorinfo>
      <Borrowerbpno>101020</Borrowerbpno>
      <Co-borrower1BPNo>101021</Co-borrower1BPNo>
      <Co-borrower2BPNo>101022</Co-borrower2BPNo>
      <Guarantor1BPNo>101023</Guarantor1BPNo>
      <Guarantor2BPNo>101024</Guarantor2BPNo>
      <Branch>New Delhi</Branch>
      </Borrowerguarantorinfo>
    - <Loaninfo>
      <Applicationtype>Fresh</Applicationtype>
      <Purposeofloan>Home Purchase</Purposeofloan>
      <Securedunsecuredflag>Secured</Securedunsecuredflag>
      <Loantype>HL with MRTA</Loantype>
      <Loancurrency>INR</Loancurrency>
      <Loanproduct>MaxiHome Loan Package</Loanproduct>
      <Loanscheme>MaxiHome ZEC</Loanscheme>
      <Loanamount>1500000.00</Loanamount>
      <Loantenure>60</Loantenure>
      <Tiered>No</Tiered>
      </Loaninfo>
      <Periodfrom>01/07/2009</Periodfrom>
      <Periodto>16/09/2019</Periodto>
      <RateType>Fixed</RateType>
      <Ratecode>10.25</Ratecode>
      </CREATIONOFCONTRACTDATA>
      </ns0:CREATIONOFCONTRACT>

    Hi Ramesh,
    Thanks for the info,but I found lot of tables unfortunately I am not getting the value for radio buttons. Also I found a FM FIELD_SELECTION_CUSTOMIZE , IMPORT_DYNPRO etc which will call that screen based on profile but it will not store data any where. I found several tables like TCATS, TFAWC, TFAWF, TFAWT etc.But I am not getting the value for raduio buttons.
    Thanks & Regards,
    Nagaraj Kalbavi

  • [ECC6] Inserting data from internal table (deep structure) into db table

    Hi experts,
    I have a problem when inserting data from IT using deep structure into a database table. Please help:
    I have one database table with 2 columns ZTest (col1, col2). Col1 is key.
    In my program I have a deep structure t_screen using table type lvc_t_scol:
    In 4.6c systems, the INSERT statement works well but it does not work in ECC6 systems.
    DATA: BEGIN OF t_screen OCCURS 0,
            rec_count(3) TYPE n,
            col1 LIKE ZTest-col1,
            col2 LIKE ZTest-col2.
    DATA: ct TYPE lvc_t_scol.
    DATA: END   OF t_screen.
    t_screen-col1 = 'test1'.
    t_screen-col2 = 'test1'.
    APPEND t_screen.
    t_screen-col1 = 'test2'.
    t_screen-col2 = 'test2'.
    APPEND t_screen.
    INSERT ZTest FROM TABLE t_screen ACCEPTING DUPLICATE KEYS.
    Currently I have an idea using a temporary internal table with the same structure as ZTest. Use MOVE-CORRESPONDING statement to move data from t_screen table to temporary table before inserting --> It worked. But do you have any ideas without using temporary table?

    Hi
    There are a large number of stataments couldn't be supported in unicode system and so it doesn't allow to do it in ECC 6.
    U need to delete the deep structure from your defination:
    DATA: BEGIN OF t_screen OCCURS 0,
            rec_count(3) TYPE n,
            col1 LIKE ZTest-col1,
            col2 LIKE ZTest-col2.
    DATA: ct TYPE lvc_t_scol. "<-------- Error is here
    DATA: END   OF t_screen.
    So u need to use a structure like this to update your table:
    DATA: BEGIN OF T_ZTEST OCCURS 0,
            rec_count(3) TYPE n,
            col1 LIKE ZTest-col1,
            col2 LIKE ZTest-col2.
    DATA: END   OFT_ZTEST.
    Max

  • Append Structure in Standard Table

    Hi Gurus,
    My problem Is:---
    I create an Append Structure on Standard Table..it create successfully..but after it, when i want to activate the standard table, it gives errors....
    Not standard table is partially active...
    I want to reverse it back...how it is possible....
    My Solution:.. I try my besy through SE14...there I give the Table name and click on EDIT...
    there i click on Activate and Adjust Database...but there it gives errors....
    Append structure ZMARC11 appended to table MARC
    Current enhancement classification 'enhanceable and numeric or char.type' is incorrect
    The following enhancement classifications can be selected:
        'Can Be Enhncd(Deep)'
    Field MATNR in table MARC is specified twice. Please check
    Field MATNR: Reference MATNR to class w/o interface cannot be used in DB table MARC
    Field MEINS: Reference MEINS to class w/o interface cannot be used in DB table MARC
    Attachment of search help MAT1 to field MARC-MATNR is deleted
    Activation of Table MARC not possible (please check)
    Request for MARC could not be executed..
    Plz. Help....

    Hi,
    I know the fields name...
    MARC-MATNR...and MARC-MEINS...
    How can i revert back....
    Plz Help...

  • Error in ABAP XSLT transformation

    Hi,
    Im trying to upload some data from XML to abap. But Im getting an error while transforming xml data to internal table.
    Here are the details.
    XML:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!--  Edited by XMLSpy® -->
    <?xml-stylesheet type="text/xsl" href="ABAP1.xsl"?>
    <conceptRevDecisionXml>
    <projectInfo>
    <projectId>P000755</projectId>
    <stage>CON</stage>
    <country>Ethiopia</country>
    <region>AFRICA</region>
    <teamleader>Priya Agarwal</teamleader>
    <teamleaderfirstname>Priya</teamleaderfirstname>
    <teamleaderlastname>Agarwal</teamleaderlastname>
    <actionType>X</actionType>
    </projectInfo>
    </conceptRevDecisionXml>
    XSLT: Transformation
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sapxsl="http://www.sap.com/sapxsl"
    >
    <xsl:strip-space elements="*"></xsl:strip-space>
    <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <PROJID>
              <xsl:apply-templates select="//conceptRevDecisionXml"></xsl:apply-templates>
            </PROJID>
          </asx:values>
        </asx:abap>
    </xsl:template>
    <xsl:template match="conceptRevDecisionXml">
          <xsl:for-each select="projectInfo">
           <xsl:value-of select="projectId"></xsl:value-of>
           <xsl:value-of select="stage"></xsl:value-of>
           <xsl:value-of select="country "></xsl:value-of>
           <xsl:value-of select="region"></xsl:value-of>
           <xsl:value-of select="teamleader"></xsl:value-of>
           <xsl:value-of select="teamleaderfirstname"></xsl:value-of>
           <xsl:value-of select="teamleaderlastname"></xsl:value-of>
            <xsl:value-of select="actionType"></xsl:value-of>
            </xsl:for-each>
        </xsl:template>
    </xsl:transform>
    Once I run the program...Im getting an error saying...ABAP XML Formatting error in XML node..
    Im new to ABAP-XML parsing..Pls help me where Im going wrong..
    Thanks in advance.
    Regards,
    Priya

    Hi Priya,
    you can try with the below,
    1) Create a local ITAB with the structure of the XML,
    TYPES: BEGIN OF t_data,
            projectid           TYPE char30,
            stage               TYPE char30,
            country             TYPE char30,
            region              TYPE char30,
            teamleader          TYPE char30,
            teamleaderfirstname TYPE char30,
            teamleaderlastname  TYPE char30,
            actiontype          TYPE char30,
           END OF t_data.
    2) Create an XSLT prog in "STRANS" with the below code,
    <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="/">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <L_DATA>
    <xsl:apply-templates select="//projectInfo"/>
    </L_DATA>
    </asx:values>
    </asx:abap>
    </xsl:template>
    <xsl:template match="projectInfo">
    <conceptRevDecisionXml>
    <PROJECTID>
    <xsl:value-of select="projectId"/>
    </PROJECTID>
    <STAGE>
    <xsl:value-of select="stage"/>
    </STAGE>
    <COUNTRY>
    <xsl:value-of select="country"/>
    </COUNTRY>
    <REGION>
    <xsl:value-of select="region"/>
    </REGION>
    <TEAMLEADER>
    <xsl:value-of select="teamleader"/>
    </TEAMLEADER>
    <TEAMLEADERFIRSTNAME>
    <xsl:value-of select="teamleaderfirstname"/>
    </TEAMLEADERFIRSTNAME>
    <TEAMLEADERLASTNAME>
    <xsl:value-of select="teamleaderlastname"/>
    </TEAMLEADERLASTNAME>
    <ACTIONTYPE>
    <xsl:value-of select="actionType"/>
    </ACTIONTYPE>
    </conceptRevDecisionXml>
    </xsl:template>
    </xsl:transform>
    3) Call the transformation as shown below,
    CALL TRANSFORMATION zxslt_project ---> "Name of the XSLT prog created above
    SOURCE XML l_xml_str                           ---> Source XML string
    RESULT l_data = l_data.                          ---> ITAB as in step 1 above
    Regards,
    Chen

  • XSLT Transformation error:  Non-canonical structure of element name

    Good day experts,
    I have recently started using xslt, and came upon the following demo in the sdn.
    http://wiki.sdn.sap.com/wiki/display/ABAP/XMLXSLTwith+ABAP
    I have retrieved the example xml files from airplus.com, as per the instructions, and implemented the code.
    When I test the xslt transformation in se80, it transforms correctly.
    However, when I run the program, I get the following error.
    CX_XSLT_FORMAT_ERROR
    Transformation error:  Non-canonical structure of element name XML_OUTPUT   
    Is there an error in the example that I am not aware of?
    Thanks in advance,
    Johan Kriek

    Found the solution.
    You rename the tag <XML_OUTPUT> to anything else like <TEST>. And Hurray!!! it works.
    It looks like SAP is using this name internally somewhere so we are getting error when we are using same name.
    Anyways the problem is solved.
    Regards,
    Jai

  • Execute a query using ABAP  (XSLT transformation issue)

    Hello,
    I made the steps from this blog (part I, II and III).
    /people/durairaj.athavanraja/blog/2005/12/05/execute-bw-query-using-abap-part-iii
    When trying to run the XSLT transformation, I got the message that : XML invalid source file.
    I am not sure what are the steps for running a transformation, or running it for this case ,maybe something it's not ok. I just run it, did not provide any information.
    Any suggestions ? Did anyone use the function module described in this blog ?
    Thank you very much in advance.

    try giving
    CALL TRANSFORMATION (`ID`)
    SOURCE meta = meta_data[]
    output = <ltable>[]
    RESULT XML xml_out
    OPTIONS xml_header = 'NO'.
    and check - sometimes the codepages configured in the BW system tend to cause an issue... I am not sure if the syntax is right though - but you are basically trying to bypass any encoding that is happening in the query transformation....
    http://www.sapetabap.com/ovidentia/index.php?tg=fileman&sAction=getFile&inl=1&id=4&gr=Y&path=ABAP%2FABAPENANGLAIS&file=ABAP-XML+Mapping.pdf&idf=41
    Edited by: Arun Varadarajan on May 18, 2009 11:28 PM

  • ABAP XSLT Transformation using element include

    Hi there,
    I am trying to convert data from SAP-DATA -> DOM over XSLT to a Stream.
    For achieving this I have to use certain modularized XSL-Files which will later be accessible over http. At the moment however, those files are on my local hard drive (client) only. I tried to access these files using:
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sap="http://www.sap.com/sapxsl"
    >
    *<xsl:include href="D:\XSL\include.xsl"/>*
    <xsl:strip-space elements="*"/>
    <xsl:template match="/">
    </xsl:template>
    </xsl:transform>
    I get the message "D:\XSL\include.xsl doesn't exist" when checking the syntax. When I test this in my OS however, it works perfectly. Being an SAP- and XML-Newbie my question is the following: Does SAP not know my hard drive mappings while I'm in a transformation or can i only access directories over al11/http. Or is it complete nonsense at all? 
    Regards, Lukas
    Edited by: Lukas Weigelt on Jun 9, 2010 4:18 PM

    Hi,
    according to:
    >
    Michal_Krawczyk_PIXI wrote:
    > as per:
    > http://help.sap.com/saphelp_470/helpdata/EN/84/2e4d3ce624b800e10000000a114084/frameset.htm
    > "The href attribute no longer applies in this case."
    it appears the include element only works with the repository.... I tried
    <xsl:include sap:name="<Name_of_the_Transformation_in_Repository>"/>
    and it works.
    However this would mean, all includes i have to make have to be imported to the repository. If that's really the case, it'll be a huge problem, because the xsl-files i want to include are outside of my reference
    Regards, Lukas

  • XSLT Transform XML 2 HTML does not work well

    Hi,
    This is my first attempt to use XSLT to convert my XML file into HTML using Java. I have included below the java code I used for the transformation, the xsl file and the xml file.
    As per the xml file, I would like to display the carrier's common-name for each host. However, I can only get to display the carrier-id using the code line
    <xsl:value-of select="./@carrier"/>
    as shown in the last part of the xsl file, but cannot get the carrier's commonname from the carrierid using the code,
    <xsl:variable name="hostCarr" select="./@carrier"/>
    <xsl:variable name="hostcomName" select="id($hostCarr)/common-name"/>
    <xsl:value-of select="$hostcomName"/>
    However this works well if I were to use XML SPY for the conversion, instead of the Transform class in Java. I am using version 1.4.1 of Java.
    Please help.
    Thanks,
    Prasuna
    XML file
    <pathinfo pathogen-name="Brucella spp.">
         <taxonomy>
              <carrier carrierID="wild">
                   <common-name>Wild cies</common-name>
              </carrier>
              <carrier carrierID="sheepandgoats">
                   <common-name>Domestic Pig</common-name>
              </carrier>
              <carrier carrierID="lab">
                   <common-name>Laboratory environment</common-name>
              </carrier>
         </taxonomy>
         <host-list>
              <host carrier="wild"></host>
              <host carrier="lab"></host>
              <host carrier="sheepandgoats"></host>
         </host-list>
    </pathinfo>
    XSL file
    <xsl:stylesheet version="1.0" xmlns:a="http://www.xmlspy.com/schemas/orgchart" xmlns:ipo="http://www.altova.com/IPO" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" omit-xml-declaration="no" indent="no" media-type="text/html"/>
         <xsl:template match="pathinfo">
              <html>
                   <head><title><xsl:value-of select="@pathogen-name"/></title>
                   </head>
                   <body bgcolor="#ffffe5" text="#000000" link="#007a00" vlink="#7a0000" alink="#ff0000">
                        <xsl:apply-templates select="host-list"/>
                   </body>
              </html>
         </xsl:template>
         <xsl:template match="host-list">
              <ol>
                   <xsl:for-each select="host">
                        <li>
                             <xsl:variable name="hostCarr" select="./@carrier"/>
                             <xsl:variable name="hostcomName" select="id($hostCarr)/common-name"/>
                             <!--
                             <xsl:value-of select="./@carrier"/>
                             <xsl:value-of select="$hostcomName"/>
                             -->
                             <xsl:value-of select="$hostcomName"/>
                        </li>
                   </xsl:for-each>
              </ol>
         </xsl:template>
    </xsl:stylesheet>
    Java Code
    import javax.xml.transform.*;
    import java.net.*;
    import java.io.*;
    public class Xml2Html {
    public static void main(String[] args) {
    try {
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer =
    tFactory.newTransformer
    (new javax.xml.transform.stream.StreamSource
    ("temp.xsl"));
    transformer.transform
    (new javax.xml.transform.stream.StreamSource
    ("temp.xml"),
    new javax.xml.transform.stream.StreamResult
    ( new FileOutputStream("temp.html")));
    catch (Exception e) {
    e.printStackTrace( );

    From Michael Kay's book "XSLT Programmer's Reference":
    'A non-validating XML parser isn't required to read attribute definitions from an external DTD. In this situation the XSLT processor will assume there are no ID attributes present, and the id() function will always return an empty result."
    Presumably you didn't set your transformer to use a validating parser, and I don't even see a reference to a DTD there. However the expression id('X') is equivalent to //*[@id='X'], Kay goes on to say. Try that instead.

  • Remove Appended Structure from standard table

    Hi Experts,
    I have appended a Z structure to table VBAP.
    I want to remove it now. How can I do?
    Rajiv Ranjan

    Hi Rajiv Ranjan,
    to delete the append structure from the database table, follow the points
    1. Goto se11
    2. enter your append structure name.
    3. press delete
    4. It will delete this append,
    also in the original table/structure
    where it is used, AUTOMATICALLY.
    5.now the data base table VBAP is partially active so
    go to tcode se14 and give the table name and click on EDIT button
    and click on ACTIVATE AND ADJUST button.
    then it will work.
    if it is not possible reply to me.
    regards
    sreenivas

  • XSLT transformation for deep structure .....

    Hello,
            I am trying to do an XSLT transformation for a deep structure HAP_S_PDF_DOCUMENT (see it in SE11), I have managed to achieve this. but not with perfection. i still get some redundant data and data have been experiencing Data duplication. I was hoping if you people point out the what is wrong in the transfromation. The data repeats for every once under node DATA and then under node of the refered structure name. Besides it also create a blank row even if the record is 0. I am mostly facing problem with nodes T_ELEMENTS. T_COL_CELL and T_FIELD. These are the nested structures, Can anybody help / guide me to achieve these transforamtion?
    <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="HAP_DOCUMENT">
    <xsl:element name="HAP_DOCUMENT" namespace="">
    <xsl:apply-templates select="MAIN_HEADER"/>
    <xsl:apply-templates select="T_ELEMENTS"/>
    <xsl:apply-templates select="T_STAT_CHG_BUTTONS"/>
    <xsl:apply-templates select="S_APPRAISAL_ID"/>
    <xsl:apply-templates select="S_HEADER"/>
    <xsl:apply-templates select="POSITIONS"/>
    <xsl:element name="STAT_CHG_BUTTON">
    <xsl:value-of select="../STAT_CHG_BUTTON"/>
    </xsl:element>
    <xsl:element name="OFFLINE_ID">
    <xsl:value-of select="OFFLINE_ID"/>
    </xsl:element>
    <xsl:element name="BSP_FLAG">
    <xsl:value-of select="BSP_FLAG"/>
    </xsl:element>
    <xsl:element name="ROLE">
    <xsl:value-of select="ROLE"/>
    </xsl:element>
    <xsl:element name="APPRAISAL_YEAR">
    <xsl:value-of select="APPRAISAL_YEAR"/>
    </xsl:element>
    </xsl:element>
    </xsl:template>
    <xsl:template match="MAIN_HEADER">
    <xsl:element name="MAIN_HEADER">
    <xsl:for-each select="ZBGAPR_FORM_HEADER">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_ELEMENTS">
    <xsl:element name="T_ELEMENTS">
    <xsl:for-each select="ZHAP_S_PDF_ELEMENTS">
    <xsl:element name="DATA">
    <xsl:apply-templates select="T_COL_CELL"/>
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_COL_CELL">
    <xsl:element name="T_COL_CELL">
    <xsl:for-each select="ZHAP_S_PDF_COL_CELL">
    <xsl:element name="DATA">
    <xsl:apply-templates select="T_FIELD"/>
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_FIELD">
    <xsl:element name="T_FIELD">
    <xsl:for-each select="ZHAP_S_PDF_FIELD">
    <xsl:element name="DATA">
    <xsl:apply-templates select="T_VAL_VALUES"/>
    <xsl:apply-templates select="T_VAL_RANGES"/>
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_VAL_VALUES">
    <xsl:element name="T_VAL_VALUES">
    <xsl:for-each select="HAP_S_BODY_CELL_VAL_VALUES">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_VAL_RANGES">
    <xsl:element name="T_VAL_RANGES">
    <xsl:for-each select="HAP_S_BODY_CELL_VAL_RANGES">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_STAT_CHG_BUTTONS">
    <xsl:element name="T_STAT_CHG_BUTTONS">
    <xsl:for-each select="HAP_S_BODY_CELL_VAL_RANGES">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_APPRAISAL_ID">
    <xsl:element name="S_APPRAISAL_ID">
    <xsl:copy-of select="node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_HEADER">
    <xsl:element name="S_HEADER">
    <xsl:apply-templates select="S_TEXTS"/>
    <xsl:apply-templates select="T_APPRAISER"/>
    <xsl:apply-templates select="T_APPRAISEE"/>
    <xsl:apply-templates select="T_PART_APPRAISER"/>
    <xsl:apply-templates select="T_OTHERS"/>
    <xsl:apply-templates select="S_STATUS"/>
    <xsl:apply-templates select="S_DATES"/>
    <xsl:apply-templates select="S_DISPLAY"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="POSITIONS">
    <xsl:element name="POSITION">
    <xsl:for-each select="ZBGHR_APR_POSITION_DET">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_TEXTS">
    <xsl:element name="S_TEXTS">
    <xsl:copy-of select="node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_APPRAISER">
    <xsl:element name="T_APPRAISER">
    <xsl:for-each select="HAP_S_PDF_APPRAISER">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_APPRAISEE">
    <xsl:element name="T_APPRAISEE">
    <xsl:for-each select="HAP_S_PDF_APPRAISEE">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_OTHERS">
    <xsl:element name="T_OTHERS">
    <xsl:for-each select="HAP_S_PDF_OTHERS">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_PART_APPRAISER">
    <xsl:element name="T_PART_APPRAISER">
    <xsl:for-each select="HAP_S_PDF_PART_APPRAISERS">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="T_PART_APPRAISER">
    <xsl:element name="T_PART_APPRAISER">
    <xsl:for-each select="HAP_S_PDF_PART_APPRAISERS">
    <xsl:element name="DATA">
    <xsl:copy-of select="child::node()"/>
    </xsl:element>
    </xsl:for-each>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_STATUS">
    <xsl:element name="S_STATUS">
    <xsl:copy-of select="node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_DATES">
    <xsl:element name="S_DATES">
    <xsl:copy-of select="node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="S_DISPLAY">
    <xsl:element name="S_DISPLAY">
    <xsl:copy-of select="node()"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="STAT_CHG_BUTTON">
    </xsl:template>
      <xsl:template match="OFFLINE_ID">
    </xsl:template>
      <xsl:template match="BSP_FLAG">
    </xsl:template>
      <xsl:template match="ROLE">
    </xsl:template>
      <xsl:template match="APPRAISAL_YEAR">
    </xsl:template>
    </xsl:transform>
    Regards,
    Shishir.P

    "XSLT transformation for a deep structure"
    which way abap to xml or xml to abap?
    you may want to check this thread
    Re: Problem converting XML back to structure using XSLT

  • How to use STRANS to translate XML to ABAP with deep structure

    every experts, I want to use Tcode: STRANS to translate XML to ABAP, But it does not work well,
    here is XML code,I want to translate this XML into an an Inter table gt_orders with deep structure of oeb, and colum oeb is also and intertable,how can I do this.
    <?xml version="1.0" encoding="gb2312" ?><axmt410><ObjectID>setSalesOrder</ObjectID><azp01>000000</azp01><oea00>1</oea00><ta_oeaecn>SO-140227-3041</ta_oeaecn><oea03>25325017</oea03><oea02>2014-02-27 17:44:44.0</oea02><ta_oea002>2763.0</ta_oea002><ta_oea001>0.0</ta_oea001><oea14></oea14><oea15>25325017</oea15><oea23>RMB</oea23><oeaconf>S3</oeaconf><oea10></oea10><oeaud01>null</oeaud01><ta_oea007></ta_oea007><oea25>101</oea25><ta_oea008>0</ta_oea008><ta_oea009>null</ta_oea009><oeauser>Hanjingya</oeauser><ta_oeanday>2014-02-27 17:44:44.991</ta_oeanday><ta_oeamday>2014-02-28 08:30:14.866</ta_oeamday><ta_oeacday>2014-02-28 08:30:14.866</ta_oeacday><oeaud02>0</oeaud02><ta_oea030>null</ta_oea030><oeb><oeb03>1</oeb03><oeb04>7400208249</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address1</ta_oeb003><ta_oeb004>zhangdagui、zhanglan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb><oeb><oeb03>2</oeb03><oeb04>7400208250</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address2</ta_oeb003><ta_oeb004>zhangdagui、chenlan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb></axmt410>
    I write these codes in SAP XSLT  editor
    <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:strip-space elements="*"/>
       <xsl:template match="/">
         <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
           <asx:values>
             <ORDERS>
               <xsl:apply-templates select="//axmt410"/>
             </ORDERS>
           </asx:values>
         </asx:abap>
       </xsl:template>
       <xsl:template match="axmt410">
         <OBJECTID>
           <xsl:value-of select="ObjectID"/>
         </OBJECTID>
         <AZP01>
           <xsl:value-of select="azp01"/>
         </AZP01>
         <OEA00>
           <xsl:value-of select="oea00"/>
         </OEA00>
         <TA_OEAECN>
           <xsl:value-of select="ta_oeaecn"/>
         </TA_OEAECN>
         <OEA03>
           <xsl:value-of select="oea03"/>
         </OEA03>
         <OEA05>
           <xsl:value-of select="oea05"/>
         </OEA05>
         <OEA02>
           <xsl:value-of select="oea02"/>
         </OEA02>
         <TA_OEA002>
           <xsl:value-of select="ta_oea002"/>
         </TA_OEA002>
         <TA_OEA001>
           <xsl:value-of select="ta_oea001"/>
         </TA_OEA001>
         <OEA14>
           <xsl:value-of select="ora14"/>
         </OEA14>
         <OEA15>
           <xsl:value-of select="ora15"/>
         </OEA15>
         <OEA23>
           <xsl:value-of select="ora23"/>
         </OEA23>
         <OEACONF>
           <xsl:value-of select="oeaconf"/>
         </OEACONF>
         <OEA10>
           <xsl:value-of select="ora10"/>
         </OEA10>
         <OEAUD01>
           <xsl:value-of select="oeaud01"/>
         </OEAUD01>
         <TA_OEA007>
           <xsl:value-of select="ta_oea007"/>
         </TA_OEA007>
         <OEA25>
           <xsl:value-of select="ora25"/>
         </OEA25>
         <TA_OEA008>
           <xsl:value-of select="ta_oea008"/>
         </TA_OEA008>
         <TA_OEA009>
           <xsl:value-of select="ta_oea009"/>
         </TA_OEA009>
         <TA_OEA013>
           <xsl:value-of select="ta_oea013"/>
         </TA_OEA013>
         <TA_OEA014>
           <xsl:value-of select="ta_oea014"/>
         </TA_OEA014>
         <TA_OEA015>
           <xsl:value-of select="ta_oea015"/>
         </TA_OEA015>
         <TA_OEA016>
           <xsl:value-of select="ta_oea016"/>
         </TA_OEA016>
         <TA_OEA017>
           <xsl:value-of select="ta_oea017"/>
         </TA_OEA017>
         <TA_OEA018>
           <xsl:value-of select="ta_oea018"/>
         </TA_OEA018>
         <TA_OEA019>
           <xsl:value-of select="ta_oea019"/>
         </TA_OEA019>
         <TA_OEA020>
           <xsl:value-of select="ta_oea020"/>
         </TA_OEA020>
         <TA_OEA021>
           <xsl:value-of select="ta_oea021"/>
         </TA_OEA021>
         <TA_OEA022>
           <xsl:value-of select="ta_oea022"/>
         </TA_OEA022>
         <TA_OEA028>
           <xsl:value-of select="ta_oea028"/>
         </TA_OEA028>
         <OEAUSER>
           <xsl:value-of select="oeauser"/>
         </OEAUSER>
         <TA_OEANDAY>
           <xsl:value-of select="ta_oeanday"/>
         </TA_OEANDAY>
         <TA_OEAMDAY>
           <xsl:value-of select="ta_oeamday"/>
         </TA_OEAMDAY>
         <TA_OEACDAY>
           <xsl:value-of select="ta_oeacday"/>
         </TA_OEACDAY>
         <OEAUD02>
           <xsl:value-of select="oeaud02"/>
         </OEAUD02>
         <TA_OEA030>
           <xsl:value-of select="ta_oea030"/>
         </TA_OEA030>
         <OEB>
           <xsl:for-each select="oeb">
             <OEB03>
               <xsl:value-of select="oeb03"/>
             </OEB03>
             <OEB04>
               <xsl:value-of select="oeb04"/>
             </OEB04>
             <OEB05>
               <xsl:value-of select="oeb05"/>
             </OEB05>
             <OEB17>
               <xsl:value-of select="oeb17"/>
             </OEB17>
             <OEB13>
               <xsl:value-of select="oeb13"/>
             </OEB13>
             <OEB15>
               <xsl:value-of select="oeb15"/>
             </OEB15>
             <OEB12>
               <xsl:value-of select="oeb12"/>
             </OEB12>
             <OEB09>
               <xsl:value-of select="oeb09"/>
             </OEB09>
             <TA_OEB001>
               <xsl:value-of select="ta_oeb001"/>
             </TA_OEB001>
             <TA_OEB002>
               <xsl:value-of select="ta_oeb002"/>
             </TA_OEB002>
             <TA_OEB003>
               <xsl:value-of select="ta_oeb003"/>
             </TA_OEB003>
             <TA_OEB004>
               <xsl:value-of select="ta_oeb004"/>
             </TA_OEB004>
             <TA_OEB005>
               <xsl:value-of select="ta_oeb005"/>
             </TA_OEB005>
             <TA_OEB006>
               <xsl:value-of select="ta_oeb006"/>
             </TA_OEB006>
             <OEBUD01>
               <xsl:value-of select="oebud01"/>
             </OEBUD01>
           </xsl:for-each>
         </OEB>
       </xsl:template>
    </xsl:transform>
    and I use below ABAP program for a test, but the items from XML can not translate into Interner table gt_orders-oeb[]
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\temp\order02.xml'.
    * This is the structure for the data from the XML file
    TYPES:
       BEGIN OF typ_s_oeb,
         oeb03     TYPE string,    "
         oeb04     TYPE string,    "
         oeb05     TYPE string,    "
         oeb17     TYPE string,    "
         oeb13     TYPE string,   
         oeb15     TYPE string,   
         oeb12     TYPE string,    "
         oeb09     TYPE string,    "
         ta_oeb001 TYPE string,    "
         ta_oeb002 TYPE string,    "
         ta_oeb003 TYPE string,    "
         ta_oeb004 TYPE string,    "
         ta_oeb005 TYPE string,    "
         ta_oeb006 TYPE string,    "
         ta_oeb013 TYPE string,    "
         ta_oeb014 TYPE string,    "
         ta_oeb015 TYPE string,    "
         ta_oeb016 TYPE string,    "
         ta_oeb017 TYPE string,    "
         ta_oeb018 TYPE string,    "
         ta_oeb019 TYPE string,    "
         ta_oeb020 TYPE string,    "
         ta_oeb021 TYPE string,    "
         ta_oeb022 TYPE string,    "
         oebud01   TYPE string,    "
       END OF typ_s_oeb.
    TYPES: typ_t_oeb TYPE TABLE OF typ_s_oeb WITH KEY oeb03.
    TYPES:
       BEGIN OF typ_s_order,
         objectid   TYPE string,   "
         azp01      TYPE string,   "
         oea00      TYPE string,   "
         ta_oeaecn  TYPE string,   "
         oea03      TYPE string,   "
         oea02      TYPE string,   "
         ta_oea002  TYPE string,   "
         ta_oea001  TYPE string,   "
         oea14      TYPE string,   "
         oea15      TYPE string,  
         oea23      TYPE string,   "
         oeaconf    TYPE string,   "
         oea10      TYPE string,   "
         oeaud01    TYPE string,   "
         ta_oea007  TYPE string,   "
         oea25      TYPE string,   "
         ta_oea008  TYPE string,   "
         ta_oea009  TYPE string,   "
         oeauser    TYPE string,   "
         ta_oeanday TYPE string,   "
         ta_oeamday TYPE string,   "
         ta_oeacday TYPE string,   "
         oeaud02    TYPE string,   "
         ta_oea030  TYPE string,   "
         ta_oea013  TYPE string,
         ta_oea014  TYPE string,
         ta_oea015  TYPE string,
         ta_oea016  TYPE string,
         ta_oea017  TYPE string,
         ta_oea018  TYPE string,
         ta_oea019  TYPE string,
         ta_oea020  TYPE string,
         ta_oea021  TYPE string,
         ta_oea022  TYPE string,
         ta_oea025  TYPE string,
         oeb        TYPE typ_t_oeb,
        END OF typ_s_order.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048,
           gs_itab       LIKE LINE OF gt_itab.
    * Table and work ares for the data from the XML file
    DATA: gt_orders     TYPE STANDARD TABLE OF typ_s_order,
           gs_orders     TYPE typ_s_order.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
           gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
           gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
       EXPORTING
         filename                = gs_file
       CHANGING
         data_tab                = gt_itab
       EXCEPTIONS
         file_open_error         = 1
         file_read_error         = 2
         no_batch                = 3
         gui_refuse_filetransfer = 4
         invalid_type            = 5
         no_authority            = 6
         unknown_error           = 7
         bad_data_format         = 8
         header_not_allowed      = 9
         separator_not_allowed   = 10
         header_too_long         = 11
         unknown_dp_error        = 12
         access_denied           = 13
         dp_out_of_memory        = 14
         disk_full               = 15
         dp_timeout              = 16
         not_supported_by_gui    = 17
         error_no_gui            = 18
         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.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IPERSON".
    GET REFERENCE OF gt_orders INTO gs_result_xml-value.
    gs_result_xml-name = 'ORDERS'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT styleshee
    TRY.
         CALL TRANSFORMATION zfx_so_xml_to_abap
         SOURCE XML gt_itab
         RESULT (gt_result_xml).
       CATCH cx_root INTO gs_rif_ex.
         gs_var_text = gs_rif_ex->get_text( ).
         MESSAGE gs_var_text TYPE 'S'.
    ENDTRY.
    LOOP AT gt_orders INTO gs_orders.
    ENDLOOP.

    The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
    When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
    If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
    If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
    t_factory.newTransformer(new StreamSource("test.xsl"));
    and use this as test.xsl:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output doctype-system="yourDTDfile.dtd"/>
       <!-- this is the identity transformation -->
       <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:copy>
             <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>Good luck.

  • Problem getting xslt transform to work

    I have the following ABAP Xslt  transformation
    <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="/">
              <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
                   <asx:values>
                        <ALLIR_REIKNINGAR>
                             <xsl:apply-templates select="//Invoice"/>   
                        </ALLIR_REIKNINGAR>
                   </asx:values>
              </asx:abap>
         </xsl:template>
        <xsl:template match="Invoice">
        <REIKNINGUR>
            <REIKN_NUMER>
                <xsl:value-of select="cbc:ID"/>           
            </REIKN_NUMER>
            <REIKN_AFRIT>
                <xsl:value-of select="cbc:CopyIndicator"/>
            </REIKN_AFRIT>
            <REIKN_UTGAFUDAGS>
                <xsl:value-of select="cbc:IssueDate"/>
            </REIKN_UTGAFUDAGS>
            <REIKN_MYNT>
                <xsl:value-of select="cbc:DocumentCurrencyCode"/>
            </REIKN_MYNT>
            <REIKN_TIMABIL_FRA>
                <xsl:value-of select="cac:InvoicePeriod/cbc:StartDate"/>
            </REIKN_TIMABIL_FRA>
            <REIKN_TIMABIL_TIL>
                <xsl:value-of select="cac:InvoicePeriod/cbc:EndDate"/>
            </REIKN_TIMABIL_TIL>
        </REIKNINGUR>
        </xsl:template>
    </xsl:transform>
    And the following XML input file
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="vodafone_xslt_namespace.xslt"?>
    <Invoice
    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
    xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
    xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
    xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
    xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
    xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ccts="urn:un:unece:uncefact:documentation:2"
    xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0"
    xmlns:clm5639="urn:un:unece:uncefact:codelist:specification:5639:1988"
    xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001"
    xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001"
    xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003"
    >
         <cbc:UBLVersionID>2.0</cbc:UBLVersionID>
         <cbc:CustomizationID>NES</cbc:CustomizationID>
         <cbc:ProfileID schemeID="Profile"
         schemeAgencyID="NES">urn:www.nesubl.eu:profiles:profile4:ver1.1</cbc:ProfileID>
         <cbc:ID>PB1554421</cbc:ID>
         <cbc:CopyIndicator>false</cbc:CopyIndicator>
         <cbc:IssueDate>2011-12-31</cbc:IssueDate>
         <cbc:InvoiceTypeCode listID="UN/ECE 1001 Restricted" listAgencyID="NES">380</cbc:InvoiceTypeCode>
         <cbc:Note languageID="IS">Company name</cbc:Note>
         <cbc:DocumentCurrencyCode listID="ISO 4217 Alpha">ISK</cbc:DocumentCurrencyCode>
         <cbc:AccountingCost>2001523</cbc:AccountingCost>
         <cac:InvoicePeriod>
              <cbc:StartDate>2011-12-01</cbc:StartDate>
              <cbc:EndDate>2011-12-31</cbc:EndDate>
         </cac:InvoicePeriod>
    </Invoice>
    My problem is that this transformation does not work unless I completly strip out the namespace parts i.e. cbc:
    How can I get the parser to read the tags with namespace part. And if the parser can not handle namespace in XML how can I go about reding the data into sap ?

    I think you are trying convert the xml to an internal table because of // in apply-templates, then you need to change last XSLT program and include <item> tag inside the <xsl:template match="inv:Invoice">  template, see updated XSLT bellow.
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:inv="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
    xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
    xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
    xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
    xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2"
    xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ccts="urn:un:unece:uncefact:documentation:2"
    xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0"
    xmlns:clm5639="urn:un:unece:uncefact:codelist:specification:5639:1988"
    xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001"
    xmlns:clm66411="urn:un:unece:uncefact:codelist:specification:66411:2001"
    xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003"
    xmlns:sapxsl="http://www.sap.com/sapxsl"
    version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <ALLIR_REIKNINGAR>
              <xsl:apply-templates select="//inv:Invoice"/>
            </ALLIR_REIKNINGAR>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="inv:Invoice">
        <item>
        <REIKNINGUR>
          <REIKN_NUMER>
            <xsl:value-of select="cbc:ID"/>
          </REIKN_NUMER>
          <REIKN_AFRIT>
            <xsl:value-of select="cbc:CopyIndicator"/>
          </REIKN_AFRIT>
          <REIKN_UTGAFUDAGS>
            <xsl:value-of select="cbc:IssueDate"/>
          </REIKN_UTGAFUDAGS>
          <REIKN_MYNT>
            <xsl:value-of select="cbc:DocumentCurrencyCode"/>
          </REIKN_MYNT>
          <REIKN_TIMABIL_FRA>
            <xsl:value-of select="cac:InvoicePeriod/cbc:StartDate"/>
          </REIKN_TIMABIL_FRA>
          <REIKN_TIMABIL_TIL>
            <xsl:value-of select="cac:InvoicePeriod/cbc:EndDate"/>
          </REIKN_TIMABIL_TIL>
        </REIKNINGUR>
       </item>
      </xsl:template>
    </xsl:transform>
    According to the XSLT program you need dclare an itab like this:
    DATA: BEGIN OF ls_reikningur,
          reikn_numer(10) TYPE c,
          END OF ls_reikningur.
    DATA: BEGIN OF ls_invoice,
          reikningur LIKE ls_reikningur,
          END OF ls_invoice.
    DATA: lt_invoice LIKE TABLE OF ls_invoice.
    And finally you need a call transformation in your abap code like this:
    DATA: root_error TYPE REF TO cx_root.
    DATA: lv_mess TYPE string.
    TRY.
        CALL TRANSFORMATION  zinvoice
           SOURCE XML lv_xml
           RESULT allir_reikningar = lt_invoice.
      CATCH cx_root INTO root_error.
        lv_mess = root_error->if_message~get_text( ).
        WRITE lv_mess.
    ENDTRY.

  • Declare deep structure with se11

    Hi,
    I would like to create a new deep structure with a table type component with se11 transaction, not a nested structure.
    I know it is possible to do that with Abap but I need to do this with se11 because it has to be accessible from some reports and some function modules as export parameters.
    Thanks.

    Hello Juan
    If you use a DB table name as TYPE for your structure field is is always a structure but not a table type.
    The only difference between DB tables and structures is that you can save records in DB tables.
    Instead of the DB table name you need the name of a table type which has the DB table as line type.
    Example: Structure has two fields
    KUNNR (of TYPE kunnr)
    DATA   (of TYPE trty_knb1 => table type for KNB1)
    Now you can define a table type having the line structure shown above.
    Regards
      Uwe

Maybe you are looking for

  • Looking for a Labview job. Any offers or suggestion​s?

    Hi, everybody! I wish we had labview.jobs or something. Since we have not yet, I would appreciate any hints regarding looking for a Labview job, especially for people with just 1 year of experience, beside emailing everybody on the NI Alliance list a

  • Withholding tax is getting updated in cleared items

    Dear Expert, Withholding tax is getting updated in cleared items when i do invoice. it happens some times.i am not getting reason why it go to cleared item instead of open item in withholding tax GL. Kindly help on above.... Regards

  • Validation on Header text

    in my scenario i need to validate on header text while creating VA01 in header text if user is entering text it should be in number if he is entering any character means i need to pass a message . Regards., mohd.

  • Link to other users' foto streams on Windows 7 PC

    Hi, I do not want to use iCloud for own foto streams but to connect to other users' foto streams on PC. Unfortunatley I did not find the way to connect. Does somebody know how to install/cutomize this feature?

  • 10.5.6 - fast user switching

    Since installing 10.5.6, my intel macbook won't rotate the screen when i use fast user switching. Anyone else found this? Anyone with a solution? i miss the effect..