/usr/share/tellico/amazon2tellico.xsl is in tellico-data 3.1.2-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | <?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://periapsis.org/tellico/"
xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2011-08-01"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!--
===================================================================
Tellico XSLT file - used for importing Amazon Web Services data.
Copyright (C) 2004-2009 Robby Stephenson <robby@periapsis.org>
This XSLT stylesheet is designed to be used with the 'Tellico'
application, which can be found at http://tellico-project.org
===================================================================
-->
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
doctype-public="-//Robby Stephenson/DTD Tellico V11.0//EN"
doctype-system="http://periapsis.org/tellico/dtd/v11/tellico.dtd"/>
<!-- need to figure out what type of collection -->
<xsl:variable name="args" select="//aws:OperationRequest/aws:Arguments"/>
<xsl:variable name="tmp">
<xsl:choose>
<!-- SearchIndex is mode, unless doing ISBN or UPC search -->
<xsl:when test="$args/aws:Argument[@Name='SearchIndex']">
<xsl:value-of select="$args/aws:Argument[@Name='SearchIndex']/@Value"/>
</xsl:when>
<!-- only happens for books -->
<xsl:when test="$args/aws:Argument[@Name='Operation']/@Value='ItemLookup'">
<xsl:text>Books</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- France might have DVD instead of Video -->
<xsl:variable name="mode">
<xsl:choose>
<xsl:when test="$tmp='DVD'">
<xsl:text>Video</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tmp"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- for lower-casing -->
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<!-- disable default behavior -->
<xsl:template match="text()|@*"></xsl:template>
<xsl:template match="/">
<tellico syntaxVersion="11">
<collection title="Amazon Import">
<xsl:attribute name="type">
<xsl:choose>
<xsl:when test="$mode='Books'">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:when test="$mode='Video'">
<xsl:text>3</xsl:text>
</xsl:when>
<!-- also can be pop-music-de -->
<xsl:when test="$mode='Music'">
<xsl:text>4</xsl:text>
</xsl:when>
<xsl:when test="$mode='VideoGames'">
<xsl:text>11</xsl:text>
</xsl:when>
<xsl:when test="$mode='Toys'">
<xsl:text>13</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:attribute>
<fields>
<field name="_default"/>
<field flags="0" title="Amazon Link" category="General" format="4" type="7" name="amazon" i18n="true"/>
<!-- the amazon importer will actually download the images and ignore these fields -->
<field flags="0" title="Small Image" category="Images" format="4" type="7" name="small-image"/>
<field flags="0" title="Medium Image" category="Images" format="4" type="7" name="medium-image"/>
<field flags="0" title="Large Image" category="Images" format="4" type="7" name="large-image"/>
</fields>
<!-- results for board games need to be filtered -->
<xsl:if test="$mode != 'Toys'">
<xsl:for-each select="//aws:Items/aws:Item">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:if>
<xsl:if test="$mode = 'Toys'">
<!-- only grab items in the board games category -->
<xsl:for-each select="//aws:Items/aws:Item[.//aws:BrowseNode/aws:Name='Board Games' or
.//aws:BrowseNode/aws:BrowseNodeId='166225011']">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:if>
</collection>
</tellico>
</xsl:template>
<xsl:template match="aws:Item">
<entry>
<amazon>
<xsl:value-of select="aws:DetailPageURL"/>
</amazon>
<small-image>
<xsl:value-of select="aws:SmallImage/aws:URL"/>
</small-image>
<medium-image>
<xsl:value-of select="aws:MediumImage/aws:URL"/>
</medium-image>
<large-image>
<xsl:value-of select="aws:LargeImage/aws:URL"/>
</large-image>
<xsl:choose>
<xsl:when test="$mode='Books'">
<comments>
<xsl:value-of select="aws:EditorialReviews/aws:EditorialReview/aws:Content"/>
</comments>
<keywords i18n="true">
<xsl:for-each select="aws:BrowseNodes/aws:BrowseNode">
<keyword>
<xsl:call-template name="nodes">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</keyword>
</xsl:for-each>
</keywords>
</xsl:when>
<xsl:when test="$mode='Music'">
<comments>
<xsl:value-of select="aws:EditorialReviews/aws:EditorialReview[1]/aws:Content"/>
</comments>
<tracks>
<!-- too hard to know which artist goes with which track, just grab first -->
<xsl:variable name="artist" select="aws:ItemAttributes/aws:Artist[1]"/>
<xsl:for-each select="aws:Tracks//aws:Track">
<track>
<xsl:value-of select="."/>
<xsl:text>::</xsl:text>
<!-- too hard to know which artist goes with which track, just grab first -->
<xsl:value-of select="$artist"/>
</track>
</xsl:for-each>
</tracks>
<!-- these get cleaned up within Tellico itself -->
<genres i18n="true">
<xsl:for-each select="aws:BrowseNodes/aws:BrowseNode">
<genre>
<xsl:call-template name="nodes">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</genre>
</xsl:for-each>
</genres>
</xsl:when>
<xsl:when test="$mode='Video'">
<plot>
<xsl:value-of select="aws:EditorialReviews/aws:EditorialReview[1]/aws:Content"/>
</plot>
<!-- these get cleaned up within Tellico itself -->
<genres i18n="true">
<xsl:for-each select="aws:BrowseNodes/aws:BrowseNode">
<genre>
<xsl:call-template name="nodes">
<xsl:with-param name="node" select="."/>
</xsl:call-template>
</genre>
</xsl:for-each>
</genres>
</xsl:when>
<xsl:when test="$mode='VideoGames'">
<description>
<xsl:value-of select="aws:EditorialReviews/aws:EditorialReview[1]/aws:Content"/>
</description>
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="aws:ItemAttributes"/>
</entry>
</xsl:template>
<xsl:template match="aws:ItemAttributes">
<title>
<xsl:value-of select="aws:Title"/>
</title>
<languages>
<xsl:for-each select="aws:Languages/aws:Language[not(aws:Name=preceding-sibling::aws:Language/aws:Name)]">
<language>
<xsl:value-of select="aws:Name"/>
</language>
</xsl:for-each>
</languages>
<xsl:choose>
<!-- book collection stuff -->
<xsl:when test="$mode='Books'">
<authors>
<xsl:for-each select="aws:Author">
<author>
<xsl:value-of select="."/>
</author>
</xsl:for-each>
</authors>
<isbn>
<!-- the EAN is the isbn-13 value for books -->
<xsl:choose>
<xsl:when test="aws:ISBN">
<xsl:value-of select="aws:ISBN"/>
</xsl:when>
<xsl:when test="aws:EAN">
<xsl:value-of select="aws:EAN"/>
</xsl:when>
</xsl:choose>
</isbn>
<publisher>
<xsl:value-of select="aws:Publisher"/>
</publisher>
<editors>
<xsl:for-each select="aws:Creator[@Role='Editor']">
<editor>
<xsl:value-of select="."/>
</editor>
</xsl:for-each>
</editors>
<binding i18n="true">
<xsl:choose>
<xsl:when test="aws:Binding='Hardcover'">
<xsl:text>Hardback</xsl:text>
</xsl:when>
<xsl:when test="contains(aws:Binding, 'Paperback')">
<xsl:text>Paperback</xsl:text>
</xsl:when>
<!-- specifically for France -->
<xsl:when test="aws:Binding='Broché' or aws:Binding='Poche'">
<xsl:text>Souple</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="aws:Binding"/>
</xsl:otherwise>
</xsl:choose>
</binding>
<pub_year>
<xsl:call-template name="year">
<xsl:with-param name="value" select="aws:PublicationDate"/>
</xsl:call-template>
</pub_year>
<edition>
<xsl:value-of select="aws:Edition"/>
</edition>
<pages>
<xsl:value-of select="aws:NumberOfPages"/>
</pages>
</xsl:when>
<!-- music collection stuff -->
<xsl:when test="$mode='Music'">
<artists>
<xsl:for-each select="aws:Artist">
<artist>
<xsl:value-of select="."/>
</artist>
</xsl:for-each>
<!-- only add composers if no artist -->
<xsl:if test="not(aws:Artist)">
<xsl:for-each select="aws:Creator[@Role='Composer']">
<artist>
<xsl:value-of select="."/>
</artist>
</xsl:for-each>
</xsl:if>
</artists>
<year>
<xsl:call-template name="year">
<xsl:with-param name="value" select="aws:ReleaseDate"/>
</xsl:call-template>
</year>
<labels>
<label>
<xsl:value-of select="aws:Label"/>
</label>
</labels>
<medium i18n="true">
<xsl:variable name="medium" select="aws:Binding"/>
<xsl:choose>
<xsl:when test="$medium='Audio CD'">
<xsl:text>Compact Disc</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:comment>
<xsl:value-of select="$medium"/>
</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</medium>
</xsl:when>
<!-- video collection stuff -->
<xsl:when test="$mode='Video'">
<directors>
<xsl:for-each select="aws:Director">
<director>
<xsl:value-of select="."/>
</director>
</xsl:for-each>
</directors>
<casts>
<!-- special case for french, there might be more actors than aws:Actor elements -->
<xsl:for-each select="aws:Creator[@Role='Acteur']">
<!-- cast is a 2-column table -->
<cast>
<column>
<xsl:value-of select="."/>
</column>
</cast>
</xsl:for-each>
<!-- assume only add actor if no creators -->
<xsl:if test="not(aws:Creator[@Role='Acteur'])">
<xsl:for-each select="aws:Actor">
<!-- cast is a 2-column table -->
<cast>
<column>
<xsl:value-of select="."/>
</column>
</cast>
</xsl:for-each>
</xsl:if>
</casts>
<writers>
<xsl:for-each select="aws:Creator[@Role='Writer']">
<writer>
<xsl:value-of select="."/>
</writer>
</xsl:for-each>
</writers>
<year>
<xsl:call-template name="year">
<xsl:with-param name="value" select="aws:TheatricalReleaseDate"/>
</xsl:call-template>
</year>
<medium i18n="true">
<xsl:variable name="medium" select="aws:ProductGroup"/>
<xsl:choose>
<xsl:when test="$medium='Video'">
<xsl:text>VHS</xsl:text>
</xsl:when>
<xsl:when test="contains(translate($medium,$lcletters,$ucletters),'blu-ray')">
<xsl:text>Blu-ray</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$medium"/>
</xsl:otherwise>
</xsl:choose>
</medium>
<color i18n="true">
<xsl:choose>
<xsl:when test="aws:Format[.='Black & White']">
<xsl:text>Black & White</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Color</xsl:text>
</xsl:otherwise>
</xsl:choose>
</color>
<aspect-ratios>
<xsl:for-each select="aws:AspectRatio">
<aspect-ratio>
<xsl:value-of select="."/>
</aspect-ratio>
</xsl:for-each>
</aspect-ratios>
<xsl:if test="aws:Format[.='Widescreen']">
<widescreen>
<xsl:text>true</xsl:text>
</widescreen>
</xsl:if>
<xsl:if test="aws:Format[.='NTSC']">
<format i18n="true">
<xsl:text>NTSC</xsl:text>
</format>
</xsl:if>
<xsl:if test="aws:Format[.='PAL']">
<format i18n="true">
<xsl:text>PAL</xsl:text>
</format>
</xsl:if>
<xsl:if test="aws:Format[.='SECAM']">
<format i18n="true">
<xsl:text>SECAM</xsl:text>
</format>
</xsl:if>
<languages>
<xsl:for-each select="aws:Languages/aws:Language[not(aws:Name=preceding-sibling::aws:Language/aws:Name)]">
<language>
<xsl:value-of select="aws:Name"/>
</language>
</xsl:for-each>
</languages>
<audio-tracks>
<xsl:choose>
<xsl:when test="aws:Languages/aws:Language/aws:AudioFormat[starts-with(.,'Dolby')]">
<audio-track>
<xsl:value-of select="aws:Languages/aws:Language/aws:AudioFormat[starts-with(.,'Dolby')][1]"/>
</audio-track>
</xsl:when>
<xsl:when test="aws:Format[starts-with(.,'Dolby')]">
<audio-track>
<xsl:value-of select="aws:Format[starts-with(.,'Dolby')][1]"/>
</audio-track>
</xsl:when>
</xsl:choose>
<xsl:if test="aws:Languages/aws:Language/aws:AudioFormat[starts-with(.,'DTS')]">
<audio-track>
<xsl:value-of select="aws:Languages/aws:Language/aws:AudioFormat[starts-with(.,'DTS')][1]"/>
</audio-track>
</xsl:if>
</audio-tracks>
<certification i18n="true">
<xsl:variable name="mpaa" select="aws:AudienceRating"/>
<xsl:choose>
<xsl:when test="starts-with($mpaa, 'PG-13')">
<xsl:text>PG-13 (USA)</xsl:text>
</xsl:when>
<xsl:when test="starts-with($mpaa, 'PG')">
<xsl:text>PG (USA)</xsl:text>
</xsl:when>
<xsl:when test="starts-with($mpaa, 'R')">
<xsl:text>R (USA)</xsl:text>
</xsl:when>
<xsl:when test="starts-with($mpaa, 'G')">
<xsl:text>G (USA)</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:comment>
<xsl:value-of select="$mpaa"/>
</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</certification>
<studios>
<studio>
<xsl:value-of select="aws:Studio"/>
</studio>
</studios>
<xsl:if test="aws:RegionCode">
<region i18n="true">
<xsl:value-of select="concat('Region ', aws:RegionCode)"/>
</region>
</xsl:if>
<xsl:if test="aws:RunningTime[@Units='minutes']">
<running-time>
<xsl:value-of select="aws:RunningTime[@Units='minutes']"/>
</running-time>
</xsl:if>
</xsl:when>
<!-- video game collection stuff -->
<xsl:when test="$mode='VideoGames'">
<publisher>
<xsl:value-of select="aws:Publisher"/>
</publisher>
<!-- assume year is last four characters of ReleaseDate -->
<year>
<xsl:call-template name="year">
<xsl:with-param name="value" select="aws:ReleaseDate"/>
</xsl:call-template>
</year>
<!-- assume that the only time there are multiple platforms is when it's for multiple versions of windows -->
<platform i18n="true">
<xsl:call-template name="platform">
<xsl:with-param name="value" select="aws:Platform"/>
</xsl:call-template>
</platform>
<genres i18n="true">
<xsl:for-each select="aws:Feature[starts-with(., 'Genre:')]">
<genre>
<xsl:value-of select="substring(., 7)"/> <!-- ends with a space -->
</genre>
</xsl:for-each>
</genres>
<certification i18n="true">
<xsl:choose>
<xsl:when test="aws:ESRBAgeRating = 'Rating Pending'">
<xsl:text>Pending</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="aws:ESRBAgeRating"/>
</xsl:otherwise>
</xsl:choose>
</certification>
</xsl:when>
<xsl:when test="$mode='Toys'">
<publishers>
<publisher>
<xsl:value-of select="(aws:Label|aws:Brand|aws:Publisher|aws:Manufacturer)[1]"/>
</publisher>
</publishers>
<description>
<xsl:value-of select="../aws:EditorialReviews/aws:EditorialReview[1]/aws:Content"/>
<xsl:for-each select="aws:Feature">
<xsl:value-of select="."/>
<!-- if the last character is not punctuation, add a period -->
<xsl:if test="not(contains('.!?,/', substring(., string-length(.))))">
<xsl:text>.</xsl:text>
</xsl:if>
<xsl:text> </xsl:text>
</xsl:for-each>
</description>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="nodes">
<xsl:param name="node"/>
<xsl:variable name="firstNode" select="$node/aws:Name"/>
<xsl:variable name="tailNodes">
<xsl:choose>
<xsl:when test="$node/aws:Ancestors/aws:BrowseNode[1]/aws:Name">
<xsl:call-template name="nodes">
<xsl:with-param name="node" select="$node/aws:Ancestors/aws:BrowseNode[1]"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($firstNode)">
<xsl:choose>
<xsl:when test="string-length($tailNodes)">
<xsl:value-of select="concat($tailNodes, '/', $firstNode)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$firstNode"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="string-length($tailNodes)">
<xsl:value-of select="$tailNodes"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="year">
<xsl:param name="value"/>
<xsl:variable name="numbers">
<xsl:value-of select="translate($value, translate($value, '0123456789', ''), '')"/>
</xsl:variable>
<!-- assume that Amazon always encodes the date with the 4-digit year first -->
<xsl:value-of select="substring($numbers, 0, 5)"/>
</xsl:template>
<xsl:template name="platform">
<xsl:param name="value"/>
<xsl:variable name="lcvalue">
<xsl:value-of select="translate($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($lcvalue, '360')">
<xsl:text>Xbox 360</xsl:text>
</xsl:when>
<xsl:when test="starts-with($lcvalue, 'x')">
<xsl:text>Xbox</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="contains($lcvalue, 'wii')">
<xsl:text>Nintendo Wii</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="$lcvalue = 'sony psp'">
<xsl:text>PSP</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="starts-with($lcvalue, 'windows')">
<xsl:text>Windows</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="starts-with($lcvalue, 'mac')">
<xsl:text>Mac OS</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="$lcvalue = 'sega dreamcast'">
<xsl:text>Dreamcast</xsl:text> <!-- as defined in the default field -->
</xsl:when>
<xsl:when test="starts-with($lcvalue, 'playstation')">
<xsl:choose>
<xsl:when test="contains($lcvalue, '3')">
<xsl:text>PlayStation3</xsl:text>
</xsl:when>
<xsl:when test="contains($lcvalue, '2')">
<xsl:text>PlayStation2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|