Automatic insert of xmlns:xsl during XSLT transformation

I am using the xmlparserv2.jar of dated "12/10/00" to perform a XSLT transformation. I need to insert a xml:space="preserve" attribute to a generated tag. However, there is an addition attribute added : xmlns:xml="http://www.w3/org/XML/1998/namespace". How can I suppress the generation of this attribute ?
Here is my XML :
<?xml version = '1.0' standalone = 'no'?>
<COLDdoc>
<Page template="bkgnd1" num="1">
<Line num="1"> CN011A021C 1A021</Line>
<Line num="2"> 1954.90 7713.36</Line>
</Page>
</COLDdoc>
My XSL is :
<?xml version = '1.0' standalone = 'yes'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" doctype-system="svg-20000303-stylable.dtd"/>
<xsl:template match="Line">
<text>
<xsl:attribute name="x">0</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="@num*10"/>
</xsl:attribute>
<xsl:attribute name="xml:space">preserve</xsl:attribute>
<xsl:value-of select="."/>
</text>
</xsl:template>
</xsl:stylesheet>
The result XSLT Transformation :
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE text SYSTEM "svg-20000303-stylable.dtd">
<text x="0" y="10" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> CN011A021C 1A021</text>
<text x="0" y="20" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> "> 1954.90 7713.36</text>
Regards.
Jeffrey
null

Hi Greg,
please try it with the following (just slightly) modified transformation (works fine for me):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:asx="http://www.sap.com/abapxml"
               xmlns:sap="http://www.sap.com/sapxsl"
               version="1.0">
  <xsl:strip-space elements="*"/>
  <xsl:template match="/PEXR2002/IDOC">
    <asx:abap version="1.0">
      <asx:values>
        <HEADER_DATA>
          <SNDPRN>
            <xsl:value-of select="EDI_DC40/SNDPRN"/>
          </SNDPRN>
          <BGMREF>
            <xsl:value-of select="E1IDKU1/BGMREF"/>
          </BGMREF>
          <MOABETR>
            <xsl:value-of select="E1IDKU5/MOABETR"/>
          </MOABETR>
          <CREDAT>
            <xsl:value-of select="EDI_DC40/CREDAT"/>
          </CREDAT>
          <DATUM>
            <xsl:value-of select="E1EDK03/DATUM"/>
          </DATUM>
        </HEADER_DATA>
      </asx:values>
    </asx:abap>
  </xsl:template>
</xsl:transform>
I recommend to test all transformations that you define on a sample source and check the output. If you apply your original transformation you would see that it basically doesn't select anything and therefore you just get an XML document with the field names but no values.
Cheers, harald

