cancel
Showing results for 
Search instead for 
Did you mean: 

localName using XSLT

Former Member
0 Kudos

I need to change the folowing sentence in Java Mapping

localName

to sentence in XSLT mapping.

For example Java Mapping

if (localName.equals("Envelope")){

salida += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">";

}

}else{

salida += "</" + localName;

salida += ">";

}

I need the same result using XSLT Mapping

Accepted Solutions (0)

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

did you try the code I provided in this link

regards

Anupam

Former Member
0 Kudos

Yes, your last code was perfect. My Client understood everything fine (in some cases Graphic Mapping is not the only solution for all problems, in some cases we can use XSLT or Java Mapping). Right now we are trying to compare instructions in Java Mapping vs. XSLT, next The Client will take the final desicion or use Java Mapping or use XSLT.

Now I need to build another code, in this case I need to obtain the Tag Name and build code using if ... and else, or several cases using when.

if (localName.equals("Envelope")){

salida += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">";

}else {

salida += "<" " + atts.getLocalName(i) + "=");

salida += ("\""atts.getValue(i)"\"");

} salida += ">";

We need a similar code in XSLT with the same result

source

<Envelope>

<Header>

<Body> XXXXXX

target

<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\>

<Header>

<Body> XXXXXX

anupam_ghosh2
Active Contributor
0 Kudos

Hi ,

Now already there is a java mapping existing. I would suggest java mapping over XSLT mapping. For following reasons

1. Resultant XML payload can not be viewed in SXMB_MONI if not in XML format (SP < SP14).

2.Interface mapping testing does not show proper error description. So errors in XSLT programs are difficult to trace in XI but can be easily identified outside XI using browser.

3. XSLT mapping requires more memory than mapping classes generated in Java.

4. In production enviornment its highly possible that the scenarios would run slowly if there are too many XSLT mapping within them, due to their high memory requirement.

Finally if you still wanna go with XSLT mapping then I have already explained the way to convert the java mapping to XSLT mapping. only place where "if" is being used in java mapping is to test whether name of a particular tag, this is being taken care by "<xsl:for-each select="//Envelope">" statement in XSLT. This you have to follow throughout the code.

For tutorials on XSLT please refer this http://www.w3schools.com/xsl/

Finally if you provide the source and target XML, I am sure Forum members will be able to assist you further in this regard. This is much better option than changing the existing java code.

Hope this helps.

regards

Anupam

Former Member
0 Kudos

Hi,

I assumed your requirment as below:

localName ==> variable name in java.

For XSLT, it shoud refer the element of your source structure as below:

<xsl:variable name:localName select ="your xpath which shoud refer source element"/>

Now going to logic:

<xsl:for-each select="your xpath which should refer source segment to repeat>

<xsl:choose>

<xsl:when test="string($localName) = 'Envelope'">

<xsl:variable name:Result>

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

<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">"/></xsl:text></xsl:variable>

</xsl:when>

<xsl:otherwise>

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

</xsl:otherwise>

</xsl:choose>

</xsl:for-each>

Hope this will help you.

Regards,

Senthil

Former Member
0 Kudos

In fact,

localName in Java Mapping return the Tag Name, for example

<Header>

localName return "Header"

I need a instruction in XSLT that return the Tag Name to compare with a string to make something else

for example

if localName = "Envelope"

then

print "XXXXXX"

else

print "YYYYYY"

When I'm in Tag Envelope print XXXXX, in another Tag print YYYYY