Subject: Re: [xsl] Retrieving named elements from separate tree From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> Date: Tue, 19 Mar 2002 20:48:51 +0100 |
[@colname=name()] is true for all nodes, where the value of @colname is the same as the name: <nodename colname="nodename"/>. name() in the predicate means the node outside the predicate. What you want to have: [@colname=name(current())]. Regards, Joerg ----- Original Message ----- From: <STEPHEN_R_FRIEDLAND@xxxxxxxxx> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, March 19, 2002 8:25 PM Subject: [xsl] Retrieving named elements from separate tree > I'm looking for advice as to how to make the following work. It > seems to me that it "should" be possible, but I'm not having > much luck. > > I'm trying to use html table column metadata (eventually this > will end up in a separate xml file) to define the alignment of > each column. > > The xml file follows. > > myData.xml --------------------------------- > <?xml version="1.0" ?> > > <TradeData date='2002-03-18'> > <ColumnInfo> > <column colname="TradeType" align="left"/> > <column colname="TradeId" align="center"/> > <column colname="TradeValue" align="right"/> > </ColumnInfo> > > <Trades> > <TradeEntry> > <TradeType>TypeA</TradeType> > <TradeId>12345</TradeId> > <TradeValue>100.00</TradeValue> > </TradeEntry> > <TradeEntry> > <TradeType>TypeB</TradeType> > <TradeId>45678</TradeId> > <TradeValue>500.00</TradeValue> > </TradeEntry> > <TradeEntry> > <TradeType>TypeC</TradeType> > <TradeId>56789</TradeId> > <TradeValue>350.00</TradeValue> > </TradeEntry> > </Trades> > </TradeData> > ---------------------------------------------------------- > The xsl file follows. > myData2html.xsl -------------------------------- > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:template match="/TradeData"> > <html><body> > <p>Prepared on <xsl:value-of select="@date"/></p> > <xsl:apply-templates select="//Trades" /> > </body></html> > </xsl:template> > > <xsl:template match="Trades"> > <p>Transactions:</p> > <table border="1"> > <tr> > <xsl:for-each select="TradeEntry[position()=1]/*"> > <th><xsl:value-of select="name()"/></th> > </xsl:for-each> > </tr> > <xsl:apply-templates select="TradeEntry"/> > </table> > </xsl:template> > > <xsl:template match="TradeEntry"> > <tr><xsl:apply-templates/></tr> > </xsl:template> > > <xsl:template match="TradeEntry/*"> > <td> > <xsl:attribute name="align"><xsl:value-of > select="//ColumnInfo/column[@colname='TradeId']/@align"/></xsl:attribute> > <xsl:value-of select="."/> > </td> > </xsl:template> > > </xsl:stylesheet> > -------------------------------------------------------------------- > > I've declared an attribute for the <td> tag, which I'm trying to set to the > current column's align attribute. If I hard-code the colname ('TradeId') > then it works. What I would like to do is to replace [@colname='TradeId'] > with something like [@colname=name()]. This (and several variations I've > tried) does not work. > > Thanks, > - Steve XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Retrieving named elements fro, STEPHEN_R_FRIEDLAND | Thread | Re: [xsl] Retrieving named elements, Peter Davis |
[xsl] Evaluating text from within a, bryan hansen | Date | Re: [xsl] Evaluating text from with, Joerg Heinicke |
Month |