xsl-list
[Top] [All Lists]

RE: Finding out if the current node is an attribute node

2003-06-01 16:11:03
Does "self::*@" work?

-----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 
Adrian
Grigore
Sent: Monday, 2 June 2003 09:00
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Finding out if the current node is an attribute node


Hi,

I am currently working with xsl-metaprogramming (an xsl template is 
compiling another language into xsl) and need to generate a 
template that 
behaves differently when it's current node is an attribute 
node than when 
it's current node is any other kind of node.

In other words, I am looking for an easy way to check within the 
template  example if the template's match attribute is something like

/somenode/@id

in which case it matched an attribute node or something like

/somenode/somechildnode

in which case it matched a element node. It's easy to find 
out about text 
and comment nodes, but there seems to be no function for this 
in order to 
distinguish between element and attribute nodes. I could 
write a an xsl 
helper template that analyzes the matched string, but that 
would take a few 
hours. For example an xpath expression like this makes it 
tricky to find 
out if you matched an attribute or an element node:

/addresses[(_at_)id='2']/someaddress/phone/@type[../@test='somevalue']

in this case the @type attribute node is the current node, so 
it is an 
attribute. But in this case

/addresses[(_at_)id='2']/someaddress/phone/@type[../@test='somevalue']/..

it would be an element! So the easiest approach I have found 
so far is to 
look for the last @... string that is not surrounded by [] 
brackets, but it 
takes a lot of xslt code to find it..

So, is there any simple way to do this? Maybe I overlooked 
something obvious?


There is certainly no other way for me to implement this, I 
looked for 
another way for many hours already. Any help would be greatly 
appreciated! :-)

Thanks in advance for your time,

Adrian Grigore

Adrian Grigore

--
Adrian Grigore
adrian(_at_)lobstersoft(_dot_)com
Lobstersoft - Fun Brain-Bending Games For All Ages
http://www.lobstersoft.com
Member of the Association of Shareware Professionals


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list