Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 3 of 3

Thread: XSL display in HTML

  1. #1
    gmaniac is offline Member
    Join Date
    Jul 2010
    Location
    Missouri
    Posts
    59

    Default XSL display in HTML

    I am trying to do something really simple, but for some reason it is not working for me. What I am trying to do is generate some content on my homepage from an SQL query in a XML Package.

    When I run the SQL query on my database it works perfectly, but when I run it through my package it makes have no values. For instance when I
    Code:
    format-number(price, '###0.00')
    I get NaN displayed on my page. I know that my package is being called correctly and everything because it displays plain text that I put on the page.

    Here is all of my code that I have in the XML Package so far:
    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Entity Simple Product List" debug="false" includeentityhelper="true">
    
    <query name="FPProducts" rowElementName="FrontPageProducts">
    	<sql>
    		<![CDATA[
    			select fpp.name,
    				fpp.bulletlist1,
    				fpp.bulletlist2,
    				pv.price,
    				isnull(pv.saleprice, 0) saleprice,
    				p.sku
    				from frontpageproducts fpp 
    				join productvariant pv on fpp.productid = pv.productid
    				join product p on fpp.productid = p.productid
    			where fpp.position = 'left top product'
    		]]>
    	</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:template match="/">
    	  
    		<xsl:param name="pName"  select="aspdnsf:GetMLValue(name)"></xsl:param>
    		<xsl:param name="sku"  select="aspdnsf:GetMLValue(sku)"></xsl:param>
    		<xsl:param name="site">http://www.archerycenter.com/images/product/icon/</xsl:param>
    		<xsl:param name="jpg">.jpg</xsl:param>
    		<xsl:param name="image"><xsl:value-of select="$site" /><xsl:value-of select="$sku" /><xsl:value-of select="$jpg" /></xsl:param>
    		
    	  	<a href=""><p class="leftProductTitle"><xsl:value-of select="$pName" /></p></a>
    		<a href=""><img src="{$image}" alt="{$pName}" /></a>
    		<ul>
    			<li class="regularPrice">Regular Price: $<xsl:value-of select="format-number(price, '###0.00')" /></li>
    			<li class="salePrice">Sale Price: $<xsl:value-of select="format-number(saleprice, '###0.00')" disable-output-escaping="yes" /></li>
    			<li class="click"><a href="">Click Here<img id="arrow" src="../../images/homeProducts/arrow.gif" /></a></li>
    		</ul>
    	  
          </xsl:template>
    
        </xsl:stylesheet>
      </PackageTransform>
    </package>
    Last edited by gmaniac; 11-10-2011 at 04:01 PM.

  2. #2
    ROBB is offline Senior Member
    Join Date
    Jun 2011
    Location
    United States
    Posts
    107

    Default XML Node

    You need to get within the correct level of your XML tree.
    /root/FPProducts/FrontPageProducts/

    Try the following:

    HTML Code:
    <ul>
    			<li class="regularPrice">Regular Price: $<xsl:value-of select="format-number(/root/FPProducts/FrontPageProducts/price, '###0.00')" /></li>
    			<li class="salePrice">Sale Price: $<xsl:value-of select="format-number(/root/FPProducts/FrontPageProducts/saleprice, '###0.00')" disable-output-escaping="yes" /></li>
    			<li class="click"><a href="">Click Here<img id="arrow" src="../../images/homeProducts/arrow.gif" /></a></li>
    		</ul>
    If that doesn't work, you will want to make sure you values are coming in. Easy way is to dump the results on the front end, and view them through your browser, by setting debug=true, within your package tag.

  3. #3
    gmaniac is offline Member
    Join Date
    Jul 2010
    Location
    Missouri
    Posts
    59

    Default Product Link

    That works perfectly! Thank you! For some reason I forgot all about that and it all makes sense. For anyone that was is doing something similar, here is the end result:

    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Entity Simple Product List" debug="false" includeentityhelper="true">
    
    <query name="FPProducts" rowElementName="FrontPageProducts">
    	<sql>
    		<![CDATA[
    			select fpp.name,
    				fpp.bulletlist1,
    				fpp.bulletlist2,
    				pv.price,
    				isnull(pv.saleprice, 0) saleprice,
    				p.sku,
    				p.sename,
    				p.productid
    				from frontpageproducts fpp 
    				join productvariant pv on fpp.productid = pv.productid
    				join product p on fpp.productid = p.productid
    			where fpp.position = 'left top product'
    		]]>
    	</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:template match="/">
    	  
    		<xsl:param name="link">
    			<xsl:value-of select="/root/System/StoreUrl" />
    			<xsl:value-of select="aspdnsf:ProductLink(/root/FPProducts/FrontPageProducts/productid, sename, 0, '')" disable-output-escaping="yes" />
    		</xsl:param>
    		<xsl:param name="site">http://www.archerycenter.com/images/product/icon/</xsl:param>
    		<xsl:param name="jpg">.jpg</xsl:param>
    		<xsl:param name="image"><xsl:value-of select="$site" /><xsl:value-of select="/root/FPProducts/FrontPageProducts/sku" /><xsl:value-of select="$jpg" /></xsl:param>
    		
    	  	<a href="{$link}"><p class="leftProductTitle"><xsl:value-of select="/root/FPProducts/FrontPageProducts/name" /></p></a>
    		<a href="{$link}"><img src="{$image}" width="75" height="75" alt="{/root/FPProducts/FrontPageProducts/name}" /></a>
    		<ul>
    			<li><xsl:value-of select="/root/FPProducts/FrontPageProducts/bulletlist1" /></li>
    			<li><xsl:value-of select="/root/FPProducts/FrontPageProducts/bulletlist2" /></li>
    			<li class="regularPrice">Regular Price: $<xsl:value-of select="format-number(/root/FPProducts/FrontPageProducts/price, '###0.00')" /></li>
    			<li class="salePrice">Sale Price: $<xsl:value-of select="format-number(/root/FPProducts/FrontPageProducts/saleprice, '###0.00')" disable-output-escaping="yes" /></li>
    			<li class="click"><a href="{$link}">Click Here<img id="arrow" src="../../images/homeProducts/arrow.gif" /></a></li>
    		</ul>
    	  
          </xsl:template>
    
        </xsl:stylesheet>
      </PackageTransform>
    </package>
    Again THANK YOU!