[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Re: Filtering with multiple templates

Subject: Re: Re: Re: Filtering with multiple templates
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Tue, 11 Nov 2003 07:33:29 +0100
xsl multiple filters
> I made some progress on this merge matter. Thanks!
>
> However, we don't know how many results we need to
> merge. It depends on user's selection. So, we need to
> dynamically generate the merge script you suggested
> based on the user's selection.
>
> There might just two(v1 and v2). But it may have more
> than two. So, I'm trying to generate a XSLT
> dynamically to handle this merge by using a java
> program.

Probably you could do without generating a new stylesheet.

If you could gather all merges into a single node-set and pass it as
parameter to the transformation, then you can process all the merges in this
single transformation.

For example, this transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:ext="http://exslt.org/common"
 exclude-result-prefixes="ext">

 <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:param  name="pMerges">
    <Member name="x">
       <Member name="x" _pos="6"/>
    </Member>
    <Member name="x">
       <Member name="y" _pos="3"/>
    </Member>
    <Member name="x">
       <Member name="z" _pos="4"/>
    </Member>
  </xsl:param>

  <xsl:variable name="vMerges"
       select="document('')/*/xsl:param[@name='pMerges']"/>

  <xsl:template match="/">
    <xsl:variable name="vrtfSrtMerges">
      <xsl:for-each select="$vMerges/*">
        <xsl:sort select="Member/@_pos" data-type="number"/>
        <xsl:copy>
          <xsl:copy-of select="@*[not(name()='_pos')]"/>
          <xsl:copy-of select="node()"/>
        </xsl:copy>
      </xsl:for-each>
    </xsl:variable>

    <xsl:call-template name="merge">
      <xsl:with-param name="pMerges"
      select="ext:node-set($vrtfSrtMerges)/*"/>
    </xsl:call-template>

  </xsl:template>

  <xsl:template name="merge">
    <xsl:param name="pMerges" select="/.."/>

    <xsl:for-each select="$pMerges[1]">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:for-each select="$pMerges/*">
        <xsl:copy>
          <xsl:copy-of select="@*[not(name() = '_pos')]"/>
          <xsl:copy-of select="node()"/>
        </xsl:copy>
      </xsl:for-each>
    </xsl:copy>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>


when applied on any source xml (not used), will produce the wanted result:

<Member xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common" name="x">
   <Member name="y"/>
   <Member name="z"/>
   <Member name="x"/>
</Member>


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.