Subject: RE: [xsl] how to get info from nodes surrounding current node? From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Mon, 30 Sep 2002 21:03:38 +0100 |
You want <xsl:value-of select="parent::TABLE/@name"/> or simply "../@name". Writing <xsl:value-of select="TABLE[@name]" means "output the string-value of the first child TABLE of the context node that has an @name attribute". Of course your context node, IDX, has no child TABLE elements, and you don't want the contents of the TABLE element, you want the contents of its @name attribute. Similarly for the columns you want @col_id to output the attribute contents. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of john liao > Sent: 30 September 2002 18:23 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] how to get info from nodes surrounding current node? > > > I am a newbie, and I just looked at the FAQ and search > turned up too many irrelevant things. I want to > display the value of name in data item when I'm > matching another element: > > <TABLE name="table1"> > <ITEM id="105" name="col1"/> > <ITEM id="106" name="col2"/> > <IDX NAME="IDX1"> > <D_ID col_id="105"/> > <D_ID col_id="106"/> > </IDX> > </TABLE> > > I want to print plaintext output in SQL so it looks > like: > > CREATE UNIQUE INDEX IDX1 on table1 (col1, col2); > > My XSL is something like: > > > <xsl:template-match select="IDX"> > CREATE UNIQUE INDEX <xsl:value-of select="@NAME"/> on > <xsl:value-of select="TABLE[@name]"/> (<xsl:apply-templates > select="D_ID"/> </xsl:template> > > <xsl:template-match select="D_ID"> > <xsl:value-of select="col_id"/>); > </xsl:template> > > This last template can only print 105, 106); so my > output looks like: CREATE UNIQUE INDEX IDX1 on table1 > (105, 106); > > while I was really looking to print: > > CREATE UNIQUE INDEX IDX1 on table1 (col1, col2); > > How do I print the 'name' in ITEM rather than the > 'col_id' in the "D_ID" template? > > Thanks for your time. > > > ===== > > > __________________________________________________ > Do you Yahoo!? > New DSL Internet Access from SBC & Yahoo! > http://sbc.yahoo.com > > 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] how to get info from node, James Fuller | Thread | [xsl] RE: replace function, Dimitre Novatchev |
Re: [xsl] replace function, Kurt Cagle | Date | RE: [xsl] XSLT template from XSLT +, James Fuller |
Month |