cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping - output completely wrong

Former Member
0 Kudos

Hello experts,

I need to send an idoc to the receiver party, but they want the complete content in 1 field.

So I use a graphical message mapping to map the fields and an XSL mapping to put the idoc structure into a specific field in the output structure.

Also, in my operation mapping, both entries are indicated.

My target structure should look like this:

<?xml version="1.0" encoding="UTF-8" ?>

- <USM>

<USMTYPE>ZBEPA_SCX_07</USMTYPE>

<USMVERSION>ZBEPA_SCX_07</USMVERSION>

<RUNOPTION>LS</RUNOPTION>

- <MESSAGE>

- <METADATAS>

- <METADATA>

<KEY>KEY</KEY>

<VALUE>VALUE</VALUE>

</METADATA>

</METADATAS>

- <ADDRESSES>

- <ADDRESS>

<ADDRESSTYPE>1</ADDRESSTYPE>

<CHANNEL>2</CHANNEL>

<ADDRESS>3</ADDRESS>

</ADDRESS>

</ADDRESSES>

<SUBJECT>Onderwerp</SUBJECT>

<TIMESTAMP>20090813113600</TIMESTAMP>

<CONFIRMDELIVERY>True</CONFIRMDELIVERY>

- <MESSAGECONTENT>

<MESSAGETEXT>Tekst</MESSAGETEXT>

<MESSAGETEXTCONTENTTYPE>Inhoud</MESSAGETEXTCONTENTTYPE>

<MESSAGETEXTENCODING>Codering</MESSAGETEXTENCODING>

- <FILES>

- <FILE>

<FILETYPE>XML</FILETYPE>

<FILENAME>To Be Determined</FILENAME>

<FILECONTENTTYPE>Plain</FILECONTENTTYPE>

<FILECONTENTENCODING>NONE</FILECONTENTENCODING>

<FILEREF>NA</FILEREF>

<COMPRESSMETHOD>NONE</COMPRESSMETHOD>

</FILE>

</FILES>

</MESSAGECONTENT>

The MESSAGECONTENT field should content the idoc content with CDATA .... in front.

</MESSAGE>

</USM>

This is my XSL mapping:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:stylesheet version="1.0" xmlns:ns0="http://www.w3.org/1999/XSL/Transform">

<ns0:output method="xml" indent="yes" version="1.0"/>

<ns0:template match="/">

<USM>

<ns0:element name="FILECONTENT">

<ns0:text disable-output-escaping="yes">&lt;![CDATA[</ns0:text>

<ns0:copy-of select="ZBEXX_STR_SCX_1P9005"/>

<ns0:text disable-output-escaping="yes">]]</ns0:text>

<ns0:text disable-output-escaping="yes">&gt;</ns0:text>

</ns0:element>

</USM>

</ns0:template>

</ns0:stylesheet>

And this is my result XML:

<?xml version="1.0" encoding="UTF-8" ?>

- <USM>

- <FILECONTENT>

- <![CDATA[

]]>

</FILECONTENT>

</USM>

Please advice.

Thanks a lot!

Dimitri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Can you try adding the attribute "cdata-section-elements" to the xsl:output tag with the name of the node which would contain the complete message content.

For example:

<xsl:output method="xml" indent="yes" version="1.0" cdata-section-elements = "Nodename"/>

Thanks

Former Member
0 Kudos

And what about the graphical message mapping? Should the FIELDCONTENT field be mapped? Or just leave it not mapped?

Former Member
0 Kudos

With this XSL mapping:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8" cdata-section-elements = "FILE"/>

<xsl:template match="/">

<USM>

<MESSAGE>

<MESSAGECONTENT>

<FILES>

<FILE>

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<xsl:copy-of select="//ZBEXX_STR_SCX_1P9005"/>

<xsl:text disable-output-escaping="yes">]]</xsl:text>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

</xsl:template>

</xsl:stylesheet>

I get this result

<?xml version="1.0" encoding="UTF-8" ?>

- <USM>

- <MESSAGE>

- <MESSAGECONTENT>

- <FILES>

- <FILE>

- <![CDATA[ <![CDATA[]]

]]>

- <![CDATA[ >

]]>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

The structure is ok I think, but where are my fields of the graphical mapping?

And still nothing in CDATA.

Thanks

Dimitri

former_member200962
Active Contributor
0 Kudos
ZBEXX_STR_SCX_1P9005

The above node...is it the one from the Original Source message OR from the output of the Message Mapping?

Also try giving the entire path instead of prefixing //

Regards,

Abhishek.

Former Member
0 Kudos

Hi,

