Re: [xsl] copy of specific elements

Subject: Re: [xsl] copy of specific elements
From: henry human <henry_human@xxxxxxxx>
Date: Mon, 18 Aug 2008 15:21:28 +0200 (CEST)
I tried with the FAQ and i understood it so as i am
witing the code snippet bellow!
Here is the sample. 
In this loop it should turns 2 times because there are
2 sections and than displays the 
author names in:
author[1] and 
author[2]
(this is the array: [@type='author'][position()])
But It does not work properly.
I am thankful for your help

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

xmlns:wpc="com.sap.nw.wpc.km.service.linkmanager.XsltHelper">
	<xsl:output method="html"/>
  <xsl:template match="/">

    <html>
<body>
  
 <xsl:variable name="var" 
select="count(document/elements/element[@type='section'])"/>
 <xsl:for-each select="//*[position() &lt;= $var]">
 
 <!--
 <xsl:value-of disable-output-escaping="yes"
select="document/elements/element[@type='author'][position()]"/>
-->
      LOOP:  <xsl:value-of
disable-output-escaping="yes" select="position()"/>

      
      
   </xsl:for-each>
     
     
     


</body>
</html>

  </xsl:template>
</xsl:stylesheet>

--------------------xml file -------------------

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl"
href="text-_ohne-loop.xsl" ?>

<document>

<elements>
        <element type="author"
description="xml.xlbl.author"  size="25"
default="true">
         Author number 1</element>
		<element type="author" description="xml.xlbl.author"
 size="25" default="true">
        Author number 2</element>

        <element type="section"
description="xml.xlbl.author"  size="25"
default="true">
        section 1</element>
        
        <element type="section"
description="xml.xlbl.author"  size="25"
default="true">
        section 2</element>


	</elements>
</document>





--- Florent Georges <lists@xxxxxxxxxxxx> schrieb:

> henry human wrote:
> 
> >   position() doesn't behave as you seem to think
> it
> > does.  What you get
> > means there are in the input tree 6 elements that
> are
> > the first or
> > second child of their parent element.
> > 
> > Could you say how to build this loop correctly ??
> 
>   I suggest looking in the FAQ for position().  It
> should be clearer
> than what I could give you here.
> 
>   For your particular problem, I don't see exactly
> what you want from
> your explanation.  You should post a simple
> (simplified) example of
> input, and the corresponding output you would like
> to have from this
> particular input.  Choose both examples carefully in
> order to make the
> relation between both as clear as possible.
> 
>   Regards,
> 
> --drkm
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>      
>
_____________________________________________________________________________
> 
> Envoyez avec Yahoo! Mail. Une boite mail plus
> intelligente http://mail.yahoo.fr
> 
> 


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verf|gt |ber einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

Current Thread