ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere DataPowerXSLT for-each issue

Post new topicReply to topic
XSLT for-each issue View previous topic :: View next topic
Author Message
nelson
PostPosted: Mon Apr 06, 2015 8:22 am Post subject: XSLT for-each issue Reply with quote

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
View user's profile Send private message
nelson
PostPosted: Tue Apr 07, 2015 9:56 am Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere DataPowerXSLT for-each issue
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.