It's from my source structure in the message mapping. So, input structure element.

Kind regards,

Dimitri

Edited by: Dimitri Sannen on Aug 31, 2009 9:41 AM

Also, I tried to enter the full path of the element, but the result is the same.

former_member187339
Active Contributor
0 Kudos

Hi Dimitri,

Try this

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<XYZ xmlns="http://xyz.com/xi/POC//">

<ABC>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]></xsl:text>

<xsl:copy-of select="*"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</ABC>

</XYZ>

</xsl:template>

</xsl:stylesheet>

Change ABC, XYz and namespce according to your requirement.

Regards

Suraj

Edited by: S.R.Suraj on Aug 31, 2009 3:50 AM

Former Member
0 Kudos

I changed this: <xsl:copy-of select="*"/>

And this is my new output. As you can see, the complete structure is taken.

I need to play around with the "*" to only get the segment I need.

<?xml version="1.0" encoding="UTF-8" ?>

- <USM>

- <MESSAGE>

- <MESSAGECONTENT>

- <FILES>

- <FILE>

- <![CDATA[

<USM>

<USMTYPE>ZBEPA_SCX_07</USMTYPE>

<USMVERSION>ZBEPA_SCX_07</USMVERSION>

<RUNOPTION>LS</RUNOPTION>

<MESSAGE>

<METADATAS>

<METADATA>

<KEY>KEY</KEY>

<VALUE>VALUE</VALUE>

</METADATA>

</METADATAS>

<ADDRESSES>

<ADDRESS>

<ADDRESSTYPE>1</ADDRESSTYPE>

<CHANNEL>2</CHANNEL>

<ADDRESS>3</ADDRESS>

</ADDRESS>

</ADDRESSES>

<SUBJECT>Onderwerp</SUBJECT>

<TIMESTAMP>20090813113600</TIMESTAMP>

<CONFIRMDELIVERY>True</CONFIRMDELIVERY>

<MESSAGECONTENT>

<MESSAGETEXT>Tekst</MESSAGETEXT>

<MESSAGETEXTCONTENTTYPE>Inhoud</MESSAGETEXTCONTENTTYPE>

<MESSAGETEXTENCODING>Codering</MESSAGETEXTENCODING>

<FILES>

<FILE>

<FILETYPE>XML</FILETYPE>

<FILENAME>To Be Determined</FILENAME>

<FILECONTENTTYPE>Plain</FILECONTENTTYPE>

<FILECONTENTENCODING>NONE</FILECONTENTENCODING>

<FILEREF>NA</FILEREF>

<COMPRESSMETHOD>NONE</COMPRESSMETHOD>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

]]>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

But I still need all the other fields of my structure filled by the graphical message mapping

Edited by: Dimitri Sannen on Aug 31, 2009 11:02 AM

I see that the structure from the target message it taken in the result above.

But I need the source message structure in it.

former_member187339
Active Contributor
0 Kudos

Hi Dimitry,

Try using this: <?xml version="1.0" encoding="UTF-8" ?>

- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

- <xsl:template match="/">

- <XYZ xmlns="http://xyz.com/xi/POC/">

- <USM>

- <USMTYPE>

<xsl:value-of select="USMTYPE" disable-output-escaping="yes" />

</USMTYPE>

- <USMVERSION>

<xsl:value-of select="USMVERSION" disable-output-escaping="yes" />

</USMVERSION>

- <RUNOPTION>

<xsl:value-of select="RUNOPTION" disable-output-escaping="yes" />

</RUNOPTION>

- <MESSAGE>

- <METADATAS>

- <METADATA>

- <KEY>

<xsl:value-of select="MESSAGE/METADATAS/METADATA/KEY" disable-output-escaping="yes" />

</KEY>

- <VALUE>

<xsl:value-of select="MESSAGE/METADATAS/METADATA/VALUE" disable-output-escaping="yes" />

</VALUE>

</METADATA>

</METADATAS>

- <ADDRESSES>

- <ADDRESS>

- <ADDRESSTYPE>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/ADDRESTYPE" disable-output-escaping="yes" />

</ADDRESSTYPE>

- <CHANNEL>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/CHANNEL" disable-output-escaping="yes" />

</CHANNEL>

- <ADDRESS>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/ADDRESS" disable-output-escaping="yes" />

</ADDRESS>

</ADDRESS>

</ADDRESSES>

- <SUBJECT>

<xsl:value-of select="MESSAGE/SUBJECT" disable-output-escaping="yes" />

</SUBJECT>

- <TIMESTAMP>

<xsl:value-of select="MESSAGE/TIMESTAMP" disable-output-escaping="yes" />

