xsl-list
[Top] [All Lists]

RE: how to get info from nodes surrounding current node?

2002-09-30 13:03:38
You want <xsl:value-of select="parent::TABLE/@name"/> or simply
"../@name". 

Writing <xsl:value-of select="TABLE[(_at_)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(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
john liao
Sent: 30 September 2002 18:23
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
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[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>