2013-05-23 1 views
1

사용자가 로그인 한 경우 welcome, [name]을 표시하고, 그렇지 않으면 register link을 표시해야합니다.사용자가 로그인하고 표시 이름을 확인하려고 시도합니다.

aspdotnet storefront를 사용하면 다음은 welcome, (로그인 한 이름없이)과 register link을 모두 표시합니다. 제대로 작동하지 않는 것 같습니다.

<xsl:when test="/root/System/CustomerFirstName!=''"> 
          Welcome, <a href='/account.aspx'><xsl:value-of select="/root/System/CustomerFirstName" disable-output-escaping="yes" /></a> 
          </xsl:when> 
          <xsl:otherwise> 
          <a href='createaccount.aspx?checkout=False' class='register'> 
          Register </a> 
          </xsl:otherwise> 
          </xsl:choose> 

나는 심지어 here에서 30 페이지를 따라 갔지만 아무 소용이 없습니다.

+0

작업중인 AspDotNetStorefront 버전을 지정해주십시오. –

답변

0

당신이 가지고 있어야합니다. 선택 노드로 둘러싸여 있는지 확인하십시오.

  <xsl:choose> 
      <xsl:when test="/root/System/CustomerFirstName!=''"> 
       Welcome, <a href='/account.aspx'> 
       <xsl:value-of select="/root/System/CustomerFirstName" disable-output-escaping="yes" /> 
       </a> 
      </xsl:when> 
      <xsl:otherwise> 
       <a href='createaccount.aspx?checkout=False' class='register'> 
       Register 
       </a> 
      </xsl:otherwise> 
      </xsl:choose> 

단지

<xsl:template match="/"> 

의 시작 후 배치 시도 및 테스트에 도움이 상단에있는 디버그 모드를 켭니다.

1

대신 현재 CustomerIsRegistered 노드를 확인하여 사용자가 현재 로그인되어 있고 등록되어 있는지 확인하는 것이 좋습니다. 값은 'true'또는 'false'가됩니다. 당신이 CustomerFirstName을 확인하려는 경우 문자열 길이는 예를 들어, 0보다 큰 경우

<xsl:choose> 
     <xsl:when test="/root/System/CustomerIsRegistered='true'"> 
     <!--Customer is registered--> 
     <a href="account.aspx"> 
      <xsl:value-of select="concat('Welcome, ',/root/System/CustomerFirstName)"/> 
     </a> 
     </xsl:when> 
     <xsl:otherwise> 
     <!--Customer is not registered--> 
     <a href="createaccount.aspx"> 
      <xsl:attribute name="class">register</xsl:attribute> 
      <xsl:text>Register</xsl:text>    
     </a> 
     </xsl:otherwise> 
    </xsl:choose> 

그때 내가 테스트를 제안 : 여기

은 작업 예입니다

<xsl:when test="string-length(/root/System/CustomerFirstName) &gt; 0>

처럼 Michael이 말했듯이 Choose 요소의 형식이 올바른지 확인하십시오. xslt 마크 업이 잘못된 경우 Xml 패키지를 실행하려고하면 오류가 발생합니다.