</TIMESTAMP>

- <CONFIRMDELIVERY>

<xsl:value-of select="MESSAGE/CONFIRMDELIVERY" disable-output-escaping="yes" />

</CONFIRMDELIVERY>

- <MESSAGECONTENT>

- <MESSAGETEXT>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGETEXT" disable-output-escaping="yes" />

</MESSAGETEXT>

- <MESSAGETEXTCONTENTTYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGECONTENTTYPE" disable-output-escaping="yes" />

</MESSAGETEXTCONTENTTYPE>

- <MESSAGETEXTENCODING>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGETEXTENCODING" disable-output-escaping="yes" />

</MESSAGETEXTENCODING>

- <FILES>

- <FILE>

- <FILETYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILETYPE" disable-output-escaping="yes" />

</FILETYPE>

- <FILENAME>

T

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILENAME" disable-output-escaping="yes" />

</FILENAME>

- <FILECONTENTTYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILECONTENTTYPE" disable-output-escaping="yes" />

</FILECONTENTTYPE>

- <FILECONTENTENCODING>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILECONTENTENCODING" disable-output-escaping="yes" />

</FILECONTENTENCODING>

- <FILEREF>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILEREF" disable-output-escaping="yes" />

</FILEREF>

- <COMPRESSMETHOD>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/COMPRESSMETHOD" disable-output-escaping="yes" />

</COMPRESSMETHOD>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

<ABC> <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA http://<?xml version=\"1.0\" encoding=\"UTF-8\"?>]></xsl:text>

<xsl:copy-of select="*"/>

<xsl:text disable-output-escaping="yes"><!CDATA[]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA>]></xsl:text>

</ABC>

</USM>

</XYZ>

</xsl:template>

</xsl:stylesheet>

Please note some mimor corrections might be required from your end

Regards

Suraj

Edited by: S.R.Suraj on Aug 31, 2009 5:46 AM

Former Member
0 Kudos

THis is my output when I tried it:

<?xml version="1.0" encoding="UTF-8" ?>

- <USM xmlns="http://www.ordina.be/StructureToFieldTest">

<USMTYPE />

<USMVERSION />

<RUNOPTION />

- <MESSAGE>

- <METADATAS>

- <METADATA>

<KEY />

<VALUE />

</METADATA>

</METADATAS>

- <ADDRESSES>

- <ADDRESS>

<ADDRESSTYPE />

<CHANNEL />

<ADDRESS />

</ADDRESS>

</ADDRESSES>

<SUBJECT />

<TIMESTAMP />

<CONFIRMDELIVERY />

- <MESSAGECONTENT>

<MESSAGETEXT />

<MESSAGETEXTCONTENTTYPE />

<MESSAGETEXTENCODING />

- <FILES>

- <FILE>

<FILETYPE />

<FILENAME>T</FILENAME>

<FILECONTENTTYPE />

<FILECONTENTENCODING />

<FILEREF />

<COMPRESSMETHOD />

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

Nothing seems to be mapped

Former Member
0 Kudos

When I added this

<FILECONTENT>

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<xsl:copy-of select="*"/>

<xsl:text disable-output-escaping="yes">]]</xsl:text>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

</FILECONTENT>

The target structure is mapping to te FILECONTENT field.

But I need the source structure with data.

former_member200962
Active Contributor
0 Kudos
The target structure is mapping to te FILECONTENT field.
But I need the source structure with data.

Target structure of what is mapped?.....is it of the Message Mapping? If yes then this is how the sequence should work....even you would have included the target structure in your XSLT mapping....check what is the target structure of your Messsage Maping and what is the source structure of your XSLT mapping.

If you want to have the Original Source structure (the source interface which you mentione in your Interface Mapping) in your XSLT output then you need to have only the XSLT mapping...

Regards,

Abhishek.

former_member187339
Active Contributor
0 Kudos

Hi,

I am unable to paste the entire XSL code here...

try to do something liek this for your each element

.. .. ..

<USMTYPE>

<xsl:value-of select="USMTYPE" disable-output-escaping="yes"/>

</USMTYPE>

<USMVERSION>

<xsl:value-of select="USMVERSION" disable-output-escaping="yes"/>

</USMVERSION>

<RUNOPTION>

<xsl:value-of select="RUNOPTION" disable-output-escaping="yes"/>

</RUNOPTION>

.. .. ..

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

I did that, but still...

I thought I map the fields with a graphical mapping and for the special field, I use an XSL mapping. But is that not possible?

Only having an XSL mapping is not the objective

