0
我为运行查询的ASPDOTNETSTOREFRONT创建了一个xml包。该文件然后在创建产品链接的地方创建一个UL。不过,我需要另一个UL来显示类别和产品链接。在XML包中创建产品类别UL?
<ul>Category 1</ul>
<ul>
<li>product 1</li>
</ul>
</ul>
就像上面那样?
这里是我的xml包:
<?xml version="1.0" standalone="yes" ?>
<package version="2.1" displayname="Simple Product" debug="true" includeentityhelper="false">
<!-- ###################################################################################################### -->
<!-- Copyright AspDotNetStorefront.com, 1995-2011. All Rights Reserved. -->
<!-- http://www.aspdotnetstorefront.com -->
<!-- For details on this license please visit the product homepage at the URL above. -->
<!-- THE ABOVE NOTICE MUST REMAIN INTACT. -->
<!-- -->
<!-- ###################################################################################################### -->
<query name="Products" rowElementName="Product">
<sql>
<![CDATA[
WITH Categories (ParentCategoryID, CategoryID, Name, ComputedLevel, Sort) AS
(
SELECT c.ParentCategoryID, c.CategoryID, c.Name, 0 AS ComputedLevel, CAST('\'+c.Name AS NVARCHAR(255))
FROM Category AS c
WHERE ParentCategoryID = 0
AND Deleted=0
AND Published=1
UNION ALL
SELECT c.ParentCategoryID, c.CategoryID, c.Name, ComputedLevel + 1, CAST(s.Sort + '\'+c.Name AS NVARCHAR(255))
FROM Category AS c
INNER JOIN Categories AS s ON c.ParentCategoryID = s.CategoryID
WHERE Deleted=0
AND Published=1
)
SELECT ParentCategoryID, c.CategoryID, Sort, p.ProductID, p.Name, p.SEName
FROM Categories c (NOLOCK)
LEFT JOIN ProductCategory pc (NOLOCK) ON pc.CategoryID = c.CategoryID
JOIN Product p (NOLOCK) ON p.ProductID = pc.ProductID
ORDER BY 3,5
]]>
</sql>
</query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
<xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />
<xsl:param name="XmlPackageName" select="/root/System/XmlPackageName" />
<xsl:param name="SecID">
<xsl:choose>
<xsl:when test="count(/root/QueryString/sectionid) > 0">
<xsl:value-of select="/root/QueryString/sectionid" />
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="CategoryID">
<xsl:choose>
<xsl:when test="/root/System/PageName = 'showmanufacturer.aspx' or /root/System/PageName = 'showsection.aspx' or /root/System/PageName = 'showdistributor.aspx' or /root/System/PageName = 'showvector.aspx' or /root/System/PageName = 'showgenre.aspx'">0</xsl:when>
<xsl:when test="/root/System/PageName = 'showcategory.aspx' and boolean(/root/QueryString/categoryid)">
<xsl:value-of select="/root/QueryString/categoryid"/>
</xsl:when>
<xsl:when test="(/root/System/PageName = 'showcategory.aspx' or /root/System/PageName = 'showproduct.aspx') and boolean(/root/Cookies/LastViewedEntityInstanceID) and /root/Cookies/LastViewedEntityName = 'Category'">
<xsl:value-of select="/root/Cookies/LastViewedEntityInstanceID"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="AncestorID">
<xsl:for-each select="/root/EntityHelpers/Category//Entity[EntityID = $CategoryID]">
<xsl:value-of select="ancestor::*/EntityID"/>
</xsl:for-each>
</xsl:param>
<xsl:param name="ParentID">
<xsl:for-each select="/root/EntityHelpers/Category//Entity[EntityID = $CategoryID]">
<xsl:value-of select="parent::*/EntityID"/>
</xsl:for-each>
</xsl:param>
<xsl:param name="CatID">
<xsl:choose>
<xsl:when test="count(/root/QueryString/categoryid) > 0">
<xsl:value-of select="/root/QueryString/categoryid" />
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:template match="/">
<xsl:element name="ul">
<xsl:attribute name="id">
<![CDATA[accordion3]]>
</xsl:attribute>
<xsl:apply-templates select="/root/Products/Product">
<xsl:with-param name="prefix" select="''"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="Product">
<xsl:param name="prefix"></xsl:param>
<xsl:param name="eName" select="aspdnsf:GetMLValue(Name)" />
<li >
<!--<xsl:value-of select="$prefix" />-->
<xsl:if test="number(ParentEntityID) != 0">
<!--<span class="catMark">>></span> -->
<a href="{concat('p-',ProductID,'-',SEName,'.aspx')}">
<xsl:if test="EntityID = $CategoryID or descendant::Entity/EntityID = $CategoryID">
<xsl:attribute name="style">font-weight:bold</xsl:attribute>
</xsl:if>
<xsl:value-of select="$eName"/>
</a>
</xsl:if>
<xsl:if test="number(ParentEntityID) = 0">
<div class="menuText">
<xsl:value-of select="$eName"/>
</div>
</xsl:if>
<xsl:if test="count(child::Entity)>0">
<ul >
<xsl:apply-templates select="Product">
<xsl:with-param name="prefix" select="concat($prefix, '  ')"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package>
的UL在这里创造:
<xsl:template match="/">
<xsl:element name="ul">
<xsl:attribute name="id">
<![CDATA[accordion3]]>
</xsl:attribute>
<xsl:apply-templates select="/root/Products/Product">
<xsl:with-param name="prefix" select="''"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
这里是该产品创建链接:
<xsl:template match="Product">
<xsl:param name="prefix"></xsl:param>
<xsl:param name="eName" select="aspdnsf:GetMLValue(Name)" />
<li >
<!--<xsl:value-of select="$prefix" />-->
<xsl:if test="number(ParentEntityID) != 0">
<!--<span class="catMark">>></span> -->
<a href="{concat('p-',ProductID,'-',SEName,'.aspx')}">
<xsl:if test="EntityID = $CategoryID or descendant::Entity/EntityID = $CategoryID">
<xsl:attribute name="style">font-weight:bold</xsl:attribute>
</xsl:if>
<xsl:value-of select="$eName"/>
</a>
</xsl:if>
<xsl:if test="number(ParentEntityID) = 0">
<div class="menuText">
<xsl:value-of select="$eName"/>
</div>
</xsl:if>
<xsl:if test="count(child::Entity)>0">
<ul >
<xsl:apply-templates select="Product">
<xsl:with-param name="prefix" select="concat($prefix, '  ')"/>
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
编辑:添加XML提取:
<Product>
<ParentCategoryID>77</ParentCategoryID>
<CategoryID>78</CategoryID>
<Sort>\Box Product\Accessories\AA990F</Sort>
<ProductID>299</ProductID>
<Name>Air compressor</Name>
<SEName>air-compressor</SEName>
</Product>
你能不能请,还提供了一个完整的(但小可能)作为XSLT转换输入的XML文档? – 2011-12-19 15:35:42
在页面末尾添加了一个编辑。它显示XML的摘录.. – PD24 2011-12-19 15:40:28
也似乎只是将每个产品链接添加到每个李,这是错误的,因为我不会能够创建这样的弹出菜单。我需要每个类别都有自己的UL/Li ...知道我的意思? – PD24 2011-12-19 15:43:29