xsl-list
[Top] [All Lists]

Re: [xsl] Processing 2 times the same node without copying content...

2008-08-08 05:33:42
Have you tried this instead ?

<xsl:template match="*[(_at_)id]">
     <a name="{(_at_)id}"/>
     <xsl:copy>
         <xsl:apply-templates select="@*[not(self::id)]|
node()"/>
     </xsl:copy>
</xsl:template>

Xmlizer

On Fri, Aug 8, 2008 at 1:56 PM, Adam Komisarek <akakus(_at_)gmail(_dot_)com> 
wrote:

Hello!

I have following problem: I need to add anchor support for quite big
stylesheets which produce HTML output. So I want to copy @id / add <a
name="{(_at_)id}"> to the result tree. But the problem is I can't do it in
this way:

<!-- HTML ANCHORS -->
<xsl:template match="*[(_at_)id]" priority="2">
       <a name="{(_at_)id}"/>

       <xsl:variable name="content">
               <xsl:copy>
                       <xsl:apply-templates mode="anchor" select="@*|node()"/>
               </xsl:copy>
       </xsl:variable>

       <xsl:apply-templates select="xalan:nodeset($content)"/>
</xsl:template>

<xsl:template match="node()" mode="anchor">
       <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="@*" mode="anchor">
       <xsl:choose>
               <xsl:when test="name()='id'">
               </xsl:when>
               <xsl:otherwise>
                       <xsl:copy>
                               <xsl:apply-templates select="."/>
                       </xsl:copy>
               </xsl:otherwise>
       </xsl:choose>
</xsl:template>

Because as far as I know xalan:nodeset changes input tree and that
stylesheet involve counting on preceding elements (to calculate how
many page breaks appeared). So I can't do that way :(.

Is there anyway to apply-templates on self node and ommiting some
attributes? It would be thing I am looking for... Thanks for help!

Regards,
Adam Komisarek

--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>