目前我正在研究ASPDNSF CMS xml包并尝试更改Web查询参数pageZise默认值。 我的代词是当我第一次搜索产品然后页面大小为0时它显示产品列表大约200个产品所以我想检查pagesize是否为零然后它应该设置页面大小pagenumber * 12。
以下是我的代码网络查询代码:
<webquery name="searchresults" RetType="xml" timeout="30">
<url><![CDATA[{SmartSearch}&searchTerm={entityName}ID:{entityID}&searchString={searchString}&sortField={sortField}&pageNumber={pageNumber}&pageSize={pageSize}&facetQuery={facet}]]></url>
<querystringreplace replaceTag="{SmartSearch}" replacetype="webconfig" replaceparamname="SmartSearchURL" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{searchString}" replacetype="runtime" replaceparamname="SearchTerm" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{entityID}" replacetype="runtime" replaceparamname="EntityID" defvalue="" validationpattern=""/>
<!-- if the EntityID is missing, then get rid of the whole searchTerm: -->
<querystringreplace replaceTag="searchTerm={entityName}ID:&" replacetype="justreplace" replaceparamname="N/A" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{entityName}" replacetype="runtime" replaceparamname="EntityName" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{pageNumber}" replacetype="request" replaceparamname="pageNumber" defvalue="1" validationpattern=""/>
<querystringreplace replaceTag="{pageSize}" replacetype="request" replaceparamname="pageSize" defvalue="0" validationpattern=""/>
<querystringreplace replaceTag="{facetGroup}" replacetype="request" replaceparamname="facetgroup" defvalue="ManufacturerID" validationpattern=""/>
<querystringreplace replaceTag="{facet}" replacetype="request" replaceparamname="facet" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{sortField}" replacetype="request" replaceparamname="sortField" defvalue="" validationpattern=""/>
</webquery>
我试图通过以下代码实现目标
<xsl:param name="pageSize" select="/root/searchresults/hits/pagesize"></xsl:param>
<xsl:param name="pageSize">
<xsl:choose>
<xsl:when test="string(number(/root/searchresults/hits/pagesize)) != 'NaN'">
<xsl:value-of select="/root/searchresults/hits/pagesize" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="30" />
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="pageNumber">
<xsl:choose>
<xsl:when test="/root/searchresults/hits/page/text()">
<xsl:value-of select="/root/searchresults/hits/page" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0" />
</xsl:otherwise>
</xsl:choose>
</xsl:param>
感谢advence :) Harpreet Singh
答案 0 :(得分:0)
更改默认值应该只是更改webquery中每个querystringreplace的defvalue属性。
基本上是下面的代码
<webquery name="searchresults" RetType="xml" timeout="30">
<url><![CDATA[{SmartSearch}&searchTerm={entityName}ID:{entityID}&searchString={searchString}&sortField={sortField}&pageNumber={pageNumber}&pageSize={pageSize}&facetQuery={facet}]]></url>
<querystringreplace replaceTag="{SmartSearch}" replacetype="webconfig" replaceparamname="SmartSearchURL" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{searchString}" replacetype="runtime" replaceparamname="SearchTerm" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{entityID}" replacetype="runtime" replaceparamname="EntityID" defvalue="" validationpattern=""/>
<!-- if the EntityID is missing, then get rid of the whole searchTerm: -->
<querystringreplace replaceTag="searchTerm={entityName}ID:&" replacetype="justreplace" replaceparamname="N/A" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{entityName}" replacetype="runtime" replaceparamname="EntityName" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{pageNumber}" replacetype="request" replaceparamname="pageNumber" defvalue="0" validationpattern=""/>
<querystringreplace replaceTag="{pageSize}" replacetype="request" replaceparamname="pageSize" defvalue="30" validationpattern=""/>
<querystringreplace replaceTag="{facetGroup}" replacetype="request" replaceparamname="facetgroup" defvalue="ManufacturerID" validationpattern=""/>
<querystringreplace replaceTag="{facet}" replacetype="request" replaceparamname="facet" defvalue="" validationpattern=""/>
<querystringreplace replaceTag="{sortField}" replacetype="request" replaceparamname="sortField" defvalue="" validationpattern=""/>
</webquery>