Sitemap

Amicuk Programming Answers

Problem getting xslt transform to work

-0001-11-30   Views:4

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
I noticed that encoding to MPEG2 (for DVD's) using the CPU (through Media Encoder) produces much better results than does the MPEG2 codec the uses the GPU.  Just finished a documentary and was preparing it for DVD.  During fades to black, I would get [More]
I have Labview 8.5, cRIO 9014 and 2 NI 9474 DO modules. In my FPGA VI, I have 5 loops.  The first loop deals with my 9474 cars.  I have boolean values as inputs to that when the boolean is one, the DO# will turn on.  This loop runs 1 time.  In side F [More]
When I send and receive messages they don't look normal like they used to. Search for an app in the app store that does this.  You can't do this on the phone natively.Read other 2 answers [More]
I am running Osx 10.3.9 and have idvd4. Unfortunatly i have an external dvd burner and idvd4 will not burn to this. Will idvd6 work on my system as Ive heard this works with an external burner.Hi chadredford: Yes-iMovie 6 would allow you to natively [More]
Is it possible to display the response after a http request in forms? the response comes from a kind of reader which sends the reading-result as parameters after a request.Hello Henry, We are firing the CREATE/POST operation in the BATCH mode exactly [More]
NW5.1SP8 - The server has been up and operating for over 5 years. Legacy printing with LPTx ports in the server using NPRINTER.NLM. We have a DOS application that prints to NetWare queues via a CAPTURE of a WS's LPTx port. This worked fine under W9x [More]
I have built a desktop website, but would also like to build a mobile version of the same site. Can Muse support a desktop and mobile edition of the same website? So for example, if the user is viewing the site on an iPhone, they see a mobile-optimis [More]
Hi, I installed BranchCache server feature on Windows Server 2008R2. When trying to enable BranchCache on SMB folder share, the check box is grayed out. can anybody help me with this. Thanks akosijesyang - the conquerorHi akosijesyang, Is the BranchC [More]
Hello Folks! Is there anyone has a broader knowledge on how to find the TV series called "THE BORGIAS " ? I have been trying to look for it and so I can download the whole series but it seems unavailable yet in iTunes or is it not really availab [More]
When I start iTunes, I keep getting the message saying that "registry settings are missing for importing and burning CDs and DVDs. This can happen as a result of installing other CD burning software. Please reinstall iTunes." I've reinstalled iT [More]