Subject: RE: [xsl] adding things up From: "Liao, John Teguh (John)" <jliao@xxxxxxxxxx> Date: Mon, 4 Nov 2002 11:28:28 -0500 |
Wow, thanks for opening my eyes to a much cleaner solution. I just got Mike Kay's book this past weekend. I hope it helps me to understand my choices because so far everything i know about xslt i found in the web. J.L. -----Original Message----- From: Amirico Albuquerque [mailto:aalbuquerque@xxxxxxxxxxxxxxxx] Sent: Saturday, November 02, 2002 6:11 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Sorry about the wrong subject, here's my question (again) Hi John. Your question was a little dificult to parse but these templates might work as you intended to, they work with the example you've provied. <xsl:key name="itemkey" match="KEY" use="../@NAME"/> <xsl:template match="/ACCESS/NON_TABLE/DATA_ITEM"> <xsl:variable name="name" select="@NAME"/> <xsl:variable name="nodes" select="key('itemkey',$name)/ID"/> <xsl:text>T:</xsl:text> <xsl:value-of select="$name"/> <xsl:text> </xsl:text> <xsl:apply-templates select="/ACCESS/TABLE[@NAME=$name]/DATA_ITEM[@DESIGN_ID=$nodes/@DESIGN_I D]" mode="keyset"> <xsl:with-param name="label" select="'K'"/> </xsl:apply-templates> <xsl:apply-templates select="/ACCESS/TABLE[@NAME=$name]/DATA_ITEM[not(@DESIGN_ID=$nodes/@DESI GN_ID)]" mode="keyset"/> </xsl:template> <xsl:template match="DATA_ITEM" mode="keyset"> <xsl:param name="label" select="'A'"/> <xsl:value-of select="$label"/> <xsl:text>:</xsl:text> <xsl:value-of select="@NAME"/> <xsl:text>:</xsl:text> <xsl:value-of select="@DB_TYPE"/> <xsl:text>:</xsl:text> <xsl:value-of select="sum(preceding-sibling::DATA_ITEM/@SIZE)"/> <xsl:text>:</xsl:text> <xsl:value-of select="count(preceding-sibling::DATA_ITEM) + 1"/> <xsl:text> </xsl:text> </xsl:template> -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Liao, John Teguh (John) Sent: Tuesday, October 29, 2002 11:22 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: [xsl] Sorry about the wrong subject, here's my question (again) -----Original Message----- From: Liao, John Teguh (John) Sent: Tuesday, October 29, 2002 6:20 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] FO:Leader Pushing Data in seperate table cells 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> </xsl:text> <xsl:value-of select="concat('K:',../../DATA_ITEM[@DESIGN_ID=current()/@DESIGN_ID]/@NA ME)" /> <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 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: test equals fails Duhhh, JWALLIS | Thread | [xsl] XSL selection question, jeremyf |
[xsl] accessing URL parameters from, John Pallister | Date | Re: [xsl] complicacy of sorting, Joerg Heinicke |
Month |