[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: table type output in text fromat in a complex xml file.
From: "Paul Tyson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Oct 2001 09:04:06 -0700
xml to text table formatting
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@xxxxxxxxxxxxxxxxxxxxxx              http://precisiondocuments.com
     "The art and science of document engineering."

----- Original Message -----
From: "Praveen G" <praveeng@xxxxxxxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, October 02, 2001 12:28 AM
Subject:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.