[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Creating then using elements from xml table <row><
[ Kathy Burke] > With what I've tried so far, I don't get errors BUT I don't get output > either! > If you do not get any output it is normally because your templates are not getting invoked. > My xml source (created using an xml authoring tool) contains > the following: > > <tools_materials> > <table><tgroup cols="2"> > <?PubTbl tgroup dispwid="6.78in"?> > <colspec colname="col1" colwidth="1.26*"/><colspec colname="col2" > colwidth="0.74*"/> > <tbody><row><entry>Tool/Material</entry> > <entry>Part Number</entry></row> > <row><entry>Operations Manual</entry><entry>092022-001</entry> > </row><row><entry>Machine Management System</entry> > <entry>10-MS30-1000-021</entry></row></tbody></tgroup></table> > </tools_materials> > > In my stylesheet, I need to create parent/child elements from > the table > content (excluding row 1), ex: > > Column 1 = <tool_mat>Operations Manual > Column 2 = <tool_partno>092022-001</tool_partno> > </tool_mat> > > I then need to use those newly created elements in an html > table. No, I do not think that this is your task. Anyway, you cannot do this with standard xslt 1.0, because anything you "create" will be a result tree fragment, not a node set. You task is to get get the data of certain entry elements into certain slots in the html table, is it not? > I have the > following xsl (the first template is just my feeble attempt): > > <xsl:template match="tools_materials/table"> <!-- just > trying to get the > first element --> > <xsl:for-each select="row[position() != 1]"> > <xsl:element name="tool_mat"> > <xsl:value-of > select="normalize-space(cell[1])"/></xsl:element> > </xsl:for-each> > </xsl:template> > No need to make it hard. If I understand what you want, just build it up bit by bit, first the table, then the header row, then the rest of the rows - something like this, although you will want to add some details I have omitted (and I wrapped your source fragment in a "root" element) - <xsl:template match='/root'> <html> <xsl:apply-templates select='tools_materials/table'/> </html> </xsl:template> <xsl:template match="table"> <table> <xsl:apply-templates select='tgroup/tbody'/> </table> </xsl:template> <xsl:template match='tbody'> <tr> <th><xsl:value-of select='row[1]/entry[1]'/></th> <th><xsl:value-of select='row[1]/entry[2]'/></th> </tr> <xsl:apply-templates select='row[position() > 1]'/> </xsl:template> <xsl:template match='row'> <tr> <td><xsl:value-of select='entry[1]'/></td> <td><xsl:value-of select='entry[2]'/></td> </tr> </xsl:template> See - clean and simple. Now you can add the rest of the details that make it look readable. Don't fuss with widths, alignment, or background colors until you have gotten the core of the thing working. Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|