Subject: RE: [xsl] Creating then using elements from xml table <row><entry > content? From: "Kathy Burke" <Kathy_Burke@xxxxxxxxx> Date: Wed, 29 Oct 2003 16:09:13 -0500 |
Follow on question, please. Within a table/row <entry> there can also be a <link> element. When I use <xsl:value-of select='entry[1]'/> etc., I dont' get the nested <link> element so my link template doesn't get applied. Any clues? Thanks again. Kathy -----Original Message----- From: Passin, Tom [mailto:tpassin@xxxxxxxxxxxx] Sent: Wednesday, October 29, 2003 2:31 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Creating then using elements from xml table <row><entry> content? [ 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Creating then using eleme, Kathy Burke | Thread | RE: [xsl] Creating then using eleme, Wendell Piez |
RE: [xsl] logical operators in *tes, Kienle, Steven C [PG | Date | Re: [xsl] logical operators in *tes, David Tolpin |
Month |