Shuvajit Ghosh
Shuvajit Ghosh

Reputation: 108

How to display an String type array of Java in xsl?

Below is the xml file from which the xpath is to be framed and used in xsl file.

<response>
<RetrieveUserResponseDTO>
<mob />
<idCustomer />
<requestId />
<idChannel />
<userType />
<idUser />
<idChannelUser>123</idChannelUser>
<idChannelUser>234</idChannelUser>
<idChannelUser>1245</idChannelUser>

etc

Below is the Java String array

l_resp.idChannelUser = new String[3];

Below is the xsl code

<xsl:for-each select="faml/response/retrieveuserresponsedto/idchanneluser">
                                            <tr>
                                                <td class="warning" width="75%">
                                                    <xsl:value-of select="faml/response/retrieveuserresponsedto/idchanneluser"></xsl:value-of>
                                                </td>       
                                            </tr>
                                        </xsl:for-each>

Upvotes: 0

Views: 407

Answers (1)

Tim C
Tim C

Reputation: 70598

Ignoring the bit about the Java array, and focusing only on XSLT transforming XML, there are two issues two note

  1. XML and XSLT are case-sensitive so retrieveuserresponsedto is not going to match RetrieveUserResponseDTO in your XML (and idchanneluser will not match idChannelUser)
  2. In side your xsl:for-each statement, you will be positioned on an idChannelUser element, so your XPath to get the value needs to be relative to that.

Try this XSLT instead: (You might need to add a faml element at the start of the XPath if indeed that element is present in your XML)

<xsl:for-each select="response/RetrieveUserResponseDTO/idChannelUser">
   <tr>
      <td class="warning" width="75%">
         <xsl:value-of select="." />
      </td>       
   </tr>
</xsl:for-each>

Upvotes: 1

Related Questions