[Solved] if length and 0 displays link

Discuss using and your tips/tricks for CATVids
User avatar
Alex Ivanovich
Posts: 307
Joined: Mon Sep 07, 2015 2:24 pm
Location: Russian - Italia

Re: if length and 0 displays link

Post by Alex Ivanovich » Sun Nov 26, 2017 6:54 pm

LotsOCds wrote:There are no hours in the XML representation "30:22"

Remember your code tests for length/@hours='0' so no hours will be shown by <xsl:value-of select="length"/>
:|

I solved the problem of the text :|
but if the value and "0" does not have to be displayed :roll:
the "hour" problem remains :(

Code: Select all

 <xsl:if test="length/@hours='0'">
          <tr>            
            <td class="record_pane_table_fieldname" nowrap=""><xsl:value-of select="/data/fld/video/length/@name"/></td>
            <td class="record_pane_table_fieldvalue">
          
                
             <xsl:choose>
               <xsl:when test="length='0:00'">
	            inserire la durata
				<a href="http://akas.imdb.com/find?q={title}">IMDB</a>
	           </xsl:when>
             </xsl:choose>
			   <xsl:if test="length/@hours='0'">
			     <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>
				 <xsl:value-of select="length/@minutes"/><xsl:text> minuti </xsl:text>
				 <xsl:value-of select="length/@seconds"/><xsl:text> secondi </xsl:text>
			  </xsl:if>
			  </td>
          </tr>
		 </xsl:if> 

User avatar
LotsOCds
Posts: 177
Joined: Thu Aug 20, 2015 4:23 am
Location: California, USA

Re: if length and 0 displays link

Post by LotsOCds » Sun Nov 26, 2017 7:22 pm

Alex Ivanovich wrote:the "hour" problem remains :(
LotsOCds wrote:Remember your code tests for length/@hours='0' so no hours will be shown
I do not understand what you mean by the "hour" problem. Your code tests two times for length/@hours='0' so the there is no display unless hours=0.
Cheers,
Dave

User avatar
Alex Ivanovich
Posts: 307
Joined: Mon Sep 07, 2015 2:24 pm
Location: Russian - Italia

Re: if length and 0 displays link

Post by Alex Ivanovich » Sun Nov 26, 2017 7:35 pm

these are the results of the code :|

02:52:00 -----> empty ????????????????????
00:00:00 -----> inserire la durata IMDB 0 ore 0 minuti 0 secondi - (wrong 0 ore 0 minuti 0 secondi <--not display if 0)
00:30:46 -----> 0 ore 30 minuti 46 secondi (wrong not display 0 ore)

User avatar
LotsOCds
Posts: 177
Joined: Thu Aug 20, 2015 4:23 am
Location: California, USA

Re: if length and 0 displays link

Post by LotsOCds » Sun Nov 26, 2017 8:14 pm

Alex Ivanovich wrote:these are the results of the code :|

02:52:00 -----> empty ????????????????????
That is right because length/@hours='2'. I will say it again:
lotsocds wrote:Your code tests two times for length/@hours='0' so the there is no display unless hours=0.
Hours is not equal to 0 so there is no display.

00:00:00 -----> inserire la durata IMDB 0 ore 0 minuti 0 secondi - (wrong 0 ore 0 minuti 0 secondi <--not display if 0)
You will need to test for length='0:00' (see my first response above) and write the code to make the display the way you want it.

00:30:46 -----> 0 ore 30 minuti 46 secondi (wrong not display 0 ore)
Delete the line of code that prints the hours.

Code: Select all

            ...
            <xsl:if test="length/@hours='0'">
              <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>        <<<<<<<<< Delete this line if you don't want to display 0 ore
             <xsl:value-of select="length/@minutes"/><xsl:text> minuti </xsl:text>
             <xsl:value-of select="length/@seconds"/><xsl:text> secondi </xsl:text>
           </xsl:if>
           ...
Cheers,
Dave

User avatar
Alex Ivanovich
Posts: 307
Joined: Mon Sep 07, 2015 2:24 pm
Location: Russian - Italia

Re: if length and 0 displays link

Post by Alex Ivanovich » Sun Nov 26, 2017 10:22 pm

code completed at 99% :)

result
in red should not be visible

2 ore 52 minuti ore

1 ore ora

inserire la durata IMDB ora

30 minuti 46 secondi ora

the code does not work to transform :| :roll: (and has effects on the text that should not be visible *in red*)

"hour" in "Hours"
or "minutes" in "minute"

this part of code

Code: Select all

<xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
complete code

Code: Select all

<xsl:if test="length/@hours!=''">
		 <!-- <xsl:if test="length/@hours='0'"> -->
          <tr>            
                 <td class="record_pane_table_fieldname" nowrap=""><xsl:value-of select="/data/fld/video/length/@name"/></td>
                 <td class="record_pane_table_fieldvalue">
                    
				<xsl:if test="length/@hours > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
		             <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>
                </xsl:if>
				<xsl:if test="length/@minutes > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
				    <xsl:value-of select="length/@minutes"/><xsl:text> minuti </xsl:text>
					</xsl:if>
                <xsl:if test="length/@seconds > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
                     <xsl:value-of select="length/@seconds"/><xsl:text> secondi </xsl:text>
                </xsl:if>
              <xsl:choose>
               <xsl:when test="length='0:00'">
	            inserire la durata
				<a href="http://akas.imdb.com/find?q={title}">IMDB</a>
	           </xsl:when>
            </xsl:choose>
			 
		 <xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
		
			 </td>
          </tr>
		 </xsl:if> 

User avatar
Alex Ivanovich
Posts: 307
Joined: Mon Sep 07, 2015 2:24 pm
Location: Russian - Italia

Re: if length and 0 displays link

Post by Alex Ivanovich » Tue Nov 28, 2017 9:10 am

:| :(

User avatar
LotsOCds
Posts: 177
Joined: Thu Aug 20, 2015 4:23 am
Location: California, USA

Re: if length and 0 displays link

Post by LotsOCds » Sat Dec 02, 2017 4:01 pm

Alex Ivanovich wrote: in red should not be visible

2 ore 52 minuti ore

inserire la durata IMDB ora

30 minuti 46 secondi ora
Please look at the flow of your code and recheck the logic. You need to rearrange things a little bit. Each of these "ore" are because the code below always runs. It will write either "ore" or "ora" at the end of every line. Always.

Code: Select all

<xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
1 ore ora
This one happens because of this code. @hours =1 so the "ore" is shown. The "ora" comes from the code above.

Code: Select all

            <xsl:if test="length/@hours > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
                   <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>
                </xsl:if>
And please note that while it does no harm, this test will always be met because there will always be a value in "length/@hours".

Code: Select all

<xsl:if test="length/@hours!=''">
Cheers,
Dave

User avatar
LotsOCds
Posts: 177
Joined: Thu Aug 20, 2015 4:23 am
Location: California, USA

Re: if length and 0 displays link

Post by LotsOCds » Sun Dec 03, 2017 2:50 pm

Quick fix. Maybe this does what you are looking for or at least gets you closer. I do not have a computer with me so I cannot test this but from inspection it looks like it should work.

Try replacing the "<xsl:text> ore</xsl:text>" in this line

Code: Select all

                   <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>
with this code:

Code: Select all

<xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
Cheers,
Dave

User avatar
Alex Ivanovich
Posts: 307
Joined: Mon Sep 07, 2015 2:24 pm
Location: Russian - Italia

Re: if length and 0 displays link

Post by Alex Ivanovich » Mon Dec 04, 2017 9:54 am

dave, it does not work :|

results

03:49:00 --> ore 49 minuti (is missing 3)

01:00:00 --> ora (is missing 1)

00:29:00 ---> ora 29 minuti (this should not be seen ora)

complete code

Code: Select all

 <xsl:if test="length/@hours!=''">
		 <!-- <xsl:if test="length/@hours='0'"> -->
          <tr>            
                 <td class="record_pane_table_fieldname" nowrap=""><xsl:value-of select="/data/fld/video/length/@name"/></td>
                 <td class="record_pane_table_fieldvalue">
                    
				
		            <xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
					
					
					
		<xsl:if test="length/@minutes > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
				    <xsl:value-of select="length/@minutes"/><xsl:text> minuti </xsl:text>
					</xsl:if>
                <xsl:if test="length/@seconds > 0"> <!-- se la lunghezza dei secondi ha valore 0 (zero) allora non visualizzare -->
                     <xsl:value-of select="length/@seconds"/><xsl:text> secondi </xsl:text>
                </xsl:if>
              <xsl:choose>
               <xsl:when test="length='0:00'">
	            inserire la durata
				<a href="http://akas.imdb.com/find?q={title}">IMDB</a>
	           </xsl:when>
            </xsl:choose>
			
			  </td>
          </tr>
		 </xsl:if> 

User avatar
LotsOCds
Posts: 177
Joined: Thu Aug 20, 2015 4:23 am
Location: California, USA

Re: if length and 0 displays link

Post by LotsOCds » Mon Dec 04, 2017 3:15 pm

You changed more than I instructed. Please do exactly the following:
LotsOCds wrote:Try replacing the "<xsl:text> ore</xsl:text>" in this line

Code: Select all

                   <xsl:value-of select="length/@hours"/><xsl:text> ore </xsl:text>
with this code:

Code: Select all

<xsl:choose>
            <xsl:when test="length/@hours > 1"><!-- se la lunghezza delle ore ha valore 1 (uno) allora sostituisce ore con ora -->
              ore
            </xsl:when>
            <xsl:otherwise>
              ora
            </xsl:otherwise>
         </xsl:choose>
Replace only the "<xsl:text> ore</xsl:text>" in the line shown.
Cheers,
Dave

Post Reply