Before the end of 2017 the board will be down for a brief period of time for an upgrade.
Past experience says less than 30 minutes but I can't predict the future.
Also, there is a high probability that the forum will move to a different host, but that will not happen in 2017.
Thanks,
Doug

[Solved] Wikipedia Search "Series"

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

[Solved] Wikipedia Search "Series"

Postby Alex Ivanovich » Sun Dec 25, 2016 10:35 pm

to run this search on Wikipedia, it is necessary that the code is deleted a part of the series title

Example (I cataloged the series in this way):
Julia - Series Regular
Julia - Almanac of Yellow
Julia - Special

the part to be deleted, and the one that starts from the empty space and - (in red)
the result should be this
Julia (for all three series, and other series (using this procedure))

attention, the elimination of the title, it must take place after the "empty space" and "-"
this is because I have the series with this title
Dylan Dog - Series Regular

if you do what I have written above, it becomes
Dylan <---- mistaken

instead it must be so
Dylan Dog <---- correct

This is the code to be modified

Code: Select all

<xsl:value-of select="translate(series, ' ', '_')"/>



complete code

Code: Select all

 <!-- Wikipedia Search Links -->
         <xsl:variable name="series">
            <xsl:value-of select="translate(series, ' ', '_')"/>
          </xsl:variable> 
        <xsl:text> | </xsl:text>
      <TR CLASS="fieldrow">
            <TD CLASS="fieldvalue" WIDTH="100%" bgcolor="white" COLSPAN="2">
              <A HREF="http://it.wikipedia.org/wiki/{$series}"><img class="index_image" src="WikipediaIT.png" border="0" width="50"/>
          <!--       Cerca su Wikipedia (italiano) -->
              </A>               
            </TD>
         <xsl:text> | </xsl:text>
            <TD CLASS="fieldvalue" WIDTH="100%" bgcolor="white" COLSPAN="2">
              <A HREF="http://en.wikipedia.org/wiki/{$series}">
                Cerca su Wikipedia (inglese)
              </A>               
            </TD>
        </TR> 
      <!-- Wikipedia Search Links -->


Merry Christmas to all the forums ;)
Last edited by Alex Ivanovich on Mon Dec 26, 2016 9:58 am, edited 3 times in total.

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

Re: Wikipedia Search "Series"

Postby LotsOCds » Mon Dec 26, 2016 5:39 am

Alex Ivanovich wrote:This is the code to be modified

Code: Select all

<xsl:value-of select="translate(series, ' ', '_')"/>

You need to use the substring-before() function.

Code: Select all

<xsl:value-of select="translate(substring-before(series, ' -'), ' ', '_')"/>
(It should work but I cannot test this code because I am not near my CAT computer.)
Cheers,
Dave

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

Re: Wikipedia Search "Series"

Postby Alex Ivanovich » Mon Dec 26, 2016 8:35 am

it works perfectly :)

ps: Can you explain how the code works, to understand :roll:

thank you Dave ;)

wishes for a Merry Christmas and Happy New Year :)

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

Re: Wikipedia Search "Series"

Postby LotsOCds » Mon Dec 26, 2016 9:41 am

From https://www.w3.org/TR/xpath/
Function: string substring-before(string, string)

The substring-before function returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string. For example, substring-before("1999/04/01","/") returns 1999.
Function: string translate(string, string, string)

The translate function returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string. For example, translate("bar","abc","ABC") returns the string BAr. If there is a character in the second argument string with no character at a corresponding position in the third argument string (because the second argument string is longer than the third argument string), then occurrences of that character in the first argument string are removed. For example, translate("--aaa--","abc-","ABC") returns "AAA". If a character occurs more than once in the second argument string, then the first occurrence determines the replacement character. If the third argument string is longer than the second argument string, then excess characters are ignored.


Code: Select all

translate(substring-before(series, ' -') , ' ', '_')

substring-before(series, ' -') will return the substring of series starting at the beginning up to the space hyphen characters. If series="Dylan Dog - Series Regular" then substring-before(series, ' -') returns "Dylan Dog".

The translate() function, as you wrote it, replaces spaces with the underscore character. Since it's input is "Dylan Dog" it will return "Dylan_Dog"
Cheers,
Dave

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

Re: Wikipedia Search "Series"

Postby Alex Ivanovich » Mon Dec 26, 2016 9:56 am

Codice: Seleziona tutto
translate(substring-before(series, ' -') , ' ', '_')

Code: Select all

substring-before(series, ' -') will return the substring of series starting at the beginning up to the space hyphen characters. If series="Dylan Dog - Series Regular" then substring-before(series, ' -') returns "Dylan Dog".

The translate() function, as you wrote it, replaces spaces with the underscore character. Since it's input is "Dylan Dog" it will return "Dylan_Dog"


interesting explanation ;)

if i understand so well the code is structured so

translate( , ' ', '_')

substring-before(series, ' -')



thank you again master :)


Return to “Using BookCAT”

Who is online

Users browsing this forum: No registered users and 1 guest