Link to home
Start Free TrialLog in
Avatar of B_Dorsey
B_Dorsey

asked on

XSL - For-Each Show first, hide others

<xsl:for-each select="//results/errorpages/page[@error = $errorID]">
 <xsl:variable name="errorpageid" select="."/>
 <xsl:if test="count(//results/page[@id = $errorpageid and @error = $errorID]) > 0">
   <div class="row{position() mod 2}">
   <xsl:variable name="cHider"><xsl:value-of select="generate-id()"/></xsl:variable>
   <xsl:for-each select="//results/page[@id = $errorpageid and @error = $errorID]">

   'RIGHT HERE I WANNA DISPLAY THE TITLE OF THE FIRST ONE AND ALL INCLUDING THE FIRST ONE BE IN A HIDDEN DIV TAG. BELOW IT.. BASICALLY A <XSL:IF TEST="POSITION() = 1">SHOW TITLE</XSL:IF>
   'HERE IS WHERE I AM STUMPED, I WANT 1 <DIV STYLE="DISPLAY:NONE"> ... THE REST OF THE ITEMS... THEN </DIV>
   </xsl:for-each>
  </div>
 </xsl:if>
</xsl:for-each>

Sorry about the caps, I would go back but I will jsut appologize cause Im too lazy to re-write it :)

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

well, well, I am not sure I understand the question completely

If you want to add a div tag around all the items of the for-each, just do it outside the loop
Can you be a bit more specific in your question
show a small piece of the XML and the result yo want

thanks

Geert
maybe this is what you are looking for
I have an example outside the context of your example, but simplified

<?xml version="1.0" encoding="UTF-8"?>
<example>
    <item>
        <title>AAA</title>
        <note>A1</note>
    </item>
    <item>
        <title>BBB</title>
        <note>B1</note>
    </item>
    <item>
        <title>CCC</title>
        <note>C1</note>
    </item>
</example>

and the stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="example">
        <div style="display:none;">
            <title><xsl:value-of select="item[1]/title"/></title>
            <xsl:for-each select="item">
                <p><xsl:value-of select="note"/></p>
            </xsl:for-each>
        </div>
    </xsl:template>
</xsl:stylesheet>


ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of B_Dorsey
B_Dorsey

ASKER

To the rescue again... thanks again.