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

Re: copy of specific elements

Subject: Re: copy of specific elements
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Mon, 18 Aug 2008 17:35:40 +0200 (CEST)
Re:  copy of specific elements
henry human wrote:

> Here is the sample. 

  You still don't show the associated output.  I guess your problem is
like the following.  From:

       <e type="author" id="a1"/>
       <e type="author" id="a2"/>
       <e type="author" id="a3"/>
       <e type="section" id="s1"/>
       <e type="section" id="s1"/>

you want to walk through the first two e[@type eq 'author'] (because
there are two e[@type ew 'section']).  You can try the following:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

       <xsl:output indent="yes"/>

       <xsl:template match="/">
             <xsl:variable name="count" select="
                 count(root/e[@type eq 'section'])"/>
             <xsl:apply-templates select="
                 root/e[@type eq 'author'][position() le $count]"/>

       <xsl:template match="e">
          <xsl:element name="{ @id }"/>


  The output is:

    $ saxon hhuman.xml hhuman.xsl
    <?xml version="1.0" encoding="UTF-8"?>

  If the e elements are not all child of the same parent element, use
parenthesis, in order to have the correct position(), like for instance

    (root//e[@type eq 'author'])[position() le $count]



Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

Current Thread


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.
First Name
Last Name
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.