Similar Messages

  • XSLT Transformer xmlns namespace problem

    Hi,
    I have the following xml document
    <PIPEDocument Version="2.0" DocumentReferenceNumber="2001" CreationDate="2002070401251212245"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://www.oeb.gov.on.ca/">
         <MarketParticipantDirectory>
    </MarketParticipantDirectory>
    </PIPEDocument>
    and the following xsl stylesheet
    <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
              xmlns ="http://www.oeb.gov.on.ca/"
              version = "1.0">
    <xsl:output method = "xml" indent = "yes" />
    <xsl:template match = "/" >
    <PIPEFunctionalAcknowledgement>
              <xsl:apply-templates select="//MarketParticipantDirectory"/>
    </PIPEFunctionalAcknowledgement>
    </xsl:template>
    <xsl:template match = "MarketParticipantDirectory" >
    </xsl:template>
    </xsl:stylesheet>           
    My problem is, using JAXP1.2.0-EA2 (from JWSDP1-0-ea2), javax.xml.transform.Transformer will not find a match on the element name within the template unless I put a prefix on the target namespace i.e.
    if my xml is changed to include a prefix (:xyz in example below)
    <PIPEDocument Version="2.0" DocumentReferenceNumber="2001" CreationDate="2002070401251212245"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xyz="http://www.oeb.gov.on.ca/">
         <MarketParticipantDirectory>
    </MarketParticipantDirectory>
    </PIPEDocument>
    and my stylesheet is changed also to include the prefix
    <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
              xmlns:xyz ="http://www.oeb.gov.on.ca/"
              version = "1.0">
    </xsl:stylesheet>
    then the transfomer works correctly and find a match on the element name "MarketParticipantDirectory" within the template (even though the element doesn't have the prefix xyz:MarketParticipantDirectory).
    Could anyone tell me why this is the case?
    I would have expected XSLT to match the elements from the namespace xmlns ="http://www.oeb.gov.on.ca/" without the prefix.
    Any comments would be much appreciated.
    Thanks
    Sinead Casey

    Matching an element on a Default Namespace requires Explicit Prefix.
    http://www.w3.org/TR/xslt20req

  • XSLT-transformation inserts linefeeds

    Hi,
    I am using XSLT-transformation on WAS 7.0. Part of the result of my XSLT-transformations is javascript-sourcecode.
    The statement
    <xsl:output omit-xml-declaration="yes" indent="no" method="html" encoding="utf-8" />
    should generate browser-readable html-code.
    So take the line
    xxxxx<br/>yyyyy
    After the transformation I am expecting the result
    xxxxx<br>yyyyy
    wheras the XSLT-transformation engine returns
    xxxxx<br>
    <br>
    yyyyy<br>
    (LINEBREAKS ARE INSERTED FOR EACH LINE!!!)
    As my result is javascript-source, this behaviour is a huge problem, as - due to the linefeeds - my generated javascipt-code is not executable anymore.
    Does anybody know a solution, how I can tell the XSLT-processor to generate code WITHOUT linefeeds?
    Thanks,
    Andreas

    A <i>value-of tag</i> would be much useful .
    <xsl:value-of
      select? = expression
      separator? =
      [disable-output-escaping]? = "yes" | "no">
    </xsl:value-of>
    e.g
    <xsl:template match="description">
      <xsl:value-of select="." disable-output-escaping="yes" />
    </xsl:template>

  • How to generate XSL for an XML file to use it for XSLT transformation -SSIS?

    Hi All,
    Can anybody please help me to generate XSL for my attached XML file?
    I need to use the XSL file for XSLT transformation.
    Thanks & Regards,
    Sri

    Hi Vibhav,
    Thanks for the response.
    I am aware of the process but not sure how to generate XSL file. 
    Can you please refer me to any tool which can convert XML to XSL? or please can you transform my simple XML to XSL?
    Thanks & Regards,
    Sri

  • XSLT transformation in XML to ABAP: special characters issue

    Hi,
    I am parsing well-formed XML file that has the following data (:
    <projects><project><name>Wallis &amp; Futuna</name></project></projects>
    I use 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="projects">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
            <PROJECTS>
              <xsl:for-each select="project">
                <PROJECT>
                  <NAME>
                    <xsl:value-of select="name"/>
                  </NAME>
                </PROJECT>
              </xsl:for-each>
            </PROJECTS>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:transform>
    If I use the above example without &amp;amp; everything works fine, but the original XML fails with exception CX_XSLT_DESERIALIZATION_ERROR and message "Error during deserialization". Googling around did not give an answer.
    Any words of wisdom?
    Edited by: Alexei Isaev on Apr 26, 2011 5:04 AM
    Edited by: Alexei Isaev on Apr 26, 2011 5:05 AM

    Hi,
    Please visit the following link for reference.
    http://help.sap.com/abapdocu_70/en/ABAPCALL_TRANSFORMATION.htm
    Thanks & Regards,
    Harish

  • How to insert new line break in XSLT mapping

    Hi experts,
    I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
    I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
    I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    Can anyone suggest me how to insert new line in XSLT mapping.
    My XSLT mapping as look like:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:variable name="break">&lt;br/&gt;</xsl:variable>
    <xsl:variable name="space"> </xsl:variable>
    <xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
    <xsl:template match="/">
    <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
    <Subject>Please Check Attached Direct Debit File</Subject>
    <From>S@za</From>
    <To>P@za</To>
    <Content_Type>text/plain</Content_Type>
    <Content>
    <xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
    <xsl:value-of select="Space1"/>
    <xsl:value-of select="Cust_AccNo"/>
    <xsl:value-of select="Reserve_1"/>
    <xsl:value-of select="Cust_Name"/>
    <xsl:value-of select="Cust_Name1"/>
    <xsl:value-of select="Cust_Bank_AccNo"/>
    <xsl:value-of select="Space2"/>
    <xsl:value-of select="Cust_Bank_BranchNo"/>
    <xsl:value-of select="Reserve_2"/>
    <xsl:value-of select="Space3"/>
    <xsl:value-of select="Cust_AccNo_1"/>
    <xsl:value-of select="Space4"/>
    <xsl:value-of select="Reserve_3"/>
    <xsl:value-of select="Deduction_Amnt"/>
    <xsl:value-of select="Space5"/>
    <xsl:value-of select="Reserve_4"/>
    <xsl:value-of select="Space6"/>
    <xsl:value-of select="Action_Date"/>
    <xsl:value-of select="Space7"/>
    <xsl:value-of select="Reserve_5"/>
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    </xsl:for-each>
    </Content>
      </ns1:Mail>
      </xsl:template>
      </xsl:stylesheet>
    Kind regards,
    Praveen

    Hi,
    I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
    Chris
    -> &
    Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM

  • 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

  • UTF-8 encoding in XSLT transformation

    Hello,
    I have a problem with a transformation of an ABAP structure into XML. I use the XSLT transformation for this.
    My XSLT starts like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:strip-space elements="*"/>
      <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
        <asx:values>
    I tried many settings I could find posted on the internet, but I did not find one that would allow encoding to UTF-8.
    It always encodes to iso-8859-1 which my interface partner cannot read.
    Does anyone know a way to force encoding to UTF-8?
    Adding a command like <xsl:output encoding="utf-8"/> did not help.
    Thanks a lot!
           J. Euler

    Hello!
    I think I just solved the problem taking a different approach.
    In a note here on SDN, a guy from SAP wrote, that the SAP XSLT processor is not able to code anything but the system's default to a string, BUT that it is able to code it to an xstring.
    All I did now is add the tag  
    <xsl:output encoding="utf-8" indent="yes" method="xml"/>
    to my xslt program and change the coding in the program accordingly.
    The program code is now:
      DATA: tempxstring TYPE xstring,
            temp_length TYPE i,
            conv      TYPE REF TO cl_abap_conv_in_ce.
      CLEAR tempxstring.
      TRY.
          CALL TRANSFORMATION
              zxxje_tst_xslt
            SOURCE omsregdatawebservice = wa_data
            RESULT XML tempxstring.
        CATCH cx_sy_conversion_base64.
        CATCH cx_sy_conv_illegal_date_time.
      ENDTRY.
      IF tempxstring IS NOT INITIAL.
        CLEAR: conv, temp_length, string_xml_result.
        conv = cl_abap_conv_in_ce=>create( input = tempxstring ).
        conv->read( IMPORTING data = string_xml_result len = temp_length ).
      ENDIF.
    Thanks anyways for all your help!
    regards,
          Johannes Euler

  • 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

  • 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

  • Need help in XSLT transformation

    Hi,
    I need to transform below input XML to output XML. Can you please provide any ideas for this
    Input XML :
    <?xml version="1.0" encoding="UTF-8" ?>
    <GenericCollection ParamValue="ParamValue1" xmlns="http://www.example.org">
    <Generic>
    <store>Store1</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store1</store>
    <metricName>Metric2</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric1</metricName>
    <metricValue>2</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric2</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store3</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store3</store>
    <metricName>Metric1</metricName>
    <metricValue>2</metricValue>
    </Generic>
    </GenericCollection>
    Output XML :
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns4:EnterpriseDocument>
    <ns4:DataSet>
    <ns4:Dimension ref_name="bu_code" value="Store1">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    </ns4:Metric>
    <ns4:Metric ref_name="Metric2">
    <ns4:Data value="1"/>
    </ns4:Metric>
    </ns4:Dimension>
    <ns4:Dimension ref_name="bu_code" value="Store2">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    <ns4:Data value="2"/>
    </ns4:Metric>
    <ns4:Metric ref_name="Metric2">
    <ns4:Data value="1"/>
    </ns4:Metric>
    </ns4:Dimension>
    <ns4:Dimension ref_name="bu_code" value="Store3">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    <ns4:Data value="2"/>
    </ns4:Metric>
    </ns4:Dimension>
    </ns4:DataSet>
    </ns4:EnterpriseDocument>
    Thanks,
    Ramesh

    Hello Ramesh,
    Nice puzzle
    For this you need a transformation with XSLT 2.0. Use a two level grouping. First group on the store elements and the second on the metricName elements.
    Transformation looks like this:
    <?xml version="1.0"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
             <EnterpriseDocument>
                 <DataSet>
                     <!-- First group on the store elements
                          Each store will be grouped based on the element value
                     -->
                     <xsl:for-each-group select="/*[local-name() = 'GenericCollection']/*[local-name() = 'Generic']" group-by="./*[local-name() = 'store']">
                         <!-- For each store a Dimension element is needed -->
                         <Dimension ref_name="bu_code" value="{./*[local-name() = 'store']}">
                             <!-- Within a Dimension we need to group by metricName -->
                             <xsl:for-each-group select="current-group()" group-by="./*[local-name() = 'metricName']">
                                 <Metric ref_name="{./*[local-name() = 'metricName']}">
                                     <!-- Iterate over the metricName nodes and create a Data element -->
                                     <xsl:for-each select="current-group()/*[local-name() = 'metricValue']">
                                         <Data value="{.}"/>
                                     </xsl:for-each>
                                 </Metric>
                             </xsl:for-each-group>
                         </Dimension>
                     </xsl:for-each-group>
                 </DataSet>
             </EnterpriseDocument>
         </xsl:template>
    </xsl:stylesheet>
    Good luck!
    Regards,
    Melvin

  • XSLT Transformation ABAP to XML speacial treatment of empty elements

    Dear All,
    I have created a deep abap structure which basically reflects the structure of my XML file which I would like to generate later. I have created a transformation via transaction SE80->create XSLT Program. I am also using the ABAP command call transformation...
    I have made a few ammendments to my XSLT program where required.
    I am outputting data in a loop.
    But I got a problem with one field. I must check if this date field is initial.
    Which I did by using statement:
    <xsl:if test="ENDDATE='0000-00-00'">
    But if this field is initial I have to output the following tag:
    <ENDDATE ReasonForNull="9"></ENDDATE>
    Hence I defined an attribute below in my element as follows:
       <xsl:for-each select="INSTANCE/_-PIQGB_-INSTANCE_XML">
    <xsl:if test="ENDDATE='0000-00-00'">
       <xsl:element name="ENDDATE">
           <xsl:attribute name="ReasonForNull"/>  
        </xsl:element>
    </xsl:if>
       </xsl:for-each>
    Which generates now the output as follows and is quitwe close to the desired output:
    <ENDDATE ReasonForNull=""></ENDDATE>
    Can anybody make a suggestion how I can generate the desired output.
    I assume that I would have to assign a value to the attribute to get the right output. But I got no idea how I could this in the loop.
    Many thanks in advance.
    Rainer

    Hello Rainer
    The solution is quite simple. See the example below.
    " Sample XML file:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="../tmp_EDI_ZZ_tests/Untitled2.xsl"?>
    <INVOIC02>
        <INSTANCE>
            <ENDDATE>2008-07-31</ENDDATE>
        </INSTANCE>
        <INSTANCE>
            <ENDDATE>0000-00-00</ENDDATE>
        </INSTANCE>
    </INVOIC02>
    " Stylesheet:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:output encoding="ISO-8859-1" method="xml" indent="yes"/>
        <xsl:template match="/*">
            <xsl:for-each select="INSTANCE">
                <xsl:choose>
                    <xsl:when test="ENDDATE='0000-00-00' ">
                        <xsl:element name="ENDDATE">
                            <xsl:attribute name="ReasonForNull">
                                <xsl:value-of select=" '9' "/>   " Set value for attribute !!!
                            </xsl:attribute>
                        </xsl:element>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="node()"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
    " Result of transformation:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ENDDATE>2008-07-31</ENDDATE>
    <ENDDATE ReasonForNull="9"/>
    Regards
      Uwe

  • XSLT transformation not working in 1.5 (but was in 1.4)

    Gentlemen,
    I have a problem with some code that worked fine under 1.4 (at least up to 1.4.2_06), but now no longer works under 1.5.0 (I know this isn't the most recent, but I have yet to update).
    I use the following XSL template in order to take a string containing a valid XML definition, strip out all whitespace (this is ok, I know I dont need it), and then indent it in a nice readable format.
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0" xmlns:xalan="http://xml.apache.org/xslt">
      <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" xalan:indent-amount="2"/>
        <xsl:strip-space elements="*"/>
          <xsl:template match="@*|node()">
            <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
          </xsl:template>
    </xsl:stylesheet>The code I use to perform the transformation is as follows :
    // read the XML string into a DOM document structure
    StringReader reader = new StringReader(xmlString);
    InputSource source = new InputSource(reader);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(source);
    // Input file to be transformed is the DOM document we have just created
    Source input = new DOMSource(doc);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(new StringReader(TEMPLATE_AS_DEFINED_ABOVE)));
    // create output writer and transform
    StringWriter writer = new StringWriter();
    transformer.transform(input, new StreamResult(writer));
    System.out.println(writer.toString());As already stated, this produced the goods, in 1.4.2_06, but in 1.5.0 it results in the following error :
    java.lang.NullPointerException
         at gnu.xml.aelfred2.SAXDriver.getLineNumber(SAXDriver.java:1165)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parseTopLevel(Parser.java:1077)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parsePattern(Parser.java:1067)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Template.parseContents(Template.java:213)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:590)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:562)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:380)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:325)
         at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:410)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:791)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
         at com.ingenico.tests.ReportTest.prettifyXMLString(ReportTest.java:231)
         at com.ingenico.tests.ReportTest.<init>(ReportTest.java:100)
         at com.ingenico.tests.ReportTest.main(ReportTest.java:136)
         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)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
    ERROR:  'null'
    FATAL ERROR:  'Could not compile stylesheet'
    Exception in thread "main" javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
         at com.ingenico.tests.ReportTest.prettifyXMLString(ReportTest.java:231)
         at com.ingenico.tests.ReportTest.<init>(ReportTest.java:100)
         at com.ingenico.tests.ReportTest.main(ReportTest.java:136)
         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)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)I have a headache now and would appreciate some help - not with the headache, but the above error! :)
    Cheers in advance,
    Lee.

    have you tried to remove the xalan specific entries
    in the XSL and use that code:
    transformer.setOutputProperty("{http://xml.apache.org/
    xslt}indent-amount", "2");?Thanks for the reply.
    Unfortunately, Ive already tried this, and it's not the problem.
    If I remove the whole <xsl:template match /> section from the template, then the compilation error does not occur. I guess this narrows it down somewhat, but I don't know why that section is now failing under 1.5. (Ive since also tried with 1.5.0_03 - same error).

  • XSLT transformation issue

    Hi Everybody,
    I have the following structure XML badly formatted provided from an external application. It's imposed like that.
    <?xml version="1.0" encoding="UTF-8"?>
    <n:root xmlns:n="http://www.something">
         <order number="1234"/>
         <orderline item="1" nom="moi"/>
         <orderline item="2" nom="toi"/>
         <order number="456"/>
         <orderline item="1" nom="bien"/>
         <orderline item="2" nom="mal"/>
    </n:root>
    Each <order> in followed by multiple <orderline> which belong to the <order< without any sequence except the order in xml.
    I need to transform it into a better structure as follow
    <n:root xmlns:n="http://www.something">
         <order>
              <number>1234</numero>
              <orderline>
                   <item>1</item>
                   <nom>moi</nom>
              </orderline>
              <orderline>
                   <item>2</item>
                   <nom>toi</nom>
              </orderline>
         </order>
         <order>
              <number>456</number>
              <orderline>
                   <item>1</item>
                   <nom>bien</nom>
              </orderline>
              <orderline>
                   <litem>2</item>
                   <nom>mal</nom>
              </orderline>
         </order>
    </n:root>
    I need to do that in XSLT without the use of PI mapping because I need to create a SOAP envelope completely want I need to put some fields dynamically in the soap-header.
    Is there someone who can help me, please?
    Kind Regards.
    E. Koralewski

    I found the solution,
    There is the coding of mu XSLT.
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:n="http://www.something" exclude-result-prefixes="n">
         <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
         <xsl:key name="fils" match="orderline" use="generate-id(preceding-sibling::order[1])"/>
         <xsl:template match="/">
              <n:root xmlns:n="http://www.something">
                   <xsl:apply-templates select="//order "/>
              </n:root>
         </xsl:template>
         <xsl:template match="orderline ">
              <orderline>
                   <item>
                        <xsl:value-of select="@item"/>
                   </item>
                   <nom>
                        <xsl:value-of select="@nom"/>
                   </nom>
              </orderline>
         </xsl:template>
         <xsl:template match="order ">
              <order>
                   <number>
                        <xsl:value-of select="@number"/>
                   </number>
                   <xsl:apply-templates select="key('fils',generate-id())"/>
              </order>
         </xsl:template>
    </xsl:stylesheet>

  • Dynamic XSLT Transformation for ABAP

    Hi Team,
    I have a simple requirement, but could not get it to work. Tried different posts but need some help.
    I have an input XML file as follows:
    <ITEM>
       <ITEMQUALF>
       <MATERIAL>
       <UPC>
       <VENDORMATERIAL>
    <ITEM>
    I created my internal table with the exact fields as above and created a transformation which works fine. The problem is, there are scenario's where only one tag "MATERIAL", "UPC", OR "VENDORMATERIAL" is passed in the input XML. Empty tags are not passed. For E.G.
    <ITEM>
      <ITEMQUALF>
      <UPC>
    <ITEM>
    My transformation fails in this scenario because it does not finds the MATERIAL and VENDORMATERIAL tags. I tried using the <tt:cond/> tag, but no luck. I have some specific questions:
    1) How to take care of this scenario where empty tags are not passed? (I have the Superset of all the Tags available in an XSD). A quick Sample would help me a lot because I have spent weeks breaking my head with this.
    2) Is there any other method or Option to parse a very larger input file (~40 MB) as above? I have seen the iXML ABAP methods but don't know if we should use XSLT or iXML or is there any other method. We don't have XI in our landscape. Our system is ECC 6.0, ABAP 7.0 - SP 17, Enhancement Pack 3.
    Any pointers would help a lot. Thanks for your time.
    Regards
    Sanjay

    Hello Sanjay
    In such a scenario I usually make pre-transformation filling the missing elements before the main mapping.
    Input:
    <?xml version="1.0" encoding="utf-8"?>
    <List>
      <ITEM>
        <ITEMQUALF/>
        <MATERIAL/>
        <UPC/>
        <VENDORMATERIAL/>
      </ITEM>
      <ITEM>
        <ITEMQUALF/>
        <UPC/>
      </ITEM>
      <ITEM>
        <MATERIAL/>
      </ITEM>
    </List>
    XSLT Mapping (XML to XML):
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <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 name="UPC">
                            <xsl:value-of select="UPC"/>   
                        </xsl:element>
                        <xsl:element name="VENDORMATERIAL">
                            <xsl:value-of select="VENDORMATERIAL"/>   
                        </xsl:element>
                    </xsl:element>
                </xsl:for-each>
            </List>
        </xsl:template>
    </xsl:stylesheet>
    Resulting XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <List>
        <ITEM>
            <ITEMQUALF/>
            <MATERIAL/>
            <UPC/>
            <VENDORMATERIAL/>
        </ITEM>
        <ITEM>
            <ITEMQUALF/>
            <MATERIAL/>
            <UPC/>
            <VENDORMATERIAL/>
        </ITEM>
        <ITEM>
            <ITEMQUALF/>
            <MATERIAL/>
            <UPC/>
            <VENDORMATERIAL/>
        </ITEM>
    </List>
    Regards
      Uwe

Maybe you are looking for