Hey Henry,

I took only a slightly different approach (still using the node-set
extension) to solve my problem:


<xsl:variable name="cat_temp">
        <xsl:for-each select="$category_blog" >
                <xsl:element name="category">
                        <xsl:attribute name="name"><xsl:value-of select="@name" 
/></xsl:attribute>
                        <xsl:attribute name="type"><xsl:value-of select="@type" 
/></xsl:attribute>
                        <xsl:attribute name="mode">blog</xsl:attribute>
                </xsl:element>
        </xsl:for-each>
        <xsl:for-each select="$category_podcast" >
                <xsl:element name="category">
                        <xsl:attribute name="name"><xsl:value-of select="@name" 
/></xsl:attribute>
                        <xsl:attribute name="type"><xsl:value-of select="@type" 
/></xsl:attribute>
                        <xsl:attribute name="mode">podcast</xsl:attribute>
                </xsl:element>
        </xsl:for-each>
</xsl:variable>

<xsl:variable name="category_defs" select="exsl:node-set($cat_temp)/category" />


It wasn't important that the nodes be actually copied, so much as the
data be collected into a common set. Later I just sort these and the
results are interleaved exactly as I wanted.


Thanks,

Ray

On Mon, 2007-08-13 at 09:17 -0400, Henry Zongaro wrote:

> 
> Hi, Raymond. 
> 
> Raymond <[EMAIL PROTECTED]> wrote on 2007-08-10 12:55:19 PM:
> > I'm wondering if there is anyway to achieve something like this:
> > 
> > <xsl:variable name="category_defs">
> >    <xsl:for-each select="$category_defs1" >
> >       <xsl:copy>
> >          <xsl:attribute name="mode">1</xsl:attribute>
> >       </xsl:copy>
> >    </xsl:for-each>
> >    <xsl:for-each select="$category_defs2" >
> >       <xsl:copy>
> >          <xsl:attribute name="mode">2</xsl:attribute>
> >       </xsl:copy>
> >    </xsl:for-each>
> > </xsl:variable>
> > 
> 
> > Essentially, what I'm trying to do is merge the two result sets into
> > one interleaved set, while maintaining the distinction between the 
> > two by applying a "mode" attribute.
> 
> According to section 11.1 of XSLT 1.0,[1] "An operation is permitted
> on a result tree fragment only if that operation would be permitted on
> a string (the operation on the string may involve first converting the
> string to a number or boolean)."  So in standard XSLT, you can't do
> it.  To be able to access the nodes in a result tree fragment and
> directly manipulate them, you need to use the node-set extension
> function.  Something like the following should work: 
> 
> <xsl:variable name="category_defs" 
>         xmlns:exslt="http://exslt.org/common";>
>   <xsl:for-each select="exslt:node-set($category_defs1)/node()" >
>      <xsl:copy>
>         <xsl:attribute name="mode">1</xsl:attribute>
>      </xsl:copy>
>   </xsl:for-each>
>   <xsl:for-each select="exslt:node-set($category_defs2)/node()" >
>      <xsl:copy>
>         <xsl:attribute name="mode">2</xsl:attribute>
>      </xsl:copy>
>   </xsl:for-each>
> </xsl:variable> 
> 
> I hope that helps. 
> 
> Thanks,
> 
> Henry 
> [1] http://www.w3.org/TR/xslt#section-Result-Tree-Fragments
> ------------------------------------------------------------------
> Henry Zongaro      XSLT Processors Development
> IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
> mailto:[EMAIL PROTECTED] 

Raymond Auge <[EMAIL PROTECTED]>
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.


Reply via email to