[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: determining whether an XPATH points to an element
>you can tell if you have an element or an attribute by ><xsl:if test="self::*">which is true just on element nodes Thanks, this is exactly what I want. All I have is a document with arbitrary XPATH's i.e. <path>//tagname1[fads and @fads]/tagname2</path> I am using XSLT to process this file to create a second XSLT file. The second XSLT file has the template in it. <xsl:template match="//tagname1[fads and @fads]/tagname2"> <xsl:choose> <xsl:when test=" self::*"><!-- if it points to element --> <TagOperation> </xsl:when> <xsl:otherwise><!-- if it points to attribute--> <AttributeOperation> </xsl:otherwise> </xsl:choose> </xsl:template> >but this is a rather strange thing to do as 999 times out of 1000 you >always know in a template what kind of node is being matched. Unless I can find out whether the XPATH points to an element or attribute before I create the second XSLT I have to assume it could be either. from Jeni post >But if they're really fairly complicated, with predicates and things, >then you need to write a XPath parser to work out whether they match >elements or attributes. And that's very difficult. I gather there is no simple way to do this with just an XPATH so I will need to test at runtime. Thank a lot for your help Edward 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
|