cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT Mapping - problem with prefixes when calling template

Former Member
0 Kudos

Hi all,

I am having a problem with using an XSLT mapping in XI to combine various fields from 2 input messages of different structures into a single output message. I understand that XI puts a wrapper around the 2 input messages so the structure of the XML I am mapping is:

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

<ns2:Messages xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge">

<ns2:Message1>

<ns:(root of first message)>

...

</ns:(root of first message)>

</ns2:Message1>

<ns2:Message2>

<ns:(root of second message)>

...

</ns: (root of second message)>

</ns2:Message2>

</ns2:Messages>

Currently my XSL looks like the following:

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://example.co.uk/example" xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge" xmlns:javamap="java:systemDate.CurrentDate" version="2.0">

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

<xsl:param name="inputparam"/>

<xsl:template match="ns2:Messages">

...<xsl:calltemplate name="FormattingTemplate"/>

</xsl:template>

<xsl:template name="FormattingTemplate">

</xsl:template>

</xsl:stylesheet>

When I test the mapping it works fine until it calls the FormattingTemplate. Then it throws out a "transformer exception" error saying the prefix 'ns2' is not mapped to a namespace.

If anyone could tell me where I am going wrong I would be very grateful.

Thanks,

Mike

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

It turned out that the problem was nothing to do with the prefixes - XI didn't like the <xsl:number .../> command, and I was using it within the XSLT map.

Mike

Former Member
0 Kudos

Hi Udo,

Thanks for your reply.

When testing the stylesheet locally with XMLSpy, it works fine, but I have just noticed that it adds information in the root tag of the target message as follows:

<(root of target message) xmlns:javamap="java:systemDate.CurrentDate" xmlns:ns="http://example.co.uk/example" xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge">

I checked the root tag of the target message in XI and it does not automatically add this information. Thus I added it in my stylesheet so the information above is projected in the target message, but the same error message appears when the call template function is called. Do you know if I need to somehow add a namespace to templates other than the main one? If so, do you know how I go about doing that?

Thanks,

Mike

udo_martens
Active Contributor
0 Kudos

Hi Michael,

I would interpret the error like this: Ur XML result doesn't contain the declaration xmlns:ns2="..." but there r elements find with prefix 'ns2'. Plz test ur stylesheet local, for example with XML-Spy, or with internet explorer / View Source 2 proove that.

Regards,

Udo