1 Reply Latest reply on Dec 15, 2017 3:27 PM by Chad Wadkins

    BAO: Concatenate adapter response output lines

    Chad Wadkins

      If given adapter response output similar to this:

      <output>

          <line index="1"> Pool Name: test3_pool : Member: abc-1.domain.com</line>

          <line index="2"> Status: enabled</line>

          <line index="3"> Pool Name: test3_pool : Member: abc-2.domain.com</line>

          <line index="4"> Status: disabled</line>

      </output>

       

      Is there a way to concatenate the even numbered @index items with their respective odd predecessor lines?

       

      Desired output would be similar to this:

      <output>

          <line index="1"> Pool Name: test3_pool : Member: abc-1.domain.com : Status: enabled</line>

          <line index="3"> Pool Name: test3_pool : Member: abc-2.domain.com : Status: disabled</line>

      </output>

       

      Thanks for any help on this that can be given,

      Chad...

        • 1. Re: BAO: Concatenate adapter response output lines
          Chad Wadkins

          I just received this xslt from one of my contacts via email, which was on point to help me resolve this.  Thanks goto Abhinay Dubey for the logic below.

           

           

          <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

            <xsl:output indent="no" />

            <xsl:template match="/">

              <value>

                <xsl:for-each select="//line">

                  <xsl:variable name="currentIndex" select="./@index" />

                  <xsl:if test="number($currentIndex) mod 2">

                    <newline>

                      <xsl:value-of select="concat(., //line[@index = ($currentIndex  + 1)])" disable-output-escaping="no" />

                    </newline>

                  </xsl:if>

                </xsl:for-each>

              </value>

            </xsl:template>

          </xsl:stylesheet>