Subject: [xsl] fill in a table with dynamic header at correct place From: "Jan Weiss" <jweiss@xxxxxxxxxxxxxxxxxx> Date: Wed, 18 Jul 2001 08:29:53 +0200 |
hi all, two problems: First: How can I get the -name- of each attribute which exists in an xml file (I need the name and not the value, because I have to build the header of a table by the attribute names, which are changing from xml file to xml file!!) Second: I have a big problem to fill in dynamic tables. Header and number of cols are always different. I read the header of the table out of /SPStruct/definitions/col/@name ! I want to put all stuff of ../data/row/col at the right place in the table, but this is the problem: if one attribute is empty, it does not appear in the xml file so I am not able to simply write the data in a row. I hope my explanation was not toooo bad and I hope somebody could HELP ME. thanks jan weiss p.s.: my output looks like this: Part_Name NOMINAL_SIZE SERIES A B T .... BCT-ITEM-ID BCT-ITEM-REV ... shdfkg lshygk hygkhf khg kjh kjh lhlhlj NOTHING there is no connection between header and content. <?xml version="1.0" encoding="UTF-8" ?> <?xml-stylesheet href="bct_spreadsheet.xsl" type="text/xsl" ?> <!DOCTYPE bct-spreadsheet-definition SYSTEM "bct_spreadsheet.dtd" > <SPStruct template="fgdhfjhfd"> <definitions> <col order="1" alias="" type="A" min="" max="" name="Part_Name" /> <!-- each attribute name should be compared with ../data/row/@name then if true write data into col of table else fill in col with blank --> <col order="2" alias="" type="N" min="" max="" name="NOMINAL_SIZE" visible="I" /> <col order="3" alias="series" min="" max="" name="SERIES" color="#ae1234" /> <col order="4" alias="" type="N" min="" max="" name="A" color="#ffff7f" /> <col order="5" alias="" type="N" min="" max="" name="B" visible="I" /> <col order="6" alias="" type="N" min="" max="" name="T" /> <col order="7" alias="" min="" max="" name="BCT-BOM-REL" /> <col order="8" alias="german" min="" max="" name="BCT-DESC1-DE" /> <col order="9" alias="" min="" max="" name="BCT-DESC1-EN" /> <col order="10" alias="" min="" max="" name="BCT-DESC2-DE" /> <col order="11" alias="" min="" max="" name="BCT-DESC2-EN" /> <col order="12" alias="" min="" max="" name="BCT-ITEM-ID" /> <col order="13" alias="" min="" max="" name="BCT-ITEM-REV" /> <col order="14" alias="" min="" max="" name="BCT-ITEM-VAR" /> <col order="15" alias="" min="" max="" name="BCT-MATERIAL" /> <col order="16" alias="" min="" max="" name="BCT-MATERIAL-NO" /> <col order="17" alias="" min="" max="" name="BCT-QUANTITY-UNIT" /> <col order="18" alias="" min="" max="" name="BCT-WEIGHT" /> <col order="19" alias="" min="" max="" name="BCT-WEIGHT-UNIT" /> <col order="20" alias="" min="" max="" name="SECTION-COMPONENT" /> <col order="21" alias="" min="" max="" name="$DESCRIPTION" /> </definitions> <data> <row> <col name="Part_Name" >ghj</col> <col name="NOMINAL_SIZE" >0.06</col> <col name="SERIES" >N</col> <col name="A" >hj</col> <col name="B" >gdh5</col> <col name="T" >dg25</col> <col name="BCT-BOM-REL" >1</col> <col name="BCT-DESC1-DE" >rhfhfdh</col> <col name="BCT-DESC1-EN" >djdhgjdhjd</col> <!-- in this example and they should be blank output --> <col name="BCT-QUANTITY-UNIT" >piece</col> <col name="SECTION-COMPONENT" >NO</col> <col name="$DESCRIPTION" >fgjgf</col> </row> <row> <col name="Part_Name" >fgjggfj</col> <col name="NOMINAL_SIZE" >0.06</col> <col name="SERIES" >R</col> <col name="A" >0fgj8</col> <col name="B" >0gh</col> <col name="T" >gfj5</col> <col name="BCT-BOM-REL" >1</col> <col name="BCT-DESC1-DE" >fghjf</col> <col name="BCT-DESC1-EN" >gfjr</col> <col name="BCT-QUANTITY-UNIT" >piece</col> <col name="SECTION-COMPONENT" >NO</col> <col name="$DESCRIPTION" >gfjgfhj</col> </row> </data> </SPStruct> <xsl:template match="data"> <TABLE BGCOLOR="#FFFFFF" BORDER="0" CELLSPACING="2" CELLPADDING="2" ALIGN="left"> <TR ALIGN="left" BGCOLOR="#9C1029"> <font face="Arial" size="+1" color="#FFFFFF"><b>kgkgkh</b></font> </TR> <TR BGCOLOR="ffffdd"> <xsl:apply-templates select="/SPStruct/definitions/col" mode="index"/> </TR> <xsl:apply-templates/> </TABLE> </td> </tr> </xsl:template> <xsl:template match="/SPStruct/definitions/col" mode="index"> <TD><xsl:value-of select="@name"/></TD> <!-- header of the table --> </xsl:template> <!-- *** row *** --> <xsl:template match="/SPStruct/data/row> <TR BGCOLOR="FFFFFF" class="odd"> <xsl:apply-templates mode="ind" /> </TR> </xsl:template> <xsl:template match="/SPStruct/data/row/col" mode="ind"> <xsl:choose> <xsl:when test="@name=//definitions/col/@name"> <!-- I think the error must be here --> <TD><xsl:value-of select="." /></TD> <!-- only write data to table if @name suites to actual header of actual columnn --> </xsl:when> <xsl:otherwise><td> sfidsgöisdg </td></xsl:otherwise> <!-- only to fill empty cols --> </xsl:choose> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] understanding order of no, Jeni Tennison | Thread | [xsl] tokenize func, shruti |
[xsl] understanding order of nodes , Tamre Bond | Date | [xsl] More Multi-Document Mambo, Larry Garfield |
Month |