XSLT 2.0 transformations in BPEL?
I'm using BPEL 10.1.3.1.0, and I want to execute a simple xslt 2.0 stylesheet, that takes two dateTime variables from the inputVariable payload, subtracts them to get a duration, and put this duration back into the outputVariable payload...
Stylesheet:
<xsl:stylesheet version="2.0"
xmlns:ns1="http://xmlns.oracle.com/durationTest"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
exclude-result-prefixes="xsl ns1 xs fn fo">
<xsl:template match="/">
<ns1:durationTestProcessResponse>
<ns1:result>
<xsl:value-of select="/ns1:durationTestProcessRequest/ns1:date2 - /ns1:durationTestProcessRequest/ns1:date1"/>
</ns1:result>
</ns1:durationTestProcessResponse>
</xsl:template>
</xsl:stylesheet>This is a snippet from our BPEL process (transform activity):
<assign name="subtractDates">
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression="ora:processXSLT('Transformation_1.xsl',bpws:getVariableData('inputVariable','payload'))"/>
<to variable="outputVariable" part="payload"/>
</copy>
</assign>My input variable XSD is:
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/durationTest"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="durationTestProcessRequest">
<complexType>
<sequence>
<element name="date1" type="dateTime"/>
<element name="date2" type="dateTime"/>
</sequence>
</complexType>
</element>
<element name="durationTestProcessResponse">
<complexType>
<sequence>
<element name="result" type="duration"/>
</sequence>
</complexType>
</element>
</schema>This stylesheet works without any problems if I try it in XMLSpy. However, when I execute my BPEL process, the payload of the outputVariable is empty. I do not get any errors... Anyone know why my stylesheet isn't properly executed? If I change the xslt version to 1.0 the result gets filled with 'NaN', which is logical...
TIA,
Bas
For anyone that's interested, I got it to work... The solution was to add dateTime() around the XPath locations to the variables:
<xsl:value-of select="dateTime(/ns1:durationTestProcessRequest/ns1:date2) - dateTime(/ns1:durationTestProcessRequest/ns1:date1)"/>
Similar Messages
-
How to implement multi-source XSLT mapping in 11g PS3 BPEL ?
Hi
How to implement multi-source (single destination) XSLT mapping in 11g PS3 BPEL ? Is there any good example step by step ?
thx
dHi d,
Also there's a sample available at samplecode.oracle.com mapper-105-multiple-sources.zip.
Regards,
Neeraj Sehgal -
XSLT 1:1 transformation?
Communication: asynchronous between SPROXY => XI => 3rd Party Webervice.
I've huge XML response with a lot of tags. I just want to have on SPROXY 1:1 response. I've imported from XSD structure of response. I've created message types and message interfaces. I need now to create message mappings between 3rd_party_response and sproxy_response. As I wrote XML has a huge tags (c.a. different 500 tags). Creating those mapping manually is a madness. How can I do this automatically? I guess I can use for that XSLT transformation. Do you have maybe and example of XSLT 1:1 transformation or maybe there is a simplier solution?
Helping answers => a lot of pointsHello ,
You can go with XSLT....
follow these links,
Follow these links.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2ea3bb983c1
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9692eb84-0601-0010-5ca0-923b4fb8674a
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/006aa890-0201-0010-1eb1-afc5cbae3f15
Some scenarios
/people/sap.user72/blog/2005/03/15/using-xslt-mapping-in-a-ccbpm-scenario
/people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
*************8Reward points,if found useful -
Hi all
How come most of the BPEL XPath expressions can't be used in a stylesheet, with a PerformXSLT()? It would be nice if you could read preference values from bpel.xml within a stylesheet.
Also, the xslt mapper in JDeveloper is a bit limited, many complex stylesheets cannot be shown with the mapper. Would it be possible to improve the mapper, perhaps just show a "black-box" for the unsupported constructions in the stylesheet?
cheers
/StigStig,
a lot of issues have been fixed with 10.1.3.1 - which is currently in preview - and the reason why you cannot sue most of the bpel ones, is because we provide a special interface that needs to be implemented, and is filled inside the engine only ..
hth clemens -
XSLT and XQuery recommendation for BPEL and OSB
Hi,
1. Why is XQuery recommeded for OSB and XSLT for BPEL. Are there any specific performance optimization reason behind this.
2. Apart from OSB and BPEL, both XSLT and XQuery has xml transformation options and creating HTML. What is the difference between these two.
Thanks in advance!you can create the graphical view of Xquery in Eclipse but not for XSLT
Xquery is much faster than XSLT in OSB.
Through XSLT however you can achieve more complex transformation.
OSB has its historic origins in BEA Aqalogic stable and so Xquery was widely used used even though XSLT is supported. It is a matter of choice(your standards in your organization,your developer skillsets,your re-usable libraries etc )
In Jdeveloper you can develop xslt in graphical mode though and attain complex transformation -
XSLT not working correctly in BPEL
Hi,
We are using XSLT to remove namespaces from our XSL. When testing this XSL in Jdeveloper, it works fine. But when we using it in BPEL, the transformation is not working correctly.
Please find below the XSL content
+<xsl:stylesheet version="1.0"+
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"+
xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
exclude-result-prefixes="xsl xref xp20 bpws ora ehdr orcl ids hwf">
+<xsl:template match="comment()|processing-instruction()|/">+
+<xsl:copy>+
+<xsl:apply-templates/>+
+</xsl:copy>+
+</xsl:template>+
+<xsl:template match="*">+
+<xsl:element name="{local-name()}">+
+<xsl:apply-templates select="@* | node()"/>+
+</xsl:element>+
+</xsl:template>+
+<xsl:template match="@*">+
+<xsl:choose>+
+<xsl:when test="name() != 'xmlns'">+
+<xsl:attribute name="{local-name()}">+
+<xsl:value-of select="."/>+
+</xsl:attribute>+
+</xsl:when>+
+</xsl:choose>+
+</xsl:template>+
+</xsl:stylesheet>+
The BPEL code of the transform is:
+<assign name="Transform_1">+
+<bpelx:annotation>+
+<bpelx:pattern>transformation</bpelx:pattern>+
+</bpelx:annotation>+
+<copy>+
+<from expression="ora:processXSLT('Transformation_1.xsl',bpws:getVariableData('inputVariable','payload'))"/>+
+<to variable="TempVar" part="payload" query="/ns1:mthReplacement_input"/>+
+</copy>+
+</assign>+
Not sure why the transformation isnt working in BPEL. Has anyone faced similar issues? Please share your experiences.
Thanks
JohnHi John ,
We have tried this instead of writing new code in the xslt , pls do the following
1.Open the xslt in jdev.
2.Remove the attribute exclude-result-prefixes for the element xsl:stylesheet.
3.Your new XSLT file should look like below,
<xsl:stylesheet version="1.0"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
>
....business logic...
</xsl:stylesheet>
4.Compile and deploy your BPEL Process.
5.You should not see any namespaces in the BPEL Console now for this xslt.
Thank you.
Regards
Venkat. -
Transformations in BPEL/ESB
Hi,
Can anybody explain how the transformations are handled
at run-time by BPEL or ESB? I have the following
questions, which I don't have much material to discuss with:
1. How does BPEL handle a transformation at runtime?
2. If the message size is very high, how is it handled?
3. Is there a difference between BPEL and ESB in
handling the transformations?
4. If the message size is huge, say in terms of GB in size,
how it is handled in the memory? Does it use any kind of
caching?
If anybody can point me to some documents or links,
that would be very helpful in understanding these concepts.
This is required for us since we have a requirement where the
message size can reach upto 7GB.
Thanks in advance.
Leo.1. How does BPEL handle a transformation at runtime?
This is done based on XML using xpath queries or by using the XSLT translator.
2. If the message size is very high, how is it handled?
The same
3. Is there a difference between BPEL and ESB in
handling the transformations?
No, they are using the same code.
4. If the message size is huge, say in terms of GB in size,
how it is handled in the memory? Does it use any kind of
caching?
Everything is handled in memory. This means that you must be aware on this, resulting in garbage collection in the JVM engine.
http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28982/toc.htm -
XSLT mapping - Which transformation engine is used in PI 7.0
Hi,
In my favorite xslt tool I can choose which transformation engine I want to use while executing the xsl.
Which Transformation engine is used in PI 7.0 ?
(Nice to test with the same as PI have....)
Br, MartinHi ,
as per my knowledge PI 7.0 uses XALAN parcer to execute XSLT Mapping programs,its available in in PI server it slelf.
Regards,
Raj -
XML to Internal table using XSLT by CALL TRANSFORMATION error
Dear experts,
I have to fetch the data from an XML file using XSLT into internal tables. The XML file is very big as following:-
<?xml version="1.0" standalone="yes" ?>
- <Shipment>
<shipmentID>25091203S000778</shipmentID>
<manifestDateTime>2009-12-03T20:16:52.00</manifestDateTime>
<shipmentFacilityNumber>025</shipmentFacilityNumber>
<shipmentFacilityAbbreviation>CHI</shipmentFacilityAbbreviation>
<shipmentFacilityAddress1>810 KIMBERLY DRIVE</shipmentFacilityAddress1>
<shipmentFacilityAddress2 />
<shipmentFacilityCity>CAROL STREAM</shipmentFacilityCity>
<shipmentFacilityState>IL</shipmentFacilityState>
<shipmentFacilityPostalCode>601880000</shipmentFacilityPostalCode>
<shipmentTruckCarrierCode>X150</shipmentTruckCarrierCode>
<shipmentSourceCode>T</shipmentSourceCode>
<userID>CAMPOSG</userID>
- <Delivery>
<primaryCustomerNumber>954371</primaryCustomerNumber>
<primaryCustomerName>MIDWEST OFFICE SUPPLY</primaryCustomerName>
<primaryCustomerAddress1 />
<primaryCustomerAddress2>4765 INDUSTRIAL DR</primaryCustomerAddress2>
<primaryCustomerCity>SPRINGFIELD</primaryCustomerCity>
<primaryCustomerState>IL</primaryCustomerState>
<primaryCustomerPostalCode>627030000</primaryCustomerPostalCode>
<primaryCustomerPhoneNumber>2177535555</primaryCustomerPhoneNumber>
<shuttleStopFacilityNumber />
<billOfLadingNumber>25HZK99</billOfLadingNumber>
<carrierProNumber />
<shipmentTotalCartonCount>6</shipmentTotalCartonCount>
<shipmentTotalWeight>266</shipmentTotalWeight>
- <order>
<orderNumber>25HZK99</orderNumber>
<subOrderNumber />
<dateProcessed>2009-12-03</dateProcessed>
<primaryOrderNumber />
<shipTruckCode>X150</shipTruckCode>
<shipTruckDescription>UDS - ADDISON</shipTruckDescription>
<shipTruckPriorityCode>01</shipTruckPriorityCode>
<shipTruckGroupCode>01</shipTruckGroupCode>
<shipTruckDepartureTime>20.00.00</shipTruckDepartureTime>
<shipTruckDockID>07</shipTruckDockID>
<ldpFacilityAbbreviation />
<shuttleAvailableIndicator>N</shuttleAvailableIndicator>
<shuttleMessageText />
<crossDockFacilityCode />
<crossDockTruckCode />
<crossDockID />
<subsidizedFreightTruckID />
<customerPurchaseOrderNumber>623559</customerPurchaseOrderNumber>
<headerTypeCode>P</headerTypeCode>
<orderTypeID>RG</orderTypeID>
<deliveryTypeID>DS</deliveryTypeID>
<deliveryMethodCode />
<customerBarCode />
<customerReferenceData>25HZK99</customerReferenceData>
<customerReferenceText />
<customerRouteData>ZNED UNTED</customerRouteData>
<customerRouteText>ROUTE</customerRouteText>
<endConsumerPurchaseOrderNumber />
<endConsumerPurchaseOrderText />
<endConsumerName>CHARLESTON TRANS. FACILITY</endConsumerName>
<endConsumerAddress1>HOMEWOOD DT PROGRAM DEPT. 3</endConsumerAddress1>
<endConsumerAddress2>17341 PALMER BLVD.</endConsumerAddress2>
<endConsumerAddress3 />
<endConsumerCity>HOMEWOOD</endConsumerCity>
<endConsumerState>IL</endConsumerState>
<endConsumerPostalCode>60430</endConsumerPostalCode>
<endConsumerCountryCode />
<fillFacilityNumber>025</fillFacilityNumber>
<shpFacilityNumber>025</shpFacilityNumber>
<homeFacilityAbbrCode>STL</homeFacilityAbbrCode>
<homeFacilityNumber>015</homeFacilityNumber>
<multiCartonIndicator>Y</multiCartonIndicator>
<primaryCustomerIndicator>Y</primaryCustomerIndicator>
<shipToCustomerNumber>954371001</shipToCustomerNumber>
<customerCompanyID>01</customerCompanyID>
<customerTruckID>U888</customerTruckID>
<customerTruckDescription>UDS - ADDISON</customerTruckDescription>
<customerTruckDockID>13</customerTruckDockID>
<thirdPartyBillCarrier />
<thirdPartyBillID />
<thirdPartyBillType />
<qualityCheckIndicator>N</qualityCheckIndicator>
<warehouseLaydownID />
<packListPosition>I</packListPosition>
<preferredPackingType>CTN</preferredPackingType>
<preferredPackingMaterial>PAPER</preferredPackingMaterial>
<preferedPackingInstructions />
<totalOrderCartonQty>6</totalOrderCartonQty>
<convertAddressIndicator>N</convertAddressIndicator>
<dealerInstructionIndicator>Y</dealerInstructionIndicator>
<dealerinstructions1>CPO#: 623559</dealerinstructions1>
<dealerinstructions2>ATTN: DANA GRIFFIN</dealerinstructions2>
<dealerinstructions3>INFO: 612</dealerinstructions3>
<dealerinstructions4>ROUTE: ZNED UNTED</dealerinstructions4>
<dealerinstructions5 />
<dealerinstructions6 />
<shippingInstructionsIndicator>N</shippingInstructionsIndicator>
<shippingInstructions1 />
<shippingInstructions2 />
<shippingInstructions3 />
<shippingInstructions4 />
<shippingInstructions5 />
<shippingInstructions6 />
<specialInstructionsIndicator>N</specialInstructionsIndicator>
<specialInstructions1 />
<specialInstructions2 />
<customeContainerDesc />
- <carton>
<deliveryCartonID>253370905995</deliveryCartonID>
<shipIndicator>Y</shipIndicator>
<deliveryPalletID>X150</deliveryPalletID>
<consolidatedDeliveryCartonID />
<scanDateTime>2009-12-03T19:36:12.00</scanDateTime>
<cartonWeight>52</cartonWeight>
<dropShipFlag>1</dropShipFlag>
<carrierTrackingNumber />
<carrierZoneID>0</carrierZoneID>
<codAmount />
<customerPackageAmount />
<declaredValue />
<residentialDeliveryIndicator />
<serviceTypeCode>00</serviceTypeCode>
<ssccCode>006860244400829393</ssccCode>
- <Item>
<shipPrefix>UNV</shipPrefix>
<shipStockNumber>21200</shipStockNumber>
<itemDescription>PAPER XERO/DUP WE LTR 20#</itemDescription>
<orderQuantity>1</orderQuantity>
<originalShipQuantity>1</originalShipQuantity>
<shipQuantity>1</shipQuantity>
<inventoryUnitCode>CT</inventoryUnitCode>
<inventoryWeightQuantity>52.000</inventoryWeightQuantity>
<upcNumber>00000000000000</upcNumber>
<upcRetailCode>087547212004</upcRetailCode>
<hazmatIndicator>N</hazmatIndicator>
<serialRequiredIndicator>N</serialRequiredIndicator>
<dealerMemoPO>S</dealerMemoPO>
<cartonLineNumber>1</cartonLineNumber>
<orderLineNumber>11</orderLineNumber>
<originalOrderPrefix>UNV</originalOrderPrefix>
<originalOrderStockNumber>21200</originalOrderStockNumber>
<reasonCode />
- <Item_Serial>
<serialNumber />
</Item_Serial>
</Item>
</carton>
</order>
</Delivery>
</Shipment>
This is not the complete XML file as it exceeds the 15000 characters and then I cann't post here. So I have deleted much part of it.
The hierarchy is as following: Shipment->Delivery->Order->Carton->Item.
I have created a XSLT for it which is working fine.
But when I execute my report program it gives CX_SY_XSLT_FORMAT_ERROR saying that
Transformation error: Non-canonical structure of element name XML_OUTPUT.Dear experts,
My report program is as following:-
*& Report Z_ASNTRNS
REPORT Z_ASNTRNS.
*& Report Z_ASNTRNS
TYPE-POOLS: abap, ixml.
TABLES: ZASN_SHIPMENT,ZASN_DELIVERY,ZASN_ORDER,ZASN_CARTON,ZASN_ITEM.
*CONSTANTS gs_file TYPE string VALUE 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
This is the structure for the data from the XML file
TYPES: BEGIN OF ts_item,
ZSHIPMENT LIKE ZASN_ITEM-ZSHIPMENT,
VBELN LIKE ZASN_ITEM-VBELN,
ORDER_NUMBER LIKE ZASN_ITEM-ORDER_NUMBER,
CARTON_ID LIKE ZASN_ITEM-CARTON_ID,
ITEM LIKE ZASN_ITEM-ITEM,
CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
AEDAT(8),
AEZET(6),
ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
ORD_QTY(16),
ORIGINAL_SHIP(16),
SHIP_QTY(16),
UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
DEALER_MEMO_PO(5),
ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
STATUS LIKE ZASN_ITEM-STATUS,
END OF ts_item.
TYPES: BEGIN OF ts_carton,
ZSHIPMENT LIKE ZASN_CARTON-ZSHIPMENT,
VBELN LIKE ZASN_CARTON-VBELN,
ORDER_NUMBER LIKE ZASN_CARTON-ORDER_NUMBER,
CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
AEDAT(8),
AEZET(6),
SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
ZZCARTON_WGT(18),
Item type ts_item,
END OF ts_carton.
TYPES: BEGIN OF ts_order,
ZSHIPMENT LIKE ZASN_ORDER-ZSHIPMENT,
VBELN LIKE ZASN_ORDER-VBELN,
ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
AEDAT(8),
AEZET(6),
SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
ORDER_DATE(8),
PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
ANZPK(5),
carton type ts_carton,
END OF ts_order.
TYPES: BEGIN OF ts_delivery,
ZSHIPMENT LIKE ZASN_DELIVERY-ZSHIPMENT,
VBELN LIKE ZASN_DELIVERY-VBELN,
AEDAT(8) TYPE C,
AEZET(6) TYPE C,
PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
CARTON_COUNT(5),
TOTAL_WEIGHT(18),
order type ts_order,
END OF ts_delivery.
TYPES: BEGIN OF ts_shipment,
ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
MANIFEST_DATE_TIME(25),
AEDAT(8) TYPE C,
AEZET(6) TYPE C,
SDATE(8) TYPE C,
STIME(6) TYPE C,
SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
Delivery type ts_delivery,
END OF ts_shipment.
TYPES: BEGIN OF ts_shipment1,
ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
MANIFEST_DATE_TIME(25),
SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
CARTON_COUNT(5),
TOTAL_WEIGHT(18),
ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
ORDER_DATE(8),
PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
ZZCARTON_WGT(18),
ITEM LIKE ZASN_ITEM-ITEM,
CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
ORD_QTY(16),
ORIGINAL_SHIP(16),
SHIP_QTY(16),
UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
DEALER_MEMO_PO(5),
ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
END OF ts_shipment1.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
*Typdefinition für Airplus
*READ THE DOCUMENTATION "LASG_XML_INVOICE_BTM"!!!
VARs beginning with "a_" are ATTRIBUTES
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_ostream TYPE REF TO if_ixml_ostream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xml TYPE REF TO cl_xml_document,
l_xmldata TYPE string.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
l_xml_line TYPE t_xml_line,
l_xml_table_size TYPE i.
DATA: l_filename TYPE string.
DATA: xml_out TYPE string ,
size type i.
DATA: l_xml_x1 TYPE xstring.
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce.
l_itab TYPE TABLE OF string.
DATA: BEGIN OF l_itab occurs 0,
data(256) type c,
end of l_itab.
TYPES : BEGIN OF TY_TEXT,
data(255) type C,
END OF TY_TEXT.
DATA: F_XML TYPE STRING.
DATA : LT_TEXT_OUT type table of TY_TEXT with header line.
tables
DATA: it_shipment TYPE STANDARD TABLE OF ts_shipment,
wa_shipment TYPE ts_shipment.
*Errorvariables
DATA: xslt_err TYPE REF TO cx_xslt_exception,
err_string TYPE string.
PARAMETERS: pa_file TYPE localfile OBLIGATORY
DEFAULT 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
here we use the CALL TRANSFORMATION method which calls
the XSLT program "z_asnfile"
TRY.
CALL TRANSFORMATION ('Z_ASNFILE')
SOURCE xml LT_TEXT_OUT[]
RESULT xml_output = it_shipment
catch any error, very helpful if the XSLT isn't correct
CATCH cx_xslt_exception INTO xslt_err.
err_string = xslt_err->get_text( ).
WRITE: / 'Transformation error: ', err_string.
EXIT.
ENDTRY." setting a breakpoint to watch the workarea
by the internal table "it_airplus"
break-point.
LOOP AT it_shipment INTO wa_shipment.
ENDLOOP.
*& Form get_xml_table
FORM get_xml_table CHANGING l_xml_table_size TYPE i
l_xml_table TYPE STANDARD TABLE.
l_filename = pa_file.
upload a file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
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.
Convert binary to text.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
INPUT_LENGTH = 70000
FIRST_LINE = 0
LAST_LINE = 0
APPEND_TO_TABLE = ' '
MIMETYPE = ' '
WRAP_LINES = 'X'
IMPORTING
OUTPUT_LENGTH =
TABLES
BINARY_TAB = l_xml_table
TEXT_TAB = LT_TEXT_OUT
EXCEPTIONS
FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "get_xml_table -
XSLT and ABAP Transformation Deep Structure
Hello Everyone,
While I've read the forums and the links of a number of folks doing the same thing. I am stuck in that I cannot figure out how to populate a deep structure via XSLT. Not sure what is going wrong, but I suspect it is obvious. The simple problem is that my structure is not getting populated. It is blank. The transformation works in testing STRANS (and in Stylus Studio).
I cannot figure out what is wrong that makes the t_pexr2002 table blank. Thanks for any insight.
Greg
The simple program is:
TYPES: BEGIN OF ty_head,
sndprn TYPE string,
bgmref TYPE string,
moabetrh TYPE string,
create_date TYPE string,
settlement_date TYPE string,
no_lines TYPE string,
END OF ty_head.
TYPES: BEGIN OF ty_pricing,
moabetr TYPE string,
END OF ty_pricing.
TYPES: BEGIN OF ty_item,
docname TYPE string,
docnummr TYPE string,
pricing TYPE ty_pricing,
END OF ty_item.
TYPES: BEGIN OF ty_summary,
status_message TYPE string,
END OF ty_summary.
TYPES: BEGIN OF ty_mn,
header_data TYPE ty_head,
item_data TYPE ty_item,
summary_data TYPE ty_summary,
END OF ty_mn.
DATA: t_pexr2002 TYPE STANDARD TABLE OF ty_mn.
DATA: xml_doc TYPE REF TO cl_xml_document, xml TYPE string.
CREATE OBJECT xml_doc.
CALL METHOD xml_doc->import_from_file
EXPORTING
filename = 'C:\temp\2640273.xml'.
CALL METHOD xml_doc->render_2_string
EXPORTING
pretty_print = 'X'
IMPORTING
stream = xml.
CALL TRANSFORMATION zusl_pexr2002_v1
SOURCE XML xml
RESULT output = t_pexr2002.
Edited by: Thomas Zloch on Jun 9, 2010 6:05 PMHere is my XSLT:
Here is the transformation: Also pretty simple...
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... >
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<OUTPUT>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETRH>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETRH>
<CREATE_DATE>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREATE_DATE>
<SETTLEMENT_DATE>
<xsl:value-of select="E1EDK03/DATUM"/>
</SETTLEMENT_DATE>
<NO_LINES>
<xsl:value-of select="count(E1IDPU1)"/>
</NO_LINES>
</HEADER_DATA>
<ITEM_DATA>
<xsl:for-each select="E1IDPU1">
<DOCNAME>
<xsl:value-of select="DOCNAME"/>
</DOCNAME>
<DOCNUMMR>
<xsl:value-of select="DOCNUMMR"/>
</DOCNUMMR>
<PRICING_DATA>
<xsl:for-each select="E1IDPU5[MOAQUAL = '006']">
<MOABETR>
<xsl:value-of select="MOABETR"/>
</MOABETR>
</xsl:for-each>
</PRICING_DATA>
</xsl:for-each>
</ITEM_DATA>
<SUMMARY_DATA>
<xsl:for-each select="EDI_DS40">
<STATUS_MESSAGE>
<xsl:value-of select="STAPA1"/>
</STATUS_MESSAGE>
</xsl:for-each>
</SUMMARY_DATA>
</OUTPUT>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
Edited by: Thomas Zloch on Jun 9, 2010 6:05 PM -
Writing XSLT to perform transformation from XML to ABAP
Hi,
I've been struggling quite a bit with XSLT. I read several old discussions regarding transformations using ST and XSLT but I haven't been able to solve my problem.
I have a requirement to build a program to convert XML to an internal table.
I've been able to do it for smaller XMLs, but whenever I try to apply the same logic to a bigger XML it simply just doesn't work. I'm almost certain it has something to do with the way I wrote the XSLT but I haven't been able to figure out what.
The XML I have to read from goes something like this:
<?xml version="1.0" encoding="WINDOWS-1252"?>
-<AuditFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
-<Header xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
<AuditFileVersion>1.02_01</AuditFileVersion>
<CompanyID>50002</CompanyID>
<TaxRegistrationNumber>5000</TaxRegistrationNumber>
<TaxAccountingBasis>F</TaxAccountingBasis>
<CompanyName>Company</CompanyName>
<BusinessName>Business</BusinessName>
-<CompanyAddress>
<AddressDetail>Address</AddressDetail>
<City>city</City>
<PostalCode>333333</PostalCode>
<Country>PT</Country>
</CompanyAddress>
<FiscalYear>2013</FiscalYear>
<StartDate>2013-07-01</StartDate>
<EndDate>2013-07-31</EndDate>
<CurrencyCode>EUR</CurrencyCode>
<DateCreated>2013-08-02</DateCreated>
<TaxEntity>Global</TaxEntity>
<ProductCompanyTaxID>00</ProductCompanyTaxID>
<SoftwareCertificateNumber>00</SoftwareCertificateNumber>
<ProductID>product</ProductID>
<ProductVersion>00</ProductVersion>
<Email>email@com</Email>
<Website>www.s.pt</Website>
</Header>
-<MasterFiles xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.02_01">
-<Customer>
<CustomerID>1</CustomerID>
<AccountID>ID</AccountID>
<CustomerTaxID>999999990</CustomerTaxID>
<CompanyName>Desconhecido</CompanyName>
-<BillingAddress>
<AddressDetail>Desconhecido</AddressDetail>
<City>Desconhecido</City>
<PostalCode>0000-000</PostalCode>
<Country>PT</Country>
</BillingAddress>
<SelfBillingIndicator>0</SelfBillingIndicator>
</Customer>
-<Customer>
<CustomerID>2</CustomerID>
<AccountID>Desconhecido</AccountID>
<CustomerTaxID>571</CustomerTaxID>
<CompanyName>Company</CompanyName>
-<BillingAddress>
<AddressDetail>detail</AddressDetail>
<City>city</City>
<PostalCode>0000-000</PostalCode>
<Country>PT</Country>
</BillingAddress>
<SelfBillingIndicator>0</SelfBillingIndicator>
</Customer>
...and so on
And the XSLT I've written so far is something like this:
<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:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ICUSTOMER>
<xsl:apply-templates select="//Customer"/>
</ICUSTOMER>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="Customer">
<item>
<CUSTOMER_ID>
<xsl:value-of select="CustomerID"/>
</CUSTOMER_ID>
<ACCOUNT_ID>
<xsl:value-of select="AccountID"/>
</ACCOUNT_ID>
<CUSTOMERTAX_ID>
<xsl:value-of select="CustomerTaxID"/>
</CUSTOMERTAX_ID>
<COMPANYNAME>
<xsl:value-of select="CompanyName"/>
</COMPANYNAME>
<ADDRESSDETAIL>
<xsl:value-of select="BillingAddress/AddressDetail"/>
</ADDRESSDETAIL>
<CITY>
<xsl:value-of select="BillingAddress/City"/>
</CITY>
<POSTALCODE>
<xsl:value-of select="BillingAddress/PostalCode"/>
</POSTALCODE>
<COUNTRY>
<xsl:value-of select="BillingAddress/Country"/>
</COUNTRY>
<SELFBILLINGINDICATOR>
<xsl:value-of select="SelfBillingIndicator"/>
</SELFBILLINGINDICATOR>
</item>
</xsl:template>
</xsl:transform>
Like I said, I'm almost certain that the problem is with the XSLT, as it returns an empty table / ALV. I've used this method before and it worked...
Any thoughts?
Thank youHello Goncalo,
I think, there are two problems:
1) The xmlns declaration within your xml is a problem for the SAP XSLT Processor.
2) I have written a similar XSLT-report, which performs directly with your data. Perhaps this is not necessary if 1) is solved:
<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:template match="AuditFile">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<xsl:apply-templates select="MasterFiles"/>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="MasterFiles">
<ICUSTOMER>
<xsl:apply-templates select="./Customer"/>
</ICUSTOMER>
</xsl:template>
<xsl:template match="Customer">
<CUSTOMER_ID>
<xsl:value-of select="CustomerID"/>
</CUSTOMER_ID>
<ACCOUNT_ID>
<xsl:value-of select="AccountID"/>
</ACCOUNT_ID>
<CUSTOMERTAX_ID>
<xsl:value-of select="CustomerTaxID"/>
</CUSTOMERTAX_ID>
</xsl:template>
</xsl:transform>
Kind regards,
Hendrik -
How to use min-max functions for date in transformation in bpel?
Hi,
I have a requirement where i need to map earliest date of a Source field among all the dates to a target field in a transformation file in BPEL. There are functions called max-value-among-nodeset and min-value-among-nodeset in mathematical functions but they can be used only for numbers and strings.How to do these with dates?
Thanks,
PrasannaI exactly have the same requirement.Are you able to solve this?
Its very urgent.Please help me. -
XSLT Grouping & Sorting in 10g BPEL
Hi,
Can any one tell how we can achieve grouping and sorting of xslt in soa 10g.
This is possible in 11g but not getting any clue as how to proceed for 10g.
Please response soon.
Thanks & Regards,
Divyathis one works for me
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ns1="http://xmlns.oracle.com/SampleJDE_BioprodProcess">
<xsl:template match="/">
<ns1:SampleJDE_BioprodProcessProcessResponse>
<xsl:for-each select="/ns1:SampleJDE_BioprodProcessProcessResponse/ns1:billToNumber">
<xsl:sort select="."/>
<test>
<xsl:value-of select="."/>
</test>
</xsl:for-each>
</ns1:SampleJDE_BioprodProcessProcessResponse>
</xsl:template>
</xsl:stylesheet>output
<?xml version="1.0" encoding="UTF-8"?>
<ns1:SampleJDE_BioprodProcessProcessResponse xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ns1="http://xmlns.oracle.com/SampleJDE_BioprodProcess">
<test>1</test>
<test>2</test>
<test>9</test>
</ns1:SampleJDE_BioprodProcessProcessResponse> -
I need help writing and XSLT to transform an XML in InDesign. I am new to XML and have no idea how to write an XSLT.
We are trying to bring in data from a database using a query language that is having trouble creating the image tags the way we need it to. Basically, I need to take this:
<Project href="file://C:\My test phot.jpg">
and transform it into this:
<Project> <image href="file://C:\My test phot.jpg" />
Can anyone help me with this?
Thanks!Not sure I can help you with this, as my understanding of XSL is very limited.
However, as a matter of trial and error, I find that if I transform this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project href="file://C:\My test phot1.jpg">The first bit of textual content here</Project>
<Project href="file://C:\My test phot2.jpg">The second bit of textual content here</Project>
<Project href="file://C:\My test phot3.jpg">The third bit of textual content here</Project>
<Project href="file://C:\My test phot4.jpg">The fourth bit of textual content here</Project>
<Project href="file://C:\My test phot5.jpg">The fifth bit of textual content here</Project>
</Root>
...with this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Root>
<xsl:for-each select="/Root/Project">
<Project>
<image><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></image>
<xsl:value-of select="."/>
</Project>
</xsl:for-each>
</Root>
</xsl:template>
</xsl:stylesheet>
...I end up with this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project><image href="file://C:\My test phot1.jpg"/>The first bit of textual content here</Project>
<Project><image href="file://C:\My test phot2.jpg"/>The second bit of textual content here</Project>
<Project><image href="file://C:\My test phot3.jpg"/>The third bit of textual content here</Project>
<Project><image href="file://C:\My test phot4.jpg"/>The fourth bit of textual content here</Project>
<Project><image href="file://C:\My test phot5.jpg"/>The fifth bit of textual content here</Project>
</Root>
...which seems what you're looking for.
[I edited the original solution slightly by removing a wildcard.] -
Hi
Using <b>XSLT</b> and <b>Call transformation</b> (XSLT scheme) to convert XML file to html the problem is that line breaks in xml are ignored when passing the call tranformation.
<b>Note in xml look like:</b>
<com:Note><![CDATA[
Serie 87% 0,000000
Amount in this period 01-01-2006 - 01-07-2006 - 180 days
Currency 16.267.117,38 DKK
Loan DKK 14.332.700,00
Debt 7.358.534,23
Indexsfactor 226,230
]]></com:Note>
<b>When HTML displayed in sap, - note is just a long string which continue out of the screen. Note looks like:</b>Serie 87% 0,000000Amount in this period 01-01-2006 - 01-07-2006 - 180 daysCurrency 16.267.117,38 DKKDebt 7.358.534,23Indexsfactor 226,230
What to do ? Any ideas ?hi Jan,
Check out the link
http://www.topxml.com/code/default.asp?p=3&id=v20031025170911&ms=20&l=xsl&sw=categ
This link contains a file that contains an importable xslt stylesheet with two templates. The first is a text wrap template that breaks texts at carriage returns. You need to modify the xslt.
[code]<xsl:template name="text.wrap">
<xsl:param name="texttowrap"/>
<xsl:variable name="textlength" select="string-length($texttowrap)"/>
<!-- don't waste time if no text supplied or remaining from recursion-->
<xsl:if test="$textlength > 0">
<xsl:choose>
<xsl:when test="contains($texttowrap,$CR)">
<!-- get the text before the first instance of a carriage return character-->
<xsl:variable name="<span style="background-color:yellow;color:red;font-weight:bold;">line</span>beforefirst<span style="background-color:yellow;color:red;font-weight:bold;">break</span>" select="substring-before($texttowrap,$CR)"/>
.................[/code]
Hope this helps.
Regards,
Richa
Maybe you are looking for
-
How to connect my iPad 2 to Sony Bavaria wirless? Any other way than apple tv?
How to connect my iPad 2 to Sony Bavaria wirless? Any other way than apple tv?
-
Unable to create RAID on SPARC-Enterprise-T5220
hi: i got the following issue on my SPARC-Enterprise-T5220. i have constructed the RAID-1 on 4 disks out of 6. i have created RAID-1 on OS Disks using raidctl command on single user mode and i have created RADI-1 on other two disks. but i'm unable to
-
DYNAMIC PROGRAMMING IN WEBDYNPRO ABAP.
Hi Experts How to create input field dynamical and when i click on the input field drop down ui should display,If i click n time the input field that many drop down should be displayed this should be done using dynamic programming. Waiting for Reply
-
Manualy add music or photos?
Sorry if i'm asking a dumb question but I tried searching and I couldn't find my answer. When I use my regular ipod on Itunes I can manually choose which songs I want to add onto my Ipod. Can I do the same with my Iphone. I usually connect it at my j
-
In-different behaviour of join condition
My query is of in-different behaviour of join condition with join between a varchar2 column and a number column. I am using the following join condition :- CM.UPDATED_BY=to_char(LM.LOGIN_ID) where CM.UPDATED_BY is a varchar2 column and LM.LOGIN_ID is