B_Dorsey
asked on
XSL - For-Each Show first, hide others
<xsl:for-each select="//results/errorpag es/page[@e rror = $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-o f select="generate-id()"/></ xsl:variab le>
<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 :)
<xsl:variable name="errorpageid" select="."/>
<xsl:if test="count(//results/page
<div class="row{position() mod 2}">
<xsl:variable name="cHider"><xsl:value-o
<xsl:for-each select="//results/page[@id
'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 :)
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>
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"/></
<xsl:for-each select="item">
<p><xsl:value-of select="note"/></p>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To the rescue again... thanks again.
welcome
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