xsl-list
[Top] [All Lists]

Re: [xsl] copy of specific elements

2008-08-18 08:22:21
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: [(_at_)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[(_at_)type='section'])"/>
 <xsl:for-each select="//*[position() &lt;= $var]">
 
 <!--
 <xsl:value-of disable-output-escaping="yes"
select="document/elements/element[(_at_)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(_at_)fgeorges(_dot_)org> 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


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--