[Home] [By Thread] [By Date] [Recent Entries]

  • From: "Michael Kay" <mike@s...>
  • To: "'Rick Jelliffe'" <rjelliffe@a...>,<">"@modelo.allette.com.au>,<xml-dev@l...>
  • Date: Tue, 9 Jan 2007 08:51:08 -0000

> Heres the code we use in Schematron (I think from David Carlisle
> originally?)
> 
>    		<xsl:template match="*|@*" mode="get-full-path">
> 
> 			<xsl:apply-templates select="parent::*" 
> mode="get-full-path"/>
> 			<xsl:text>/</xsl:text>
> 			<xsl:if test="count(. | ../@*) = 
> count(../@*)">@</xsl:if>
> 			<xsl:value-of select="name()"/>
> 			<xsl:text>[</xsl:text>
> 	  		<xsl:value-of 
> select="1+count(preceding-sibling::*[name()=name(current())])"/>
> 	  		<xsl:text>]</xsl:text>
>        	 	</xsl:template>
> 

Two criticisms: 

(a) it's not namespace-safe (e.g. comparing name(x)=name(y) is thoroughly
dubious)

(b) It would make more sense to have separate template rules for elements
and attributes. This will output an attribute as @a[1] which doesn't make
much sense.

Michael Kay
http://www.saxonica.com/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member