former_member187339
Active Contributor
0 Kudos

Hi Dimitri,

You should go for XSL mapping alone. Both Graphical mapping and XSL mapping is not advisable. A workaround I can suggest is like this:

1. First mapping : IDoc to target Structur (with the filed containing entire XML blank): Thsi can be graphical mapping

2. Second Mapping: Source and traget structure shoudl be same (the USM one). Here use XSLT mapping. Here we need to map a 1:1 mapping for all fields and a copy-of select=* logic for the field which will contain the entire XML value.

The first mapping is simple to create and you can use graphical mapping for the same. So the output of first mapping will lokk like :

<USM>

<USMTYPE>

abc

</USMTYPE>

<USMVERSION>

123

</USMVERSION>

<RUNOPTION>

456

</RUNOPTION>

.. ..

.. ..

This willbe input for the second XSL mapping. there give the mapping for each node as

<USM>

<USMTYPE>

<xsl:value-of select="USMTYPE" disable-output-escaping="yes"/>

</USMTYPE>

<USMVERSION>

<xsl:value-of select="USMVERSION" disable-output-escaping="yes"/>

</USMVERSION>

<RUNOPTION>

<xsl:value-of select="RUNOPTION" disable-output-escaping="yes"/>

</RUNOPTION>

.. .. ..

take care of the path if the root node is some MT_ROOT then the path will also change to MT_ROOT/USMTYPE and so on.

finally map the entire source XML to target field using the before discussed logic.

Hope now the problme/confusion is solved

Regards

Suraj

Former Member
0 Kudos

Aha... Let's go for XSL ... (I deleted the graphical message mapping step from the operation mapping step)

This is my XSL mapping

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8" cdata-section-elements="FILECONTENT"/>

<xsl:template match="/">

<USM xmlns="http://www.ordina.be/StructureToFieldTest">

<USMTYPE>

<xsl:value-of select="USMTYPE" disable-output-escaping="yes"/>

</USMTYPE>

<USMVERSION>

<xsl:value-of select="USMVERSION" disable-output-escaping="yes"/>

</USMVERSION>

<RUNOPTION>

<xsl:value-of select="RUNOPTION" disable-output-escaping="yes"/>

</RUNOPTION>

<MESSAGE>

<METADATAS>

<METADATA>

<KEY>

<xsl:value-of select="MESSAGE/METADATAS/METADATA/KEY" disable-output-escaping="yes"/>

</KEY>

<VALUE>

<xsl:value-of select="MESSAGE/METADATAS/METADATA/VALUE" disable-output-escaping="yes"/>

</VALUE>

</METADATA>

</METADATAS>

<ADDRESSES>

<ADDRESS>

<ADDRESSTYPE>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/ADDRESTYPE" disable-output-escaping="yes"/>

</ADDRESSTYPE>

<CHANNEL>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/CHANNEL" disable-output-escaping="yes"/>

</CHANNEL>

<ADDRESS>

<xsl:value-of select="MESSAGE/ADDRESSES/ADDRESS/ADDRESS" disable-output-escaping="yes"/>

</ADDRESS>

</ADDRESS>

</ADDRESSES>

<SUBJECT>

<xsl:value-of select="MESSAGE/SUBJECT" disable-output-escaping="yes"/>

</SUBJECT>

<TIMESTAMP>

<xsl:value-of select="MESSAGE/TIMESTAMP" disable-output-escaping="yes"/>

</TIMESTAMP>

<CONFIRMDELIVERY>

<xsl:value-of select="MESSAGE/CONFIRMDELIVERY" disable-output-escaping="yes"/>

</CONFIRMDELIVERY>

<MESSAGECONTENT>

<MESSAGETEXT>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGETEXT" disable-output-escaping="yes"/>

</MESSAGETEXT>

<MESSAGETEXTCONTENTTYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGECONTENTTYPE" disable-output-escaping="yes"/>

</MESSAGETEXTCONTENTTYPE>

<MESSAGETEXTENCODING>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/MESSAGETEXTENCODING" disable-output-escaping="yes"/>

</MESSAGETEXTENCODING>

<FILES>

<FILE>

<FILETYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILETYPE" disable-output-escaping="yes"/>

</FILETYPE>

<FILENAME>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILENAME" disable-output-escaping="yes"/>

</FILENAME>

<FILECONTENTTYPE>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILECONTENTTYPE" disable-output-escaping="yes"/>

</FILECONTENTTYPE>

<FILECONTENTENCODING>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILECONTENTENCODING" disable-output-escaping="yes"/>

</FILECONTENTENCODING>

<FILEREF>

