Re: [xsl] table type output in text fromat -ONE DOUBT

Subject: Re: [xsl] table type output in text fromat -ONE DOUBT
From: "Praveen G" <praveeng@xxxxxxxxxxxx>
Date: Wed, 3 Oct 2001 18:30:19 +0800
Hi paul and wendell ,
 Thanks for responding. I am using  xalan-j_2_2_d10 parser for my xml work.
In this we have a java program
(DOM2DOM .java) which is used for displaying xml text output on the command
prompt. Apart from this , we are using Microsoft Internet explorer version
6.0 for viewing xml documents.
Basically, i am not able to figure out how to utilize the code paul has sent
yesterday(I am getting domparser exceptions in xalan.)
I am pasting a sample xml document of ours here. i will specify the required
text table output format also. . i have to design some 20 odd tables like
that in text format. If u can please give a sample code for this xml
document here, i can use the same way of designing for the rest of my
tables.  i will also paste paul's code at the end so that he need not refer
back.
MY XML DOCUMENT ::
<?xml version="1.0"?>
<?xml-stylesheet  type="text/xsl" href="config.xsl"?>
<configuration_package>
<configuration>
 <acp_info>
      <name>WP424-c</name>
      <pb>5</pb>
      <pk>A/U10</pk>
      <serial>HCJ02454</serial>
      <factory>HiCAM</factory>
 </acp_info>
<acp_info>
      <name>WP426-b</name>
      <pb>6</pb>
      <pk>A/U10</pk>
      <serial>HCJ02479</serial>
      <factory>HiCAM</factory>
</acp_info>
<channel_info>
     <name>SH2132-A</name>
      <pb>2</pb>
      <pk>E5</pk>
      <serial>SH2120B9</serial>
      <factory>STR</factory>
 </channel_info>
 <subsytem_id>001</subsytem_id>
<subsytem_id>002</subsytem_id>
<subsytem_id>003</subsytem_id>
<subsytem_id>004</subsytem_id>
<subsytem_id>005</subsytem_id>
<subsytem_id>006</subsytem_id>
</configuration>
</configuration_package>
My REQUIRED TEXT FORMAT IS LIKE THIS:
Acp_info:
name              pb         pk         serial            factory
WP424-c        5     A/U10      HCJ02454   Hicam
WP426-b        6    A/U10      HCJ02479   Hicam

channel_info :
name              pb         pk         serial            factory
SH2132-A     2           E5      SH2120B9      STR

Subsystem_id :

               cu01     cu02     cu03 -->these are table columns.
00-3f      0001     0005
40-7f      0002     0006
80-bf      0003
co-ff       0004

1)all the table names will appear only once.
2) i have asked a question about the subsystem _id table format and paul has
provided a solution for that before(in html). Thanks a lot for that. now , i
need a similar table format in text.
3) can you please explain to me, what all i have to do to view this in
notepad(i have microsoft I.E -6.0 and xalan parser with me.) If u can give
me a sample stylesheet for this code above, i'll try it out in xalan. please
specify the namespace to be used also.
4)Basically, this kind of design will suffice, any improvement in the table
look above this will be a bonus for me.

PAUL'S CODE:
<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>

Expecting your help,
Thanks and regards,
praveen




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


Current Thread