RE: [xsl] FO:Leader Pushing Data in seperate table cells

Subject: RE: [xsl] FO:Leader Pushing Data in seperate table cells
From: "Liao, John Teguh (John)" <jliao@xxxxxxxxxx>
Date: Tue, 29 Oct 2002 18:19:31 -0500
Hi list

I'm trying to compute the column sizes of my tables:

my XML looks like this:

<ACCESS>
   <NON_TABLE>
      <DATA_ITEM NAME="TABLE1" DESCRIPTION="SUB CORC=att1,att2,att5"/>
   </NON_TABLE>
   <TABLE NAME="TABLE1" ... >
      <DATA_ITEM DESIGN_ID="100" NAME="att1" SIZE="8" DB_TYPE="number"/>
      <DATA_ITEM DESIGN_ID="200" NAME="att2" SIZE="4" DB_TYPE="number"/>
      <DATA_ITEM DESIGN_ID="300" NAME="att5" SIZE="32" DB_TYPE="string"/>
      <KEY NAME="INDEX1">
         <ID DESIGN_ID="100"/>
         <ID DESIGN_ID="200"/>
      </KEY_NAME>
   </TABLE>
</ACCESS>

and my xsl looks like this:

<!-- matching ACCESS/NON_TABLE/DATA_ITEM -->
<xsl:template match="DATA_ITEM">
<xsl:if test="@DESCRIPTION and substring-after(@DESCRIPTION,' ')">

T:<xsl:value-of select="@NAME"/>
<xsl:variable name="prikey"
select="../../TABLE[@DB_NAME=current()/@NAME]/KEY"/>
<xsl:variable name="curtbl" select="@NAME"/>
<xsl:for-each select="$prikey/ID">
	<xsl:text>&#10;</xsl:text>
	<xsl:value-of
select="concat('K:',../../DATA_ITEM[@DESIGN_ID=current()/@DESIGN_ID]/@NAME)"
/>
	<xsl:value-of
select="concat(':',../../DATA_ITEM[@DESIGN_ID=current()/@DESIGN_ID]/@DB_TYPE
)"/>
	<xsl:call-template name="prtoffset">
	    <xsl:with-param name="tblname" select="$curtbl"/>
	</xsl:call-template>
	<xsl:value-of select="concat (':', position())"/>
</xsl:for-each>
</xsl:if>
</xsl:template>
<!-- End of DATA_ITEM -->

<!-- context node is TABLE/KEY/ID -->
<xsl:template name="prtoffset">
    <xsl:param name="tblname" select="''"/> 
<xsl:value-of select="$tblname"/>
    <xsl:for-each select="../preceding-sibling::*">
	<xsl:number value="count(node()/@SIZE)"/>           <!--  What is
the right syntax for this? -->
    </xsl:for-each>
    <xsl:value-of select="."/>  <!-- supposed to be the offset -->
</xsl:template>

I need the output to look like this:

T:TABLE1
K:att1:number:0:1
K:att2:number:8:2
A:att5:string:12:3

The output can be read as: T is tablename, att1 is the first key attribute
with an offset of 0 bytes from the beginning
of the table, att2 is the second key attribute with an offset of 8 bytes
from the beginning of the table, att5 is a
regular attribute with an offset of 12 bytes from the beginning of the
attribute. The last number is the position of
the attribute in the document.

I'm having difficulty adding up the SIZEs in the prtoffset template in the
for-each loop. I have not coded the A: for
regular attributes yet. That's the next problem to solve.

Thanks in advance for the help!

J.L.
P.S. As you can see, I've advanced a little bit from my newbie status :)

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


Current Thread