Subject: Re: [xsl] copy of specific elements From: Florent Georges <lists@xxxxxxxxxxxx> Date: Mon, 18 Aug 2008 17:35:40 +0200 (CEST) |
henry human wrote: > Here is the sample. You still don't show the associated output. I guess your problem is like the following. From: <root> <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"/> </root> 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" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="/"> <results> <xsl:variable name="count" select=" count(root/e[@type eq 'section'])"/> <xsl:apply-templates select=" root/e[@type eq 'author'][position() le $count]"/> </results> </xsl:template> <xsl:template match="e"> <xsl:element name="{ @id }"/> </xsl:template> </xsl:stylesheet> The output is: $ saxon hhuman.xml hhuman.xsl <?xml version="1.0" encoding="UTF-8"?> <results> <a1/> <a2/> </results> 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 in: (root//e[@type eq 'author'])[position() le $count] Regards, --drkm _____________________________________________________________________________ Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] copy of specific elements, henry human | Thread | Re: [xsl] copy of specific elements, Norman Gray |
Re: [xsl] flattening and re-orderin, Andrew Welch | Date | Re: [xsl] copy of specific elements, Norman Gray |
Month |