|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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[@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[@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@xxxxxxxxxxxxxxx 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








