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.

Similar Messages

  • How to download an IDOC in XML or spreadsheet with well structured.

    Dear Experts,
    I am currently display an IDOC in WE02.
    May i know how to download this IDOC into XML format or spreadsheets format and well structured with Hierarchy level..
    Thank you very much

    Hi,
    Good question my friend,
    Follow below process:
    - Input t-code IDOC
    - In selection screen, select 'Analyse IDOC field values
    - Press F8
    - Input your IDOC number
    - Check mark on 'Also evaluate empty fields
    - Click on 'Output in internal form' : this is very much important thing
    - The execute
    - You will see all the data
    - Then go to 'List'>Save/send option from where you can achieve your purpose.
    Hrishi

  • How to use if condition in XML Publisher Desk Top

    Hi..,
    How to use if condition in XML Publisher desk Top.
    Please guide me.
    Thanks,
    Suresh.

    What kind of condition you want to use?
    You can use Condition like this:
    <?xdofx:if condition then value1
    else if condition then Value2
    else Value3
    end if?>
    Please go thru XML Publisher User Guide.
    Thanks
    Ravi
    [email protected]

  • How to use Euro symbol in xml tags?

    How to use Euro symbol in xml tags?

    What do you mean by "in xml tags"? Can you post a three-line XML snippet showing what you hope to achieve?

  • How to use Crystal Reports XI release 2 Preview with Lotus Notes  Scripts ?

    <br />Hi all,<br /><br /> How to use Crystal Reports XI release 2 Preview with Lotus Notes 7 Scripts ?<br /><br /> <br /><br />Thank&#39;s  <br />

    Hi,
    we are using Lotus Notes and Crystal Reports for preview and printing reports from our Lotus Notes Applications. We use the RDC object model. For previewing the reports we export them in an pdf-file and then start the PDF Reader to show the Preview. This works fine.
    But with Crystal Reports > 11 the RDC Object Model is no longer supportet, so we look for another way to preview and print our reports.
    I try to preview a report build with crystal report XI release 2 in my thick client (Lotus Notes) using java reporting component JRC, this report uses an native xml file as datasource. If the datasource is saved with the report everything works fine, but otherwise I have the following error:
    JRCAgent1 detected an exception: javax.xml.namespace.QName: method getPrefix()Ljava/lang/String; not found
    I also tried the .jars from Crystal4Eclipse. Doesn't work. When I use Eclipse to view the report everything works fine. The class QName exitsts in the jaxrpc.jar and in the xbean.jar, but only in the xbean.jar a Methode getPrefix exists.
    This is what we tried:
    Works fine with RDC. Doesn't work with JRC until now.
    Did this help you ?
    Perhaps you con help me with the JRC, because I'm a java newbee so any ideas could be helpful.
    Oliver
    <p><a href="http://www.cominform.de">www.cominform.de</a></p>

  • Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program

    Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program

    http://wiki.sdn.sap.com/wiki/display/Snippets/Reading+Sets+-+GS01+-+GS02+-+GS03

  • How can use my Wireless Location Appliance to work with RF ID's?

    How can use my Wireless Location Appliance to work with RF ID's for Asset Tagging.
    It seems Smartcard used for ID cards have a small RF ID, can I use this for Asset Tagging?
    Thanks in Advance

    There are two kinds of RFID tags: Active tags, which have a battery or other internal power source, and passive tags, which have no power source and work by reflecting the energy from an RFID scanner (basically). At the energy levels and distances used for WiFi location detection, passive tags will not return a detectable signal.
    Take a look at http://www.aeroscout.com/ for more info on WiFi RFID tagging.

  • How to use the special character pallet in Maverics with Illustrator

    How to use the special character pallet in Mavericks with Illustrator - I follow the help instructions, but the pasted in object looks like a rectangle with an X, I have done this before, in earlier versions of AI, but cannot make it work in CS6.
    In fact, I can open an old AI file (CS4), copy the character (a graphic symbol, also taken from the special character set), paste it in, and it works, but can't do this with a new one, from the drop down, Show Character Viewer, in the Mavericks menu bar.

    The box with an X indicates the font you are using does not have the glyph you are trying to paste. Try a different font.

  • How to use LABVIEW to collect wireless network camera (with video server) video.

    How to use LABVIEW to collect wireless network camera (with video server) video.I would like to use LABVIEW for a wireless network camera (IP Camera comes with the video server module)the client program.Will the ability to achieve?If feasible, how to do, there are examples, thank you.

    I believe NI Vision is what you are looking for. 

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • How to use NodeIterator on an XML document

    I have been trying to create a NodeIterator using the following code:
    try
    FileInputStream inStream;
    Document doc;
    String xmlDocumentPath = "I have a real path here";
    inStream = new FileInputStream(xmlDocumentPath);
    DOMParser parser = new DOMParser();
    parser.parse(inStream);
    doc = parser.getDocument();
    Node root = doc.getDocumentElement();
    formInputFilter filter = new formInputFilter();
    DocumentTraversal traverse = (DocumentTraversal)doc;
    NodeIterator iter = traverse.createNodeIterator(root, NodeFilter.SHOW_ALL, filter, true);
    Node n = (Node)iter.nextNode();
    while (n != null)
    System.out.println(n.getNodeName());
    catch (Exception e)
    System.out.println(e.toString());
    When the nextNode method is executed I get an NPE. Looking in the iterator it shows the value of next as null when it is created. I have found a couple of code sources that all show this as the correct way to create a NodeIterator and I can't figure out what I am doing wrong. I have tried creating it with and without my filter and I still have the same problem. I had other code that could loop through the XML file that worked but the NodeIterator would be much simpler to use. Anyone have a suggestion.

    Using JDev 9.0.3.1, and with a C:\temp\test.xml file setup ahead of time, running the following program works for me just fine. How is yours different?
    package test;
    import java.io.FileInputStream;
    import oracle.xml.parser.v2.DOMParser;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.traversal.DocumentTraversal;
    import org.w3c.dom.traversal.NodeFilter;
    import org.w3c.dom.traversal.NodeIterator;
    public class Test {
      public static void main(String[] args) throws Throwable {
        Test t = new Test();
        t.test();
      void test() throws Throwable {
        String xmlDocumentPath = "c:\\temp\\test.xml";
        FileInputStream inStream = new FileInputStream(xmlDocumentPath);
        DOMParser parser = new DOMParser();
        parser.parse(inStream);
        Document doc = parser.getDocument();
        Node root = doc.getDocumentElement();
        MyNodeFilter filter = new MyNodeFilter();
        DocumentTraversal traverse = (DocumentTraversal)doc;
        NodeIterator iter = traverse.createNodeIterator(root, NodeFilter.SHOW_ALL, filter, true);
        Node n = null;
        while ((n = (Node)iter.nextNode()) != null) {
          System.out.println(n.getNodeName());
      class MyNodeFilter implements NodeFilter {
        public short acceptNode(Node n){
          return FILTER_ACCEPT;
    }

  • How to use SAX Parseto paser xml without root element

    Hello,
    I have big a xml file(500M) with without root element. How can I use SAXParse to parse it.

    A well-formed XML file has a single root element. Your parser can't deal with any other kind. So find the person who produced that file and explain politely that it's no good. (Hitting them with a big stick would be optional.)
    You could write a non-XML program that reads it in and creates a new version, wrapped in a single root element, if your supplier can't fix their problem.

  • How to use class for Translate..codepage/numer format

    In the Unicode context, TRANSLATE... CODEPAGE/NUMBER FORMAT is not allowed.

    this is the class to be used for  Translate…Codepage/number format.statement
    Unicode Error : In the Unicode context, TRANSLATE... CODEPAGE/NUMBER   FORMAT is not allowed.
    Before Unicode
      TRANSLATE T143T-TBTXT FROM CODE PAGE '1100' TO CODE PAGE '1105'.
    After Unicode
       Use class for Translate codepage to codepage.
         Data : g_codepage LIKE tcp0c-charco VALUE '1100'.
    CONSTANTS: c_unicodecp(4) VALUE '1105'.
    PERFORM translate_codepage USING g_codepage
                                     c_unicodecp
                               CHANGING T143T.
    FORM translate_codepage  USING    P_G_CODEPAGE
                                      P_C_UNICODECP
                             CHANGING P_T143T.
      DATA: converter  TYPE REF TO cl_abap_conv_obj.
      DATA: l_out      TYPE string.
      DATA: l_fromcode TYPE cpcodepage.
      DATA: l_tocode   TYPE cpcodepage.
      l_fromcode = P_G_CODEPAGE.
      l_tocode = P_C_UNICODECP.
      CREATE OBJECT converter
        EXPORTING
          incode  = l_fromcode
          miss     = '.'
          broken   = '.'
          use_f1   = 'X'
          outcode  = l_tocode
        EXCEPTIONS
          invalid_codepage = 1
          internal_error   = 2.
      IF sy-subrc <> 0.
        CASE sy-subrc.
          WHEN 1.
            MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
          WHEN 2.
            MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
        ENDCASE.
      ENDIF.
      CALL METHOD converter->convert
        EXPORTING
          inbuff         = P_T143T
          inbufflg       = 0
          outbufflg      = 0
        IMPORTING
          outbuff        = l_out
        EXCEPTIONS
          internal_error = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
        CASE sy-subrc.
          WHEN 1.
            MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
          WHEN 2.
            MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.
        ENDCASE.
      ENDIF.
      P_T143T = l_out.
    ENDFORM.                    " translate_codepage

  • Using XSLT to link XML and ABAP data

    Hi Experts,
    I am using XSLT to deal with XML and ABAP data.
    I using the following statement to convert a Internal Table to XML String:
    CALL TRANSFORMATION id SOURCE  root = lt_sflight RESULT XML l_xml_string.
    And I get the XML String:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <SFLIGHT>
    </SFLIGHT>
    <SFLIGHT>
    </SFLIGHT>
    </ROOT>
    </asx:values>
    </asx:abap>
    But What I expected is:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <DATA>
    </DATA>
    <DATA>
    </DATA>
    </ROOT>
    </asx:values>
    </asx:abap>
    Could you tell me how to get my dream format using XSLT?
    Best Regards,
    Guo Guo Qing
    Edited by: guoqing guo on Jun 11, 2008 9:58 AM

    Hi Experts,
    I am using XSLT to deal with XML and ABAP data.
    I using the following statement to convert a Internal Table to XML String:
    CALL TRANSFORMATION id SOURCE  root = lt_sflight RESULT XML l_xml_string.
    And I get the XML String:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <SFLIGHT>
    </SFLIGHT>
    <SFLIGHT>
    </SFLIGHT>
    </ROOT>
    </asx:values>
    </asx:abap>
    But What I expected is:
    <?xml version="1.0" encoding="utf-16" ?>
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <ROOT>
    <DATA>
    </DATA>
    <DATA>
    </DATA>
    </ROOT>
    </asx:values>
    </asx:abap>
    Could you tell me how to get my dream format using XSLT?
    Best Regards,
    Guo Guo Qing
    Edited by: guoqing guo on Jun 11, 2008 9:58 AM

  • How to add doctype when generating XML from an arbitrary data structure

    I was reading SUN's tutorial "Working with XML - PART IV: Using XSLT". Inside this tutorial, in 3, it talks about how to generate XML from an arbitrary data structure making use of a XMLReader and a Transformer. The example only shows adding elements. Is there a way to add DTD information in the XML generated, i.e. <!DOCTYPE ... >? What APIs can I use?
    Thanks,
    Alex

    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.

Maybe you are looking for

  • Authorization issue in BI 7.0 query

    Hi, The user has the authorization for the company code 0001, 0002 and 0003. The three different roles for each respectively company code 0001, 0002 and 0003 has been assigned to this user. When the User executes the query for only one company code,

  • Problem installing PDF printer on Windows 7

    I'm trying to install the PDF printer on my computer using the CS3 disk and it's not working.  Any ideas?

  • WICD won't save networks

    When I installed it, I added two networks wifi networks to wicd and those were saved. However, now every time I add any new network, it is being forgotten by wicd as soon as it disconnects and I have to type the passwords again. What could be causing

  • New Release - My Cloud Mirror Firmware Release 1.05.36 (7/8/2015)

    WD is happy to announce the release of the My Cloud Mirror Firmware Update. Please follow the instructions when doing the update, and feel free to post your questions and experiences in the My Cloud Mirror forum. Please create individual topics for a

  • How to read output of native program

    Hi, I wrote a Java program that runs a native program. In my case, the native program is written in C++ and runs under Linux. My purpose is, to start the native program and to capture the output of it and send also some input. I found the code to do