<xsl:value-of select="MESSAGE/MESSAGECONTENT/FILES/FILE/FILEREF" disable-output-escaping="yes"/>

</FILEREF>

<COMPRESSMETHOD>

<xsl:value-of select="COMPRESSMETHOD" disable-output-escaping="yes"/>

</COMPRESSMETHOD>

<FILECONTENT>

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<xsl:copy-of select="*"/>

<xsl:text disable-output-escaping="yes">]]</xsl:text>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

</FILECONTENT>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

</xsl:template>

</xsl:stylesheet>

This is the result: as you can see, nothing is mapped. and the target structure is in and not the source structure

<?xml version="1.0" encoding="UTF-8" ?>

- <USM xmlns="http://www.ordina.be/StructureToFieldTest">

<USMTYPE />

<USMVERSION />

<RUNOPTION />

- <MESSAGE>

- <METADATAS>

- <METADATA>

<KEY />

<VALUE />

</METADATA>

</METADATAS>

- <ADDRESSES>

- <ADDRESS>

<ADDRESSTYPE />

<CHANNEL />

<ADDRESS />

</ADDRESS>

</ADDRESSES>

<SUBJECT />

<TIMESTAMP />

<CONFIRMDELIVERY />

- <MESSAGECONTENT>

<MESSAGETEXT />

<MESSAGETEXTCONTENTTYPE />

<MESSAGETEXTENCODING />

- <FILES>

- <FILE>

<FILETYPE />

<FILENAME />

<FILECONTENTTYPE />

<FILECONTENTENCODING />

<FILEREF />

<COMPRESSMETHOD />

- <FILECONTENT>

- <![CDATA[

<ZBEPA_SCX_07>

<IDOC BEGIN="1">

<EDI_DC40 SEGMENT="1">

<TABNAM>EDI_DC40</TABNAM>

<MANDT>312</MANDT>

<DOCNUM>0000000000008155</DOCNUM>

<DOCREL>701</DOCREL>

<STATUS>30</STATUS>

<DIRECT>1</DIRECT>

<OUTMOD>2</OUTMOD>

<IDOCTYP>ZBEPA_SCX_07</IDOCTYP>

<MESTYP>ZBEPA_SCX_07</MESTYP>

<STDMES>ZBEPA_</STDMES>

<SNDPOR>SAPSED</SNDPOR>

<SNDPRT>LS</SNDPRT>

<SNDPRN>SEDCLNT312</SNDPRN>

<RCVPOR>SAPSXD001</RCVPOR>

<RCVPRT>LS</RCVPRT>

<RCVPRN>SXDCLNT001</RCVPRN>

<CREDAT>20090831</CREDAT>

<CRETIM>125942</CRETIM>

<SERIAL>20090813113600</SERIAL>

</EDI_DC40>

<ZBEXX_STR_SCX_1P9005 SEGMENT="1">

<FIRMA>NGA</FIRMA>

<DEPARTMENT>01</DEPARTMENT>

<CATEGORY>X</CATEGORY>

<PERSON>IKKE</PERSON>

<BEGDA>30072009</BEGDA>

<NEXT_INCREASE_DATE>31072009</NEXT_INCREASE_DATE>

</ZBEXX_STR_SCX_1P9005>

</IDOC>

</ZBEPA_SCX_07>

]]>

</FILECONTENT>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

former_member187339
Active Contributor
0 Kudos

Hi Dimitri,

I suggest to go for Graphical mapping and then teh XSL mapping. Coz it will be easier for you to convert IDoc to desired output structur in graphical mapping. Just keep the field which shoudl have the entire output as blank.

Now in second XSL mapping do as i mentioned in above post. you need to map each field of source (target generated by graphical mappin) in the XSL code. If you are new to XSL try googling and you will get a lot of information.

Your requirement of getting entire target into a single field is donefinished. Now you need to map individual fields.

A part of code is

<USM>

<USMTYPE>

<xsl:value-of select="USM/USMTYPE" disable-output-escaping="yes"/>

</USMTYPE>

<USMVERSION>

<xsl:value-of select="USM/USMVERSION" disable-output-escaping="yes"/>

</USMVERSION>

<RUNOPTION>

<xsl:value-of select="USM/RUNOPTION" disable-output-escaping="yes"/>

</RUNOPTION>

here usmtype, usmversion ad runoption is getting created...

Also post the target DT structure so that we can see whether the paths USM/UMTYPE etc are correct or not.

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

I did it with an XSL mapping only. This works fine now!

But is this case, the XSL mapping is really long and I only took a really small idoc.

