cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping ?

Former Member
0 Kudos

Hi Guys,

I need to do a HTTP post and the xml has multipart. I thought of using the soap adapter with the followign options as true

1. Do not use soap envelope

2. keep attachments

I want to know which part of the payload i need to message mapping and which part i need to append with the xslt mapping.

any help with the xslt mapping or any other ideas of the acheiving this would be really appreciated.

The xml which i need to post is as below

<AccessRequest xml:lang='en-US'>

<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>

<UserId>YOURUSERID</UserId>

<Password>YOURPASSWORD</Password></AccessRequest>

<?xml version="1.0" ?>

<AddressValidationRequest xml:lang='en-US'>

<Request>

<TransactionReference>

<CustomerContext /><XpciVersion>1.0001</XpciVersion>

</TransactionReference>

<RequestAction>XAV</RequestAction>

<RequestOption>3</RequestOption>

</Request>

<MaximumListSize>3</MaximumListSize>

<AddressKeyFormat>

<ConsigneeName>UPS Capital</ConsigneeName>

<BuildingName>Business Credit</BuildingName>

<AddressLine>425 Day Hill Road</AddressLine>

<AddressLine>P.O. Box 400</AddressLine>

<AddressLine>Main Office</AddressLine>

<PoliticalDivision2>Windsor</PoliticalDivision2>

<PoliticalDivision1>CT</PoliticalDivision1>

<PostcodePrimaryLow>06095</PostcodePrimaryLow>

<CountryCode>US</CountryCode>

</AddressKeyFormat>

</AddressValidationRequest

Thanks,

Srini

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

I am not 100% sure if you need to send a content-type multipart or if you only mean two root-segments with "multipart". Anyway the solution is similar. I assume the second variant because easier.

1. map your AddressValidationRequest in the normal graphical mapping (this means you create message type and interface for this structure)

2. write an XSLT which takes this AdressValidationRequest as input structure

in this XSLT, you also add some text constants (your AccessRequest structure at the top of the document).

3. you define an interface mapping which first executes the graphical and then the XSLT mapping. For the IM, you define Target interface = AdressValidationRequest interface, although the result will not be of that type at runtime. This is the trick. XI does not validate the result. That means you can create anything as output. But you have to define a target interface for the IM. Because your output is not wellformed XML, you cannot define this structure in XI, or map it in graphical mapping. A bit sick.

4. create normal communication channel HTTP receiver, easier than using SOAP. Your content-type is text/xml ?

About the XSLT. Try the following (not tested this variant, but used similar in other project). Note that these local-name calls are needed because XI creates the ns0-Namespace garbgage, which normally cannot be read by the receiver.

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- important to set the output method to html, otherwise transformer would escape, we dont want that.

Because the result will be sent to an HTTP server as HTTP body -->

<xsl:output method="html" encoding="ISO-8859-1"/>

<xsl:template match="*">

<!-- remove element prefix (if any) -->

<xsl:element name="{local-name()}">

<!-- process attributes -->

<xsl:for-each select="@*">

<!-- remove attribute prefix (if any) -->

<xsl:attribute name="{local-name()}">

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

</xsl:attribute>

</xsl:for-each>

<xsl:apply-templates/>

</xsl:element>

</xsl:template>

<!-- root template -->

<!-- add multipart header -->

<xsl:template match="/">

<xsl:text>

<AccessRequest xml:lang='en-US'>

<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>

<UserId>YOURUSERID</UserId>*<Password>YOURPASSWORD</Password>*</AccessRequest>

</xsl:text>

<!-- copy the complete payload -->

<xsl:apply-templates/>

<!-- add multipart footer -->

<xsl:text>

<!-- not applicable for you -->

</xsl:text>

</xsl:template>

</xsl:stylesheet>

CSY

Former Member
0 Kudos

Hi Christian,

Thanks for the quick reply and detailed explanation, i appreciate your help. I will follow these and i will update the thread with the results.

Thanks,

Srini

Former Member
0 Kudos

Hi Christian,

Do you think with this the message will be sent with the two xml tag versions like below. I need to have these 2 xml tags in the message when i send the request.

can you please let me know if this is possible or *do i need to write anything in the xslt mapping to add the second xml declaration tag like <?xml version="1.0" ?>*

<?xml version="1.0" ?>

<AccessRequest xml:lang='en-US'>

<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>

<UserId>YOURUSERID</UserId>

<Password>YOURPASSWORD</Password>

</AccessRequest>

<?xml version="1.0" ?>

<AddressValidationRequest xml:lang='en-US'>

<Request>

<TransactionReference>

<CustomerContext /><XpciVersion>1.0001</XpciVersion>

</TransactionReference>

<RequestAction>XAV</RequestAction>

<RequestOption>3</RequestOption>

</Request>

<MaximumListSize>3</MaximumListSize>

<AddressKeyFormat>

<ConsigneeName>UPS Capital</ConsigneeName>

<BuildingName>Business Credit</BuildingName>

<AddressLine>425 Day Hill Road</AddressLine>

<AddressLine>P.O. Box 400</AddressLine>

<AddressLine>Main Office</AddressLine>

<PoliticalDivision2>Windsor</PoliticalDivision2>

<PoliticalDivision1>CT</PoliticalDivision1>

<PostcodePrimaryLow>06095</PostcodePrimaryLow>

<CountryCode>US</CountryCode>

</AddressKeyFormat>

</AddressValidationRequest>

any help would be really appreciated

Thanks,

Srini

Former Member
0 Kudos

I think the first version tag will automatically be created by the XSLT mapper.

For the second please use

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

&lt;?xml version="1.0"?&gt;

</xsl:text>

put that in front of

<!-- copy the complete payload -->

Then give it a try.

CSY

Former Member
0 Kudos

Thanks Christian

Former Member
0 Kudos

Hi,

also you can go for java or abap mapping. Or use xslt output as text and than create such file:

<xsl:output method="text"/>...

/wg

Former Member
0 Kudos

Hi Christian,

I have created xslt code as below and it is giving errors as

at: file:///c:/DOCUME~1/srinu/Desktop/UPS_new.xsl 19

java.lang.RuntimeException: Error: at AccessRequest on line 19 of file:///c:/DOCUME~1/srinu/Desktop/UPS_new.xsl:

XTSE0010: xsl:text must not contain child elements

XSLT

<?xml version="1.0"?>

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

<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>

<xsl:template match="*">

<!-- remove element prefix (if any) -->

<xsl:element name="{local-name()}">

<!-- process attributes -->

<xsl:for-each select="@*">

<!-- remove attribute prefix (if any) -->

<xsl:attribute name="{local-name()}">

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

</xsl:attribute>

</xsl:for-each>

<xsl:apply-templates/>

</xsl:element>

</xsl:template>

<xsl:template match="/">

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

<AccessRequest xml:lang="en-US">

<AccessLicenseNumber>EC26E5B354448E54</AccessLicenseNumber>

<UserId>ackschmi</UserId>

<Password>stateups</Password>

</AccessRequest>

</xsl:text>

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

<xsl:processing-instruction name="xml" version="1.0">

<?xmlversion = '1.0'?></xsl:processing-instruction>

</xsl:text>

<AddressValidationRequest>-

<Request>

<RequestAction>XAV</RequestAction>

<RequestOption>3</RequestOption>

</Request>

<AddressKeyFormat>

<ConsigneeName>LONG POINT GOLF COURSE</ConsigneeName>

<BuildingName>LONG POINT GOLF COURSE</BuildingName>

<AddressLine>1 OSPREY RD</AddressLine>

<AddressLine>NASSAU</AddressLine>

<PoliticalDivision2>AMELIA CITY</PoliticalDivision2>

<PoliticalDivision1>FL</PoliticalDivision1>

<PostCodePrimaryLow>32034</PostCodePrimaryLow>

<CountryCode>US</CountryCode>

</AddressKeyFormat>

<MaximumListSize>15</MaximumListSize>

</AddressValidationRequest>

<xsl:apply-templates/>

</xsl:template>

</xsl:stylesheet>

any help would be appreciated

Thanks,

Srini

Former Member
0 Kudos

ok, then you have unfortunately to escape the xml content inside the xsl:text element.

Example:

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

&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;

</xsl:text>

CSY

Former Member
0 Kudos

Hi Guys,

I am getting the erors like xsl:text must not contain child elements at

<xsl:text><Accessrequest xml:lang=

any help would be appreciated

Thanks,

Srini

Former Member
0 Kudos

Hi Srini

<xsl:text>here_Is_Only_Text_Allowed</xsl:text>

In your case there starts a new node:

<Accessrequest xml:lang

Regards Mario

Former Member
0 Kudos

Hi Mario,

Thanks for the quick reply and now i understand the error. Can you please tell me how to maintain the header and body under this <xsl:text>.

Do i need to write <xsl:text> for every node ?

Header - constant

<AccessRequest xml:lang='en-US'>

<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>

<UserId>YOURUSERID</UserId>

<Password>YOURPASSWORD</Password></AccessRequest>

Body

<?xml version="1.0" ?>

<AddressValidationRequest xml:lang='en-US'>

<Request>

<TransactionReference>

<CustomerContext /><XpciVersion>1.0001</XpciVersion>

</TransactionReference>

<RequestAction>XAV</RequestAction>

<RequestOption>3</RequestOption>

</Request>

<MaximumListSize>3</MaximumListSize>

<AddressKeyFormat>

<ConsigneeName>UPS Capital</ConsigneeName>

<BuildingName>Business Credit</BuildingName>

<AddressLine>425 Day Hill Road</AddressLine>

<AddressLine>P.O. Box 400</AddressLine>

<AddressLine>Main Office</AddressLine>

<PoliticalDivision2>Windsor</PoliticalDivision2>

<PoliticalDivision1>CT</PoliticalDivision1>

<PostcodePrimaryLow>06095</PostcodePrimaryLow>

<CountryCode>US</CountryCode>

</AddressKeyFormat>

</AddressValidationRequest

any help would be really appreciated

Thanks,

Srini

Answers (4)

Answers (4)

Former Member
0 Kudos

HI

Step u2013 By u2013 Step Simple Approach for XSLT Mapping

cheers

Former Member
0 Kudos
Former Member
0 Kudos

hi srinivas

check the below blog

XSLT mapping for multiple segments of XML

generic xslt mapping part 1

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2e...

generic xslt mapping part 2

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9692eb84-0601-0010-5ca0-923...

Step u2013 By u2013 Step Simple Approach for XSLT Mapping

regards

kummari

Former Member
0 Kudos