Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT products pages Help

Status
Not open for further replies.

kle87

Technical User
Apr 24, 2009
4
GB
Hi everyone,

Hope someone can help me out as im new to this language and am abit confused.

Basically im creating an online store with sections Music and subsections CD, Vinyl & MP3. I have the products displaying but they display on all three pages how do i sort them so they only appear on the correct page. so far the code I have used to sort them is:

<td>


<xsl:for-each select="document('products.xml')/SECTIONS/CATEGORY/SECTION/SUBSECTION[INFO='CD']">
<xsl:sort select="SUB"/>
<P>
<xsl:value-of select="INFO"/><br/>
<xsl:value-of select="SUB"/><br/>
<xsl:value-of select="SUB2"/><br/>
<xsl:value-of select="SUB3"/><br/>
</P>


</xsl:for-each>

</td>

Thank you
 
>I have the products displaying but they display on all three pages how do i sort them so they only appear on the correct page.
What has "sort" to do with displaying on different pages or on all pages? Make not much sense as the description goes.
 
Ok bad choice of word not 'sort' then but i want to display the products so that the cd's appears on the cd page and dvd's on the dvd page etc. If anyone could help id be very greatful!
 
What is typically appeared in SUBSECTION node(s)?
 
This is my XML structure file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stylesheetcopy.xsl"?>


<SECTIONS>
<CATEGORY>
<TITLE>Music</TITLE>
<SECTION>
<NAME>CDs</NAME>

</SECTION>
<SECTION>
<NAME>Vinyl</NAME>


</SECTION>
<SECTION>
<NAME>Cassette</NAME>

</SECTION>
<SECTION>
<NAME>MP3</NAME>

</SECTION>
</CATEGORY>

There is also a products file used to generate the content.

<?xml version="1.0" encoding="UTF-8"?>

<SECTIONS>
<CATEGORY>
<TITLE>Music</TITLE>
<SECTION>
<NAME>CDs</NAME>

<SUBSECTION>
<INFO>CD</INFO>
<SUB>Aerosmith</SUB>
<SUB2>Greatest Hits</SUB2>
<SUB3>Rock</SUB3>
</SUBSECTION>

<SUBSECTION>
<INFO>CD</INFO>
<SUB>Rhianna</SUB>
<SUB2>Good Girl Gone Bad</SUB2>
<SUB3>Pop</SUB3>
</SUBSECTION>

</SECTION>

 
It depends where you call the loop. "Where" means the context node of the you-call-it "structure file". Suppose the context node is SECTION, it would be about this.
><xsl:for-each select="document('products.xml')/SECTIONS/CATEGORY/SECTION/SUBSECTION[INFO='CD']">
[tt]<xsl:for-each select="document('products.xml')/SECTIONS/CATEGORY/SECTION[red][NAME=current()/NAME]/SUBSECTION[/red]">[/tt]
 
Thank you very much problem solved!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top