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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML , XSL, ASP

Status
Not open for further replies.

Kazzy

Programmer
Jul 21, 2003
20
US
I am using asp, xml/xsl, access db. I am trying display/desing the layout for a asp page. Currently I have about 20 xml files similar to the one below (see xml file). Each file contains about the same categories (structure of tree is the same for each file.
Food.xml
- Articles (cateogy)
- FQA
- Books
.
.
Health.xml
- Articles
- FQA
- Assestments
.
.
I created a database driven side menu that points to each of the files. The menu is database driven because member must login and a menu will be display accourding to the type of packge/services that they selected during their registration.

SideMenu
Food
Health
.
.

Now, I need to create a submenu from each xml file (using its category-name title for submenu) and display the content for each category as the user clicks on each submenu on the asp page. Again I am very new to xml...

until now I am was able to display the content of one of the categories by filtered the category-name <xsl:if test="category-name = 'Articles'">. However, I think that is the wrong way of doing this. I want to be able to create a generic xsl file where I can click on the submenu and diplay content of category on my asp page. I am not sure if I can do that with xsl or some how manipulating the xml file using asp...any suggestions?

<?xml version="1.0" encoding="iso-8859-1"?>
<CARD>
<DATAAREA>
<folder>
<folder-name>Foods<folder-name>
<category>
<category-name>Articles</category-name>
<category-items>
<item-name>more blah blah..</item-name>
<item-description>blah blah..</item-description>
<item-id>1100</item-id>
</category-items>
<category-items>
<item-name>More More blahh</item-name>
<item-description>xxdhfkas</item-description>
<item-id>1001</item-id>
</category-items>
</category>
<category>
<category-name>FAQ</category-name>
<category-items>
<item-name>blahh blahh.</item-name>
<item-description>more.</item-description>
<item-id>1101</item-id>
</category-items>
<category-items>
<item-name>blahh blahh...</item-name>
<item-description>more..</item-description>
<item-id>1022</item-id>
</category-items>
</category>
</folder>
</DATAAREA>
</CARD>

---- xsl file

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:template match="category">
<html>
<body>
<table class="bodycopy-grey" width="50%" border="1" cellspacing="0" cellpadding="4">
<xsl:if test="category-name = 'Articles'">
<tr>
<td>
<xsl:value-of select="child::category-name"/>
</td>
</tr>

<xsl:for-each select="category-items">
<tr>
<td>
<xsl:variable name="itemid">
<xsl:apply-templates select="child::item-id"/>
</xsl:variable>
<xsl:variable name="itemdescription">
<xsl:apply-templates select="child::item-description"/>
</xsl:variable>
<a title="{$itemdescription}" href="{$itemid}.xml"><xsl:apply-templates select="child::item-name"/></a><xsl:apply-templates select="child::item-description"/></td>

</tr>
</xsl:for-each>
</xsl:if>
</table>

</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top