This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: table type output in text fromat in a complex xml file.


Praveen,

Yes, it is possible.  The difficult part is wrapping text in cells.

The easy part is padding a string to a given length:

<xsl:template name="pad-string">
  <xsl:param name="str"/>
  <xsl:param name="len"/>
  <xsl:param name="quad" select="'left'"/><!-- or 'right' or 'center' -->
  <xsl:choose>
    <xsl:when test="string-length($str) &gt;= $len">
      <xsl:value-of select="substring($str,1,$len)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="$quad = 'right'">
          <xsl:call-template name="pad-string">
            <xsl:with-param name="str" select="concat(' ',$str)"/>
            <xsl:with-param name="len" select="$len"/>
            <xsl:with-param name="quad" select="$quad"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:when test="$quad = 'center'">
          <xsl:call-template name="pad-string">
            <xsl:with-param name="str" select="concat(' ',$str,' ')"/>
            <xsl:with-param name="len" select="$len"/>
            <xsl:with-param name="quad" select="$quad"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="pad-string">
            <xsl:with-param name="str" select="concat($str,' ')"/>
            <xsl:with-param name="len" select="$len"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

With just a little more work you could even align columns on a character (a
decimal point, for example).

Have fun,

Paul Tyson, Principal Consultant                   Precision Documents
paul@precisiondocuments.com              http://precisiondocuments.com
     "The art and science of document engineering."

----- Original Message -----
From: "Praveen G" <praveeng@india.hp.com>
To: <XSL-List@lists.mulberrytech.com>
Sent: Tuesday, October 02, 2001 12:28 AM
Subject: [xsl] table type output in text fromat in a complex xml file.


> Hi all,
>  we know that we can give a table like ordered appearance(without borders,
> obviously)for an xml data when all the data is similar(i.e all the
elements
> and their child elements are similar in content --they  all can be grouped
> into a pattern) in text format(that can be seen in notepad) using XSL.
>  now, i have a complex XML file with a lot of different kinds of elements
> and their corresponding child elements.
> I have written a style sheet in XSL  to html which will group all the
> similar data in html tables. we have a lot of html tables like that.
>
> Now , my question is --- is it possible to write a xsl style sheet to
> produce that many html table like appearances(without borders-just a open
> table look)  in text format?This is just an investigation and i wanted to
> know whether it is possible.
>
> 1) we have to use only XSLT. we cannot use  XSL  Formatting   objects.
>  2) we know that <xsl:text> command can be used for small files where u
can
> get only one table. we use it inside template match ="/"  etc. code. now,
if
> i have to produce some 10 to 20 tables like that in the same style sheet
in
> text format, what do i do?
>
> can anyone enlighten me , whether it is possible in XSLT?
>
> thanks and regards,
> praveen
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]