[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

Subject: Finding out if the current node is an attribute node
From: Adrian Grigore <adrian@xxxxxxxxxxxxxxx>
Date: Sun, 01 Jun 2003 22:59:58 +0200
adrian 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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.