/app/xsl/detect-uf.xsl

https://github.com/WebOrganics/TransFormr · Extensible Stylesheet Language Transformations · 163 lines · 145 code · 18 blank · 0 comment · 0 complexity · f5e6fe521ffdeb7439b26822e0277a52 MD5 · raw file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xhtml="http://www.w3.org/1999/xhtml"
  4. xmlns="http://www.w3.org/1999/xhtml"
  5. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  6. xmlns:dc="http://purl.org/dc/elements/1.1/"
  7. version="1.0"
  8. exclude-result-prefixes="xhtml xs dc">
  9. <xsl:import href="url-encode.xsl" />
  10. <xsl:strip-space elements="*"/>
  11. <xsl:param name="base-uri" select="''"/>
  12. <xsl:param name="doc-title" select="''"/>
  13. <xsl:param name="endpoint-link" select="''"/>
  14. <xsl:param name="base-encoded">
  15. <xsl:call-template name="url-encode">
  16. <xsl:with-param name="str" select="$base-uri"/>
  17. </xsl:call-template>
  18. </xsl:param>
  19. <xsl:param name="transformr" select="''"/>
  20. <xsl:param name="title">
  21. <xsl:choose>
  22. <xsl:when test=".//*[local-name() = 'title']">
  23. <xsl:value-of select=".//*[local-name() = 'title']" />
  24. </xsl:when>
  25. <xsl:otherwise>
  26. <xsl:value-of select="$doc-title" />
  27. </xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:param>
  30. <xsl:param name="hatom" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' hentry ')]"/>
  31. <xsl:param name="hcard" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' vcard ')]"/>
  32. <xsl:param name="hfoaf" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' vcard ') and descendant::*[contains(concat(' ',normalize-space(@rel),' '),' me ')]]"/>
  33. <xsl:param name="geo" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' geo ')]"/>
  34. <xsl:param name="haudio" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' haudio ')]"/>
  35. <xsl:param name="hreview" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' hreview ')]"/>
  36. <xsl:param name="vevent" select="descendant::*[contains(concat(' ',normalize-space(@class),' '),' vevent ')]"/>
  37. <xsl:param name="rdfa" select="descendant::*/attribute::about|descendant::*/attribute::property"/>
  38. <xsl:param name="xfn" select="descendant::*[contains(concat(' ',normalize-space(@profile),' '),' http://gmpg.org/xfn/11 ') or contains(concat(' ',normalize-space(@profile),' '),' http://gmpg.org/xfn/1 ')]"/>
  39. <xsl:param name="microdata" select="//*[@itemscope] and //*[@itemprop]"/>
  40. <xsl:param name="erdf" select="descendant::*[contains(concat(' ',normalize-space(@profile),' '),' http://purl.org/NET/erdf/profile ')]"/>
  41. <xsl:output
  42. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  43. doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" media-type="text/html;charset=utf-8" method="xml" indent="yes"/>
  44. <!-- ============================================================ -->
  45. <xsl:template match="/">
  46. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  47. <head profile="http://gmpg.org/xfn/11">
  48. <title>Microform.at Transformer - <xsl:value-of select="$title"/></title>
  49. <meta name="description" content="Microformats Transformer"/>
  50. <link rel="stylesheet" type="text/css" media="screen" href="{$transformr}stylesheets/user.css" />
  51. <xsl:if test="$hfoaf">
  52. <link type="application/rdf+xml" title="FOAF" href="{$transformr}hfoaf/{$base-uri}" rel="meta" />
  53. </xsl:if>
  54. <xsl:if test="$hatom">
  55. <link type="application/atom+xml" title="Atom" href="{$transformr}hatom/{$base-uri}" rel="alternate"/>
  56. <link type="application/rss+xml" title="RSS2" href="{$transformr}hatom-rss2/{$base-uri}" rel="alternate"/>
  57. <link type="application/rdf+xml" title="SIOC" href="{$transformr}hatom-sioc/{$base-uri}" rel="alternate"/>
  58. </xsl:if>
  59. <link rel="default-slice" type="application/x-hatom" href="{$transformr}detect/#content"/>
  60. </head>
  61. <body>
  62. <div id="fork-me">
  63. <a href="http://wiki.github.com/WebOrganics/TransFormr">
  64. <img src="./images/github.png" alt="Fork me on github" />
  65. </a>
  66. </div>
  67. <div class="butt">
  68. <small>
  69. <a href="http://wiki.github.com/WebOrganics/TransFormr" rel="nofollow">Wiki</a> |
  70. <a href="http://github.com/WebOrganics/TransFormr" rel="nofollow">Source</a> |
  71. <a href="http://github.com/WebOrganics/TransFormr/issues" rel="nofollow">Issues</a>
  72. <xsl:if test="$endpoint-link !=''">
  73. | <a href="{$endpoint-link}" title="Sparql Endpoint">Endpoint</a> |
  74. <a href="{$transformr}?type=dump" title="Store Dumps">Store Dumps</a>
  75. </xsl:if>
  76. </small>
  77. </div>
  78. <div class="heading">
  79. <h1>
  80. <a href="{$transformr}">
  81. <img style="border:0;" src="{$transformr}images/microformat.png" alt="Microformat TransFormer"/>
  82. </a>
  83. </h1>
  84. <q class="subtitle" cite="http://www.hp.com/hpinfo/execteam/speeches/fiorina/04openworld.html">The goal is to transform data into information and information into insight.</q>
  85. </div>
  86. <div class="hslice" id="content">
  87. <h2 class="entry-title">
  88. <xsl:value-of select="$title"/>
  89. </h2>
  90. <div class="entry-content" style="margin-left:0px;text-align:left;">
  91. <p>Source:
  92. <a rel="canonical" href="{$base-uri}">
  93. <xsl:value-of select="$base-uri"/>
  94. </a>
  95. </p>
  96. <p>Detected formats:</p>
  97. <xsl:call-template name="classes"/>
  98. </div>
  99. </div>
  100. <div style="clear:both;margin-top:40px;">
  101. <p>
  102. <strong>
  103. <a href="javascript:history.go(-1);">Go Back</a>
  104. </strong>
  105. </p>
  106. </div>
  107. </body>
  108. </html>
  109. </xsl:template>
  110. <!-- ============================================================ -->
  111. <xsl:template name="classes">
  112. <ul>
  113. <xsl:if test="$hcard">
  114. <li><p>hCard <a href="{$transformr}?type=hcard&amp;url={$base-encoded}">vCard</a> | <a href="{$transformr}?type=hcard-rdf&amp;url={$base-encoded}">RDF</a> | <a href="{$transformr}?type=hcard2qrcode&amp;url={$base-encoded}">QRCode</a></p></li>
  115. </xsl:if>
  116. <xsl:if test="$hatom">
  117. <li><p>hAtom <a href="{$transformr}?type=hatom&amp;url={$base-encoded}">Atom</a> | <a href="{$transformr}?type=hatom-rss2&amp;url={$base-encoded}">RSS2</a> | <a href="{$transformr}?type=hatom-sioc&amp;url={$base-encoded}">RDF</a></p></li>
  118. </xsl:if>
  119. <xsl:if test="$hfoaf">
  120. <li><p>hFoaF <a href="{$transformr}?type=hfoaf&amp;url={$base-encoded}">RDF</a></p></li>
  121. </xsl:if>
  122. <xsl:if test="$geo">
  123. <li><p>Geo <a href="{$transformr}?type=geo&amp;url={$base-encoded}">KML</a></p></li>
  124. </xsl:if>
  125. <xsl:if test="$haudio">
  126. <li><p>hAudio <a href="{$transformr}?type=haudio-rss&amp;url={$base-encoded}">RSS2</a> | <a href="{$transformr}?type=haudio-xspf&amp;url={$base-encoded}">XSPF</a></p></li>
  127. </xsl:if>
  128. <xsl:if test="$hreview">
  129. <li><p>hReview <a href="{$transformr}?type=hreview&amp;url={$base-encoded}">RDF</a></p></li>
  130. </xsl:if>
  131. <xsl:if test="$vevent">
  132. <li><p>hCalendar <a href="{$transformr}?type=hcalendar&amp;url={$base-encoded}">vCal</a> | <a href="{$transformr}?type=hcalendar-rdf&amp;url={$base-encoded}">RDF</a></p></li>
  133. </xsl:if>
  134. <xsl:if test="$rdfa">
  135. <li><p>RDFa <a href="{$transformr}?type=rdfa&amp;url={$base-encoded}">RDF</a></p></li>
  136. </xsl:if>
  137. <xsl:if test="$erdf">
  138. <li><p>eRDF <a href="{$transformr}?type=erdf&amp;url={$base-encoded}">RDF</a></p></li>
  139. </xsl:if>
  140. <xsl:if test="$microdata">
  141. <li><p>Microdata <a href="{$transformr}?type=microdata&amp;url={$base-encoded}">JSON</a></p></li>
  142. </xsl:if>
  143. </ul>
  144. </xsl:template>
  145. </xsl:stylesheet>