xsl-list
[Top] [All Lists]

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

2010-11-30 09:32:46

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/*[(_at_)hide =
1])"/>
                </xsl:variable>
                

do

        <xsl:variable name="colCount" select="@col - count(col/*[(_at_)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. ________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>