0

実行時にXMLを生成するeコマースカートがあります。実際のXMLのスタイルを設定するXSLスタイルシートにアクセスできます。

メニューに商品カテゴリの画像を表示したいのですが。xslファイル内でクエリを実行して表示できる例はありますか?

カテゴリデータをどこから取得しているのかわかりませんか?

手伝ってくれますか?

<?xml version="1.0" standalone="yes" ?>
    <!-- ###################################################################################################### -->
    <!-- Copyright AspDotNetStorefront.com, 1995-2009. 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. -->
    <!-- ###################################################################################################### -->
    <package version="2.1" displayname="Categories" debug="false" includeentityhelper="true">
    <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="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:template match="/">
    <xsl:element name="ul">
    <xsl:attribute name="class">
    <![CDATA[menuul]]>
    </xsl:attribute>

    <xsl:apply-templates select="/root/EntityHelpers/Category/Entity">
    <xsl:with-param name="prefix" select="''"/>
    </xsl:apply-templates>

    </xsl:element>
    </xsl:template>

    <xsl:template match="Entity">
    <xsl:param name="prefix"></xsl:param>
    <xsl:param name="eName" select="aspdnsf:GetMLValue(Name)" />

    <xsl:choose>
    <xsl:when test="Published=1">

    <li class="menuli">
    <xsl:value-of select="$prefix" />
    <!--<xsl:if test="number(ParentEntityID) != 0">
    <span class="catMark">>></span>�
    </xsl:if>-->
    <a href="{concat('c-',EntityID,'-',SEName,'.aspx')}">
    <xsl:if test="EntityID = $CategoryID or descendant::Entity/EntityID = $CategoryID">
    <xsl:attribute name="class">MenuSelected</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="$eName" disable-output-escaping="yes"/>
    </a>


    <xsl:if test="count(child::Entity)>0">
    <ul class="submenuul">
    <xsl:apply-templates select="Entity">
    <xsl:with-param name="prefix" select="concat($prefix, '��')"/>
    </xsl:apply-templates>
    </ul>
    </xsl:if>
    </li>

    </xsl:when>
    </xsl:choose>

    </xsl:template>

    </xsl:stylesheet>
    </PackageTransform>
    </package>
4

2 に答える 2

1

ASP.NETを使用している場合は、標準のASP.NETを使用できますXML Control

ページの読み込み時に、次のようにxmlファイルとxslファイルを割り当てます。

protected void Page_Load(object sender, EventArgs e)
{
   Xml1.DocumentSource = "~/App_Data/YourXmlFile.xml";
   Xml1.TransformSource = "~/App_Data/YourXslStyleSheetFile.xsl";
}

DocumentContentまた、xmlがファイルではなくデータベースに保存されているプロパティを使用することもできます。

こちらの例をご覧ください

于 2012-05-30T16:41:58.537 に答える
0

受け入れられた答えは、ASP.Net には当てはまりますが、Aspdotnetstorefront には当てはまりません。質問で参照されている XML ファイルは、デバッグが有効になっている場合にのみ生成され、実稼働環境では生成されません (書き込みの競合が発生します)。

XSLT の背後にある XML は、実行時に生成されます。があるため、カテゴリ データ (およびその他のエンティティ データ) が含まれますincludeentityhelper="true"。EntityHelper は、カテゴリ (およびその他のエンティティ) データをキャッシュして、DB クエリを削減します。これに加えてデータが必要な場合は、<query>ここ (「SQL クエリ」の下) に記載されている XMLPackage ノードを使用する必要があります: http://manual.aspdotnetstorefront.com/p-157-xml-packages.aspx

また、デフォルト ビルドに含まれるほとんどの XMLPackages で使用される '' ノードも見つかります。

于 2014-10-28T02:23:43.520 に答える