[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] identity template to filter and modify atributes


Subject: Re: [xsl] identity template to filter and modify atributes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 30 Nov 2010 15:31:43 +0000

You need to drop in the new attribute after you have opened the header node, after you have copied the existing attributes but before you copy the children.

You copy the attribute before you start the element node:

Error on line 26 of file:/C:/tmp/col.xsl:
XTDE0410: An attribute node (col) cannot be created after the children of the containing element
Transformation failed: Run-time errors were reported



so move things around to be in this order


		<xsl:copy>		 			 	
<!-- That's the idea, but it doesn't work ... -->

		 	<xsl:apply-templates
select="@*[not(name()='@col')]"/>
'')]"/>
		<xsl:attribute name="col">
			 <xsl:value-of select="$colCount"/>
		</xsl:attribute>




<xsl:apply-templates select="node()[not(key('keyHidden',name()) != '')]"/>


note that not(name()='@col' never does anything as the name is never the string '@col' I expect you mean current()/@col, or something.


also don't do

	<xsl:variable name="colCount">
			<xsl:value-of select="@col - count(col/*[@hide =
1])"/>
		</xsl:variable>
		

do

	<xsl:variable name="colCount" select="@col - count(col/*[@hide =
1])"/>
		

as it's less to type, and a lot more efficient making colCount the number 8 rather than a result tree fragment consisting of a document node with a child text node with string value the serialisation of 8 as a decimal string.

David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________



Current Thread