XML : splitting string into new items XSLT 1.0 [duplicate]

This question already has an answer here:

I need help I have problem with fitting splitted string into new items I splitted string and putted in the Item (td) but whole splitted string... Whats I need is after splitted (splitting every second space) string put into new td

Here is my input:

  <gml:posList>50.48972 3.8125 50.43528 3.95389 50.50278 3.9425 50.53528 3.93611 50.63806 3.66167 50.62389 3.64611 50.51722 3.7375 50.48972 3.8125</gml:posList>    

Here is my code:

  <?xml version="1.0" encoding="UTF-8"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:message="http://www.aixm.aero/schema/5.1/message" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:aixm="http://www.aixm.aero/schema/5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">      <xsl:template name="splitEverySecond">      <xsl:param name="pText" select="."/>       <xsl:if test="string-length($pText)">        <xsl:value-of select="concat(substring-before($pText,' '),' ',substring-before(substring-after($pText,' '),' '),'&#xa;')" />        <xsl:call-template name="splitEverySecond">          <xsl:with-param name="pText" select="substring-after(substring-after($pText,' '),' ')" />        </xsl:call-template>      </xsl:if>    </xsl:template>      <xsl:template match="gml:posList">      <html>        <body>          <h2>Position</h2>          <table border="1">            <tr bgcolor="#9acd32">              <th>Pos</th>                </tr>            <tr>               <td>                  <xsl:for-each select="*">                  <p>                    <xsl:value-of select="name()"/>                    <xsl:value-of select="."/>                  </p>                </xsl:for-each>                              <xsl:call-template name="splitEverySecond" />              </td>            </tr>          </table>        </body>      </html>      </xsl:template>    <xsl:template match="text()|@*"/>    </xsl:stylesheet>    

My output is now :

  <tr>              <td>50.48972 3.8125                 50.43528 3.95389                 50.50278 3.9425                 50.53528 3.93611                 50.63806 3.66167                 50.62389 3.64611                 50.51722 3.7375                 50.48972                 </td>           </tr>    

So I want output like this:

    <tr>                  <td>50.48972 3.8125</td>                  <td>50.43528 3.95389</td>                  <td>50.50278 3.9425</td>                  <td>50.53528 3.93611</td>                  <td>50.63806 3.66167</td>                  <td>50.62389 3.64611</td>                  <td>50.51722 3.7375</td>                  <td>50.48972</td>                    </td>               </tr>    

Thank you so much for help

No comments:

Post a Comment