2017-05-02 57 views
1

當前我正在處理ASPDNSF CMS xml包並嘗試更改Web查詢參數pageize的默認值。 我的pronblm是當我第一次搜索產品,然後頁面大小爲0時,它顯示200產品左右的產品列表,所以我想檢查pagesize是否爲零,然後它應該設置頁面大小pagenumber * 12。如何在xslt(xml包)中重新分配參數值在運行時更改Web查詢參數值

下面是我的代碼網站查詢代碼:

<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:&amp;" 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> 

,我試圖實現的目標從下面的代碼使用前請先:) Harpreet辛格

回答

0

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

謝謝更改默認值應該更改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:&amp;" 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> 
代碼
相關問題