2012-05-30 2 views
0

런타임시 XML을 생성하는 전자 상거래 카트가 있습니다. 실제 XML을 스타일링하는 XSL 스타일 시트에 액세스 할 수 있습니다.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> 

답변

1

ASP.NET을 사용하는 경우 표준 ASP.NET XML Control을 사용할 수 있습니다. 페이지로드

아래처럼 당신의 XML 및 XSL 파일을 지정 : 또한 데이터베이스에 XML이없는 파일 만 저장되어 DocumentContent 특성, 즉 사용할 수 있습니다

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

.

example here

+0

템플릿 스킨 파일을 사용하고 있습니다. XML 파일에 대한 데이터 피드를 런타임에 만들 때 찾을 수 없습니다. –

+1

@ sp-1986 죄송합니다, 귀하의 의견을 이해하지 못합니다 ... xml 및 xsl 텍스트가 모두있는 예제 링크를 사용하여 내 대답을 업데이트했습니다. – Cheburek

0

허용 된 대답은 ASP.Net에 사실이지만,하지 Aspdotnetstorefront을 참조하십시오. 질문에서 언급 된 XML 파일은 디버그가 활성화되어 있고 어떤 프로덕션 환경에서도 생성되지 않아야 생성됩니다 (쓰기 충돌로 끝날 것입니다).

XSLT이면의 XML은 런타임에 생성됩니다. includeentityhelper="true"이 (가) 있기 때문에 카테고리 데이터 (및 기타 엔티티 데이터)가 포함됩니다. EntityHelper는 DB 쿼리를 줄이기 위해 범주 (및 기타 엔터티) 데이터를 캐시합니다. 이 http://manual.aspdotnetstorefront.com/p-157-xml-packages.aspx

당신은 또한 XMLPackages의 대부분이 포함에 사용 된 ''노드를 찾을 수 있습니다 :이 외에도 데이터가 필요한 경우 ('SQL 쿼리'에서) 여기에 설명 된 XMLPackage <query> 노드를 사용한다 기본 빌드.

관련 문제