Skip to content

Instantly share code, notes, and snippets.

@terrywbrady
Last active September 19, 2022 17:25
Show Gist options
  • Save terrywbrady/a27e80bbcdeaed899bbd to your computer and use it in GitHub Desktop.
Save terrywbrady/a27e80bbcdeaed899bbd to your computer and use it in GitHub Desktop.
Schema.org microtags in XMLUI
<xsl:template match="dim:field" mode="itemDetailView-DIM">
<tr>
<xsl:attribute name="class">
<xsl:text>ds-table-row </xsl:text>
<xsl:if test="(position() div 2 mod 2 = 0)">even </xsl:if>
<xsl:if test="(position() div 2 mod 2 = 1)">odd </xsl:if>
</xsl:attribute>
<td>
<xsl:value-of select="./@mdschema"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="./@element"/>
<xsl:if test="./@qualifier">
<xsl:text>.</xsl:text>
<xsl:value-of select="./@qualifier"/>
</xsl:if>
</td>
<td>
<xsl:choose>
<xsl:when test="(@element='contributor' and @qualifier='author') or (@element='creator')">
<span itemscope="" itemtype="http://schema.org/Person" itemprop="author">
<span class="gu-full-display" itemprop="name">
<xsl:copy-of select="./node()"/>
</span>
</span>
</xsl:when>
<xsl:when test="@element='publisher'">
<span itemscope="" itemtype="http://schema.org/Organization" itemprop="publisher">
<span class="gu-full-display" itemprop="name">
<xsl:copy-of select="./node()"/>
</span>
</span>
</xsl:when>
<xsl:otherwise>
<span class="gu-full-display">
<xsl:choose>
<xsl:when test="@element='title'">
<xsl:attribute name="itemprop">name</xsl:attribute>
</xsl:when>
<xsl:when test="@element='date' and @qualifier='created'">
<xsl:attribute name="itemprop">dateCreated</xsl:attribute>
</xsl:when>
<xsl:when test="@element='subject'">
<xsl:attribute name="itemprop">about</xsl:attribute>
</xsl:when>
<xsl:when test="@element='identifier' and @qualifier='uri'">
<xsl:attribute name="itemprop">url</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:copy-of select="./node()"/>
</span>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="./@authority and ./@confidence">
<xsl:call-template name="authorityConfidenceIcon">
<xsl:with-param name="confidence" select="./@confidence"/>
</xsl:call-template>
</xsl:if>
</td>
<td><xsl:value-of select="./@language"/></td>
</tr>
</xsl:template>
<xsl:template name="itemSummaryRow">
<xsl:param name="clause"/>
<xsl:param name="phase"/>
<xsl:param name="title"/>
<xsl:param name="title-hover"/>
<xsl:param name="unavail"/>
<xsl:param name="sep"/>
<xsl:param name="itemtype"/>
<xsl:param name="itemprop"/>
<xsl:param name="nodes" select="/bogus"/>
<xsl:variable name="spanval">
<xsl:choose>
<xsl:when test="$nodes">
<xsl:for-each select="$nodes">
<xsl:apply-templates select="." mode="special-row">
<xsl:with-param name="title-hover" select="$title-hover"/>
</xsl:apply-templates>
<xsl:if test="position() != last()">
<xsl:copy-of select="$sep"/>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$unavail"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="ds-table-row {$phase}">
<td><span class="bold"><xsl:copy-of select="$title"/>: </span></td>
<td>
<xsl:choose>
<xsl:when test="$itemtype">
<span>
<xsl:attribute name="itemscope"/>
<xsl:attribute name="itemtype">
<xsl:value-of select="$itemtype"/>
</xsl:attribute>
<span class="gu-summary-display">
<xsl:attribute name="itemprop">name</xsl:attribute>
<xsl:value-of select="$spanval"/>
</span>
</span>
</xsl:when>
<xsl:otherwise>
<span class="gu-summary-display">
<xsl:if test="$itemprop">
<xsl:attribute name="itemprop">
<xsl:value-of select="$itemprop"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$spanval"/>
</span>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<xsl:call-template name="itemSummaryView-DIM-fields">
<xsl:with-param name="clause" select="($clause + 1)"/>
<xsl:with-param name="phase">
<xsl:choose>
<xsl:when test="$phase = 'even'">
<xsl:text>odd</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>even</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

Assuming that you are running on a TEST instance that is not publicly available, use the following procedure to test

Questions

  • What are the most imporant features to tag?
  • How should the tagging vary by content type (article, image, etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment