|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
XSLT for-each issue |
« View previous topic :: View next topic » |
Author |
Message
|
nelson |
Posted: Mon Apr 06, 2015 8:22 am Post subject: XSLT for-each issue |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
Hi all,
I now this is more a XSLT issue than Datapower's, but maybe some of you could give some light on this (that seem's pretty basic).
I need the following behavior in a XSLT Transformation in Datapower:
Input text:
Code: |
AAAAAZZZZZZZ
BBBBBZZZZZZZ
CCCCCZZZZZZZ |
Output text:
Code: |
_HEADER
AAAAA
BBBBB
CCCCC
_FOOTER |
So I wrote the following XSLT:
Code: |
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:str="http://exslt.org/strings"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="dp str date"
>
<dp:input-mapping href="store:///pkcs7-convert-input.ffd" type="ffd"/>
<xsl:output method="text"/>
<xsl:variable name="rowsep" select="'
'"/>
<xsl:variable name="input64" select="dp:binary-encode(/object/message/node())"/>
<xsl:variable name="str" select="dp:decode($input64,'base-64')"/>
<xsl:template match="/">
<!-- Header -->
<xsl:text>_HEADER
</xsl:text>
<!-- Body -->
<xsl:for-each select="str:split($str,$rowsep)">
<xsl:if test="position()!=last()">
<xsl:value-of select="substring(.,1,5)"/>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
<!-- Trailer -->
<xsl:text>_FOOTER
</xsl:text>
</xsl:template>
</xsl:stylesheet> |
But it is generating the following output:
Code: |
_HEADER
_HEAD
AAAAA
BBBBB
CCCCC
_FOOT
_FOOTER |
I don't understand why every text or value-of tag outside the for-each tag generates strange outputs (or at least I'm not able to find a pattern of what's wrong). As you can see, the header is "partially" repeated, and has no clue the reason of this behavior. Seems that it is modifying a reference.
Could you please give me some hints on where the mistake would be? |
|
Back to top |
|
 |
nelson |
Posted: Tue Apr 07, 2015 9:56 am Post subject: |
|
|
 Partisan
Joined: 02 Oct 2012 Posts: 313
|
Solved!... It was my fault... I was closed in the idea that was the XSLT that was failing. But I was applying twice the transformation: in the MPG and in the backend. That explains the strange behavior.  |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|