For our big idocs, this will be a problem and that's why we need a combination of graphical and XSL mapping.

Please tell me why this combination is not advisable.

Also, is the combination of an XSL and an ABAP mapping advisable?

Thanks a lot

Dimitri

former_member187339
Active Contributor
0 Kudos

Hi Dimitri,

We generally prefer to use single mapping so as reduce the maintenance overhead.

But there are cases (like this one) where we need to use more than one mapping. So there is no harm in using more than one (else do you think SAP would have provided this option!:))

Regards

Suraj

Former Member
0 Kudos

This is my XSL mapping now.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" version="1.0" encoding="UTF-8"/>

<xsl:template match="/">

<USM>

<USMTYPE>

<xsl:value-of select="ZBEPA_SCX_07/IDOC/EDI_DC40/IDOCTYP" disable-output-escaping="yes"/>

</USMTYPE>

<USMVERSION>

<xsl:value-of select="ZBEPA_SCX_07/IDOC/EDI_DC40/MESTYP" disable-output-escaping="yes"/>

</USMVERSION>

<RUNOPTION>

<xsl:value-of select="ZBEPA_SCX_07/IDOC/EDI_DC40/SNDPRT" disable-output-escaping="yes"/>

</RUNOPTION>

<MESSAGE>

<METADATAS>

<METADATA>

<KEY>

KEY

</KEY>

<VALUE>

VALUE

</VALUE>

</METADATA>

</METADATAS>

<ADDRESSES>

<ADDRESS>

<ADDRESSTYPE>

1

</ADDRESSTYPE>

<CHANNEL>

2

</CHANNEL>

<ADDRESS>

3

</ADDRESS>

</ADDRESS>

</ADDRESSES>

<SUBJECT>

Onderwerp

</SUBJECT>

<TIMESTAMP>

<xsl:value-of select="ZBEPA_SCX_07/IDOC/EDI_DC40/SERIAL" disable-output-escaping="yes"/>

</TIMESTAMP>

<CONFIRMDELIVERY>

<xsl:value-of select="True" disable-output-escaping="yes"/>

</CONFIRMDELIVERY>

<MESSAGECONTENT>

<MESSAGETEXT>

Tekst

</MESSAGETEXT>

<MESSAGETEXTCONTENTTYPE>

Inhoud

</MESSAGETEXTCONTENTTYPE>

<MESSAGETEXTENCODING>

Codering

</MESSAGETEXTENCODING>

<FILES>

<FILE>

<FILETYPE>

Dimona

</FILETYPE>

<FILENAME>

XML

</FILENAME>

<FILECONTENTTYPE>

To be defined

</FILECONTENTTYPE>

<FILECONTENTENCODING>

Codering

</FILECONTENTENCODING>

<FILEREF>

NGA

</FILEREF>

<COMPRESSMETHOD>

NONE

</COMPRESSMETHOD>

<FILECONTENT>

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>

<xsl:copy-of select="ZBEPA_SCX_07/IDOC/ZBEXX_STR_SCX_1P9005"/>

<xsl:text disable-output-escaping="yes">]]</xsl:text>

<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

</FILECONTENT>

</FILE>

</FILES>

</MESSAGECONTENT>

</MESSAGE>

</USM>

</xsl:template>

</xsl:stylesheet>

What needs to be changed in order to work together with a graphical message mapping?

The things you mentioned are already in.

Thanks a lot!

Dimitri

former_member187339
Active Contributor
0 Kudos

Hi,

Here you have used only one mapping

Approach 1 : IDoc - XSL Mapping - Target

another approach was to

Approach 2 : IDoc - Graphical Mapping - Intermediate Traget - XSL Mapping - Traget

(Infact I earlier thgth you were using this approach)

If you are ok with the Approach 1, then no need of graphical mapping.

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

Indeed, I was using the second appoach wiht both mappings, but that did not work.

Now, with only the XSL it does work.

But I want to use a graphical mapping befiore the XSL to covert 99% of the mapping.

The mapping of the last field should be done by the XSL mapping.

That's why I wonder how my XSL mapping will looks like when I use it in combination with a Graphical MM.

Kind regards

Dimitri

former_member187339
Active Contributor
0 Kudos

Hi,

If you want the entire Idoc strucutre to be put into one field of target structure using graphical mapping and then XSLT, then this is not possible as the second mapping (XSLT) has XML Message as input and not the IDoc.

If you want the Output structure (with tags USM etc.) to be put into one of its field then you can use Graphical mapping (to convert Idoc to XML structure) and then use XSLT (for putting Target XML to a field).

So in your case you need to go for single XSL mapping.

Regards

Suraj

Former Member
0 Kudos

Hi,

We will try to use an ABAP mapping in combination with an XSL mapping.

Or try to use 2 ABAP mappings after eachother in the Operation mapping.

Is that possible?

Thanks

Dimitri

former_member187339
Active Contributor
0 Kudos

Hi Dimitry,

>>We will try to use an ABAP mapping in combination with an XSL mapping.

The ABAP mapping you will be using to map individual fields and the XSL mapping is then used for putting the entire source (IDOC) to one field of target. correct? Here also you will face the same problem, when the ABAP mapping is executed. the output ofABAP mapping will act as an input for the XSL mapping and hence the IDoc stucture is unavailable to XSL mapping

>>Or try to use 2 ABAP mappings after eachother in the Operation mapping.

Same problem as mentioned above.

So try to do everything (ndividual field mapping and mapping entire IDoc to a target field) in one single mapping, either ABAP, or XSL or JAVA.

Regards

Suraj

Answers (2)

Answers (2)

Former Member
0 Kudos

Dimitri,

Find below xsl code with "CDATA"...

<?xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">

<cnclErpDocument>

<body>

<payload>

<xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>

<xsl:value-of select="//payload"/>

<xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>

</payload>

</body>

</cnclErpDocument>

</xsl:template>

</xsl:stylesheet>

Where //payload" is payload from previous mapping...

Hope this will help.

Let me know if you need more details.

Thanks,

Nilesh

former_member188019
Active Participant
0 Kudos

you got the output as you instructed in your xsl instructions.

<ns0:template match="/">

when the xsl engine reads the root node,

<USM>

it is emmiting <USM>

<ns0:element name="FILECONTENT">

then it is creating and emitting <FILECONTENT> node.

so, if u need different output xml, you need to correct the xsl transformation instructions i.e. xsl code.

Former Member
0 Kudos

Can you clarify?

Indeed I need to correct my XSL mapping, but that's exactly the question I have.

I do not know how.

thanks

former_member188019
Active Participant
0 Kudos

Hi,

the xsl you provided, expected target xml you provided.

I am pretty much familiar with xsl, but it will be really difficult to assist you unless you provide source xml.

PS:

you can debug/test to check if your xsl is correct or not, using tools like xmlspy.

the one forum that works with xsl related discussions is : http://www.mulberrytech.com/xsl/xsl-list you can use this if u come across complex stuff with xsl transformation

Former Member
0 Kudos

Hello,

This is my input XML (I got it from the XI monitor. In fact, it's an idoc send from the SAP ECC backend system):

<?xml version="1.0" encoding="UTF-8" ?>

- <ZBEPA_SCX_07>

- <IDOC BEGIN="1">

- <EDI_DC40 SEGMENT="1">

<TABNAM>EDI_DC40</TABNAM>

<MANDT>312</MANDT>

<DOCNUM>0000000000007011</DOCNUM>

<DOCREL>701</DOCREL>

<STATUS>30</STATUS>

<DIRECT>1</DIRECT>

<OUTMOD>2</OUTMOD>

<IDOCTYP>ZBEPA_SCX_07</IDOCTYP>

<MESTYP>ZBEPA_SCX_07</MESTYP>

<STDMES>ZBEPA_</STDMES>

<SNDPOR>SAPSED</SNDPOR>

<SNDPRT>LS</SNDPRT>

<SNDPRN>SEDCLNT312</SNDPRN>

<RCVPOR>SAPSXD001</RCVPOR>

<RCVPRT>LS</RCVPRT>

<RCVPRN>SXDCLNT001</RCVPRN>

<CREDAT>20090827</CREDAT>

<CRETIM>090645</CRETIM>

<SERIAL>20090813113600</SERIAL>

</EDI_DC40>

- <ZBEXX_STR_SCX_1P9005 SEGMENT="1">

<FIRMA>NGA</FIRMA>

<DEPARTMENT>01</DEPARTMENT>

<CATEGORY>X</CATEGORY>

<PERSON>IKKE</PERSON>

<BEGDA>30072009</BEGDA>

<NEXT_INCREASE_DATE>31072009</NEXT_INCREASE_DATE>

</ZBEXX_STR_SCX_1P9005>

</IDOC>

</ZBEPA_SCX_07>

The output structure should look like this (I took it from the message mapping)

<?xml version="1.0" encoding="UTF-8" ?>

- <USM>

<USMTYPE>ZBEPA_SCX_07</USMTYPE>

<USMVERSION>ZBEPA_SCX_07</USMVERSION>

<RUNOPTION>LS</RUNOPTION>

- <MESSAGE>

- <METADATAS>

- <METADATA>

<KEY>KEY</KEY>

<VALUE>VALUE</VALUE>

</METADATA>

</METADATAS>

- <ADDRESSES>

- <ADDRESS>

<ADDRESSTYPE>1</ADDRESSTYPE>

<CHANNEL>2</CHANNEL>

<ADDRESS>3</ADDRESS>

</ADDRESS>

</ADDRESSES>

<SUBJECT>Onderwerp</SUBJECT>

<TIMESTAMP>20090813113600</TIMESTAMP>

<CONFIRMDELIVERY>True</CONFIRMDELIVERY>

- <MESSAGECONTENT>

<MESSAGETEXT>Tekst</MESSAGETEXT>

<MESSAGETEXTCONTENTTYPE>Inhoud</MESSAGETEXTCONTENTTYPE>

<MESSAGETEXTENCODING>Codering</MESSAGETEXTENCODING>

- <FILES>

- <FILE>

<FILETYPE>XML</FILETYPE>

<FILENAME>To Be Determined</FILENAME>

<FILECONTENTTYPE>Plain</FILECONTENTTYPE>

<FILECONTENTENCODING>NONE</FILECONTENTENCODING>

<FILEREF>NA</FILEREF>

<COMPRESSMETHOD>NONE</COMPRESSMETHOD>

</FILE>

</FILES>

</MESSAGECONTENT> In this field, the complete ZBEXX_STR_SCX_1P9005 structure must be in

</MESSAGE>

</USM>

Thanks a lot!

Kind regards

Dimitri

former_member200962
Active Contributor
0 Kudos

In the XSLT mapping that you have defined you have referenced every element wth ns0 (even the XSLT functions).....this is wrong usage....use the prefix (ns0/ ns1) as they appear in the very first line of your XSLT code.

Nilesh has provided you with the code...try with that.....ns0/ ns1 to be used only for fields/ nodes of the source & target structure....XSLT functions to be prefixed with xsl.

Regards,

Abhishek.

Former Member
0 Kudos

What do you mean with prefix ns0/ ns1 ?

Shouldn't it be 1 of the 2?

Also, with the code of Nilesh, I'm not able to fix it.

I do not know XSL at all.

Thanks a lot

Dimitri

former_member200962
Active Contributor
0 Kudos
What do you mean with prefix ns0/ ns1 ?
Shouldn't it be 1 of the 2?

Normally it is ns0 for source structure and ns1 for target structure. When creating the XSLT you associate the namespace prefixes to the respective source & target namespaces and then in the rest of the mapping use these prefixes for the source and target. I use Stylus Studio and by default these prefixes are a and b instead of ns0 or ns1....os you need to change it accordingly.

Also, with the code of Nilesh, I'm not able to fix it.
I do not know XSL at all.

Can you provide the XSLT that you are using....the recent one.

Please note that you are having two different mappings (Message & XSLT) in sequence....so your XSLT mapping should refer the structure that is coming out of the Message Mapping and not the original source message.

Regards,

Abhishek.

Former Member
0 Kudos

Please look at the top of this post. There's my XSLT mapping.

Former Member
0 Kudos

I think in this case your code should look like below..

xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">

<cnclErpDocument>

<body>

<payload> *** Replace bold nodes with your payload nodes...

<xsl:text disable-output-escaping="yes"><![CDATA[<!CDATA[]></xsl:text>

<xsl:value-of select="//ZBEXX_STR_SCX_1P9005"/>

<xsl:text disable-output-escaping="yes"><!CDATA[]]]></xsl:text>

<xsl:text disable-output-escaping="yes"><![CDATA>]></xsl:text>

</payload>

</body>

</cnclErpDocument>

</xsl:template>

</xsl:stylesheet>

Former Member
0 Kudos

I got an error when using this XSL mapping

<xml version='1.0' ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">

<cnclErpDocument>

<USM>

<FILECONTENT>

<xsl:text disable-output-escaping="yes"><![CDATA<!CDATA[></xsl:text>

<xsl:value-of select="//ZBEXX_STR_SCX_1P9005"/>

<xsl:text disable-output-escaping="yes"><!CDATA]]></xsl:text>

<xsl:text disable-output-escaping="yes"><!CDATA>></xsl:text>

</FILECONTENT>

</USM>

</cnclErpDocument>

</xsl:template>

</xsl:stylesheet>

Error:

TransformerConfigurationException triggered while loading XSLT mapping StructureToField.xsl; http://www.ordina.be/StructureToFieldTest848190f0-4544-11de-bfec-d626ac13014e-1