Sitemap

Amicuk Programming Answers

Problem getting xslt transform to work

-0001-11-30   Views:5

Advertisement

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="*"/>      &

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 ?

The replay answer
Advertisement
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.

Go to See the other 4 answers

Problem with XSLT Transformation on BPM

Category:DefaultRelease time:2015-10-11Views:130

Hi there, I have a 1:N File --> Idocs Scenario with BPM, Inside the BPM i have an XSLT Transformation that has a problem i cant figure out, basically this XSLT Groups the file structure like this: <File>                                           [More]

Problem getting xslt transform to work

Category:DefaultRelease time:-0001-11-30Views:130

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="*"/>      &[More]

Facing problem in XSLT transformation

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I m new bie to XSLT n transformation. I have written a simple java program that uses the javax.xml.transform and javax.xml.parsers package to transform source file using a XSL file provided. When I excuted the program providing XSLT file that[More]

XSLT transformation: tamplate match="*" problem

Category:DefaultRelease time:2015-10-11Views:130

Hi everybody, I have some stupid problem with XSLT transformations. I use XALAN-J 2.7 to transform xml files. My xslt transformation can be downloaded from http://tesla.rcub.bg.ac.yu/~sing/xsd2rdf.xslt Problem is when I have in xslt file template def[More]

Issue with xslt transform

Category:DefaultRelease time:2015-10-11Views:130

I'm having a problem with xslt transformations. I'm sending a DOMDocument to be transformed into a varchar2. The transformation was into html and I was then printing the returning varchar2 to a web page, along the lines of... htp.prn(Xslt.transform(d[More]

XSLT Transformation problem

Category:DefaultRelease time:2015-10-11Views:130

Hi, hope anybody can help. I try to transform a object to another object via XSLT transformation. Here is my coding :   DATA: wa_transformation TYPE y0dpl_structures.   DATA: obj_import TYPE abap_trans_srcbind_tab,         wa_import TYPE abap_trans_s[More]

Problem with x:transform function : translation with XSLT

Category:DefaultRelease time:2015-10-11Views:130

I've got a problem with this code : This is the XML file : <%@taglib prefix="x" uri="http://java.sun.com/jstl/xml"%> <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <c:import var="xslD[More]

Problem in Call transformation - xslt program

Category:DefaultRelease time:2015-10-11Views:130

Hi Experts, For the below XML file i have declared the XSLT Program  as described. i am not able to get the data into Internal table. Could you pls help me in where am i going wrong? Is it XSLT declaration or what? Data declarations TYPES: BEGIN OF T[More]

PL/SQL XSLT transformation problem

Category:DefaultRelease time:2015-10-11Views:130

I am trying to perform an XSLT transformation inside a PL/SQL procedure using dbms_xslprocessor.processxsl() but I am getting the following error 'LPX-00411: unknown function name encountered' The transformation XSL contains a java extension to prefo[More]

Error when applying a XSLT transformation

Category:DefaultRelease time:2015-10-11Views:130

central instance transaction SURVEY Extras->Target Group Hierarchy-> Import from file select file Error when applying a XSLT transformation dialog instance workingHello Andrey Kuryanov, Could make sure you describe the problem more clear as much as[More]

UTF-8 encoding in XSLT transformation

Category:DefaultRelease time:2015-10-11Views:130

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">   <x[More]

Hot
Hey, I am facing with this peculiar problem of transaction variant. I created a transaction variant as desired by my client for VA01 and activated the same. I checked the status in the transaction VA01 and there it showed that the transaction variant [More]
Hi there, I wrote an iBooks and I want to publish it on the iBooks store but i can't connect to iTunes Connect. It says " The iTunes Store account entered is already being used for an iTunes Connect account that distributes Apps. To continue with thi [More]
anyone have any ideas, i cant upload any of my songs or podcasts or photos.You MUST use a USB 2.0... It does not work with a USB 1.0 I spent days hating my ipod before finding this out. Now it works perfectly. CiaoRead other 4 answers [More]
When i try to open up Safari, it bounces around 2-3 times and then stops. it wont open at all. I have tried finding out on how to fix this problem but found nothing. how do i fix this problem?Do a backup. Quit the application. In Finder hold down the [More]
Just recently, with Windows 8 and Premiere CC, I get a bug that makes Premiere unusable.  Certain windows don't draw or update regularly.  See attached screenshot (https://dl.dropboxusercontent.com/u/651378/premiere%20windows%20not%20showing.PNG).  N [More]
Hi Everyone, can anyone guide me one the diffrence between the BW BPS and SEM BPS . Please do guide me if there is any site /link that provide the above informationHi From netweaver 2004 i.e BW3.5 BPS is integrated with BW and called as BW-BPS, prior [More]
Hi All, I have a group of date from that is it possible to Max and Min of date. I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>. I have also tried like this but it doesnt works <?xdoxslt:minimum(CREATION_DATE)?& [More]
Can dlsw ethernet redundancy support mutliple vlans with the following configuration? host dlsw router1 host dlsw router2 | | local dlsw router 1 local dlsw router2 | | ethernet switch1-------ethernet switch2 Ethernet switch1 and 2 are supporting mul [More]
Hi all, My client business process is there creating Sales Contracts base on validity period pricing Sales Contracts are created for long periods.The base price changes every year / for defined period. For Example: Contract created for 10 years. Firs [More]
Hi, I am developing one paint program. I am drawing over an image but the image is wash out when i am dragging mouse on canvas. But when i am clicking first on canvas before selecting any button. then selecting button after that it is working fine. P [More]