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 4 of 4

Thread: queries in xml

  1. #1
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default queries in xml

    I tried adding the following to one of my product xml files
    Code:
    <query name="Materials" rowElementName="Material">
            <sql>
                <![CDATA[
                    SELECT Name, '/product/' + CAST(ProductID AS Varchar(4)) + '/' + SEName + '.aspx', CASE WHEN SKU IS NULL OR SKU = '' THEN ImageFilenameOverride ELSE SKU END AS [Image] 
                    FROM Product 
                    WHERE (CAST(ExtensionData AS varchar(50))) LIKE '%.' + RIGHT(@ProductID, CHARINDEX('-', REVERSE(@ProductID))-1) + '.%'
    
                ]]>
            </sql>
            
            <queryparam paramname="@ProductID"       paramtype="request" requestparamname="ProductID"       sqlDataType="int" defvalue="0"  validationpattern="^\d{1,10}$" />
        </query>
    Then, I called the information from it using
    Code:
    <xsl:template match="Material">
                    <xsl:param name="mName" select="/root/Materials/Material/Name"></xsl:param>
                    <tr>
                        <td width="20%" valign="middle" align="left">{$mName}</td></xsl:if>
                    </tr>
    
            </xsl:template>
    The problem is that the page doesn't load at all when I have this. Did I miss something or do I need to change something?

  2. #2
    Orangey is offline Junior Member
    Join Date
    Aug 2010
    Location
    UK
    Posts
    23

    Default

    That </xsl:if> tag looks a bit out of place in your second section of code although I'd have thought the page would give you an error message to tell you that already.

  3. #3
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    The page loads fine when I comment out the Materials query.

    Code:
    <query name="Materials" rowElementName="Material">
            <sql>
                <![CDATA[
                    SELECT Name, '/product/' + CAST(ProductID AS Varchar(4)) + '/' + SEName + '.aspx', CASE WHEN SKU IS NULL OR SKU = '' THEN ImageFilenameOverride ELSE SKU END AS [Image] 
                    FROM Product 
                    WHERE (CAST(ExtensionData AS varchar(50))) LIKE '%.' + RIGHT(@ProductID, CHARINDEX('-', REVERSE(@ProductID))-1) + '.%'
    
                ]]>
            </sql>
            
            <queryparam paramname="@ProductID"       paramtype="request" requestparamname="ProductID"       sqlDataType="int" defvalue="0"  validationpattern="^\d{1,10}$" />
        </query>
    Is there somewhere that I need to define the name "Materials" or "Material"?
    Last edited by chrismartz; 08-17-2010 at 05:43 AM.

  4. #4
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    The problem was with my query. I have figured this one out