<commit_before><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:ddw="http://datadryad.org/api/v1/widgets/display"
    xmlns:csv="http://apache.org/cocoon/csv/1.0"
    xmlns:math="http://exslt.org/math"
    exclude-result-prefixes="xhtml ddw math csv"
    version="1.0">
    
    <!-- 
        TODO: split out per-mime-type templates into xsl:include's
    -->
    
    <xsl:output method="html" indent="yes"/>
    <xsl:preserve-space elements="script"/>
    
    <xsl:variable name="mime-type" select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.format']"/>
    <xsl:variable name="extent"    select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.extent']"/>
    <xsl:variable name="source"    select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.source']"/>
    
    <xsl:param name="doi"/>
    <xsl:param name="object-url"/> <!-- DataOne-MN url for bitstream -->
    
    <!-- 
        Lookup table for template to call for handling input based on mime-type
    -->
    <ddw:templates>
        <ddw:template mime-type="text/plain"          >text-plain</ddw:template>
        <ddw:template mime-type="text/csv"            >text-csv</ddw:template>
        <ddw:template mime-type="application/pdf"     >application-pdf</ddw:template>
        <ddw:template mime-type="application/x-python">code</ddw:template>
        <ddw:template mime-type="image/png"           >image-native</ddw:template>
        <ddw:template mime-type="image/jpeg"          >image-native</ddw:template>
    </ddw:templates>
    
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="not(document('')/xsl:stylesheet/ddw:templates/ddw:template[@mime-type=$mime-type])">
                <xsl:call-template name="unsupported"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="template-name" select="document('')/xsl:stylesheet/ddw:templates/ddw:template[@mime-type=$mime-type]"/>
                <xsl:choose>
                    <xsl:when test="$template-name = 'text-plain'"      ><xsl:call-template name="text-plain"        /></xsl:when>
                    <xsl:when test="$template-name = 'text-csv'"        ><xsl:call-template name="text-csv"          /></xsl:when>
                    <xsl:when test="$template-name = 'application-pdf'" ><xsl:call-template name="application-pdf"   /></xsl:when>
                    <xsl:when test="$template-name = 'code'"            ><xsl:call-template name="code"              /></xsl:when>
                    <xsl:when test="$template-name = 'image-native'"    ><xsl:call-template name="image-native"      /></xsl:when>
                    <xsl:otherwise>
                        <xsl:message terminate="yes">Misconfigured lookup or missing named template.</xsl:message>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- suppress this element from result document -->
    <xsl:template match="xhtml:head"/>
    
    <!-- -->
    <xsl:template name="unsupported">
        <html>
            <head></head>
            <body>
                <div>This content type '<xsl:value-of select="$mime-type"/>' is unsupported. 
                    Please visit the <a href="http://dx.doi.org/{$doi}">Dryad site</a>
                    to view the data or download the data from this widget.
                </div>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="text-plain">
        <html>
            <head></head>
            <body>
<pre>
<xsl:value-of select="/xhtml:xhtml/xhtml:body"/>
</pre>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="application-pdf">
        <html>
            <head>
                <script src="http://mozilla.github.io/pdf.js/build/pdf.js"></script>
                <script><![CDATA[
'use strict';]]>
var url = '<xsl:value-of select="$object-url"/>';<![CDATA[
PDFJS.getDocument(url).then(function(pdf) {
  pdf.getPage(1).then(function(page) {
    var scale = 1.5;
    var viewport = page.getViewport(scale);
    var canvas = document.getElementById('PDFcanvas');
    var context = canvas.getContext('2d');
    canvas.height = viewport.height;
    canvas.width = viewport.width;
    var renderContext = {
      canvasContext: context,
      viewport: viewport
    };
    page.render(renderContext);
  });
});
]]>
                </script><commit_msg>fixed parameter name for dataFileBitsream.xsl to match sitemap generator<commit_after><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:ddw="http://datadryad.org/api/v1/widgets/display"
    xmlns:csv="http://apache.org/cocoon/csv/1.0"
    xmlns:math="http://exslt.org/math"
    exclude-result-prefixes="xhtml ddw math csv"
    version="1.0">
    
    <!-- 
        TODO: split out per-mime-type templates into xsl:include's
    -->
    
    <xsl:output method="html" indent="yes"/>
    <xsl:preserve-space elements="script"/>
    
    <xsl:variable name="mime-type" select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.format']"/>
    <xsl:variable name="extent"    select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.extent']"/>
    <xsl:variable name="source"    select="/xhtml:xhtml/xhtml:head/xhtml:meta[@property='dc.source']"/>
    
    <xsl:param name="doi"/>
    <xsl:param name="bitstream"/> <!-- DataOne-MN url for bitstream -->
    
    <!-- 
        Lookup table for template to call for handling input based on mime-type
    -->
    <ddw:templates>
        <ddw:template mime-type="text/plain"          >text-plain</ddw:template>
        <ddw:template mime-type="text/csv"            >text-csv</ddw:template>
        <ddw:template mime-type="application/pdf"     >application-pdf</ddw:template>
        <ddw:template mime-type="application/x-python">code</ddw:template>
        <ddw:template mime-type="image/png"           >image-native</ddw:template>
        <ddw:template mime-type="image/jpeg"          >image-native</ddw:template>
    </ddw:templates>
    
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="not(document('')/xsl:stylesheet/ddw:templates/ddw:template[@mime-type=$mime-type])">
                <xsl:call-template name="unsupported"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:variable name="template-name" select="document('')/xsl:stylesheet/ddw:templates/ddw:template[@mime-type=$mime-type]"/>
                <xsl:choose>
                    <xsl:when test="$template-name = 'text-plain'"      ><xsl:call-template name="text-plain"        /></xsl:when>
                    <xsl:when test="$template-name = 'text-csv'"        ><xsl:call-template name="text-csv"          /></xsl:when>
                    <xsl:when test="$template-name = 'application-pdf'" ><xsl:call-template name="application-pdf"   /></xsl:when>
                    <xsl:when test="$template-name = 'code'"            ><xsl:call-template name="code"              /></xsl:when>
                    <xsl:when test="$template-name = 'image-native'"    ><xsl:call-template name="image-native"      /></xsl:when>
                    <xsl:otherwise>
                        <xsl:message terminate="yes">Misconfigured lookup or missing named template.</xsl:message>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- suppress this element from result document -->
    <xsl:template match="xhtml:head"/>
    
    <!-- -->
    <xsl:template name="unsupported">
        <html>
            <head></head>
            <body>
                <div>This content type '<xsl:value-of select="$mime-type"/>' is unsupported. 
                    Please visit the <a href="http://dx.doi.org/{$doi}">Dryad site</a>
                    to view the data or download the data from this widget.
                </div>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="text-plain">
        <html>
            <head></head>
            <body>
<pre>
<xsl:value-of select="/xhtml:xhtml/xhtml:body"/>
</pre>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template name="application-pdf">
        <html>
            <head>
                <script src="http://mozilla.github.io/pdf.js/build/pdf.js"></script>
                <script><![CDATA[
'use strict';]]>
var url = '<xsl:value-of select="$bitstream"/>';<![CDATA[
PDFJS.getDocument(url).then(function(pdf) {
  pdf.getPage(1).then(function(page) {
    var scale = 1.5;
    var viewport = page.getViewport(scale);
    var canvas = document.getElementById('PDFcanvas');
    var context = canvas.getContext('2d');
    canvas.height = viewport.height;
    canvas.width = viewport.width;
    var renderContext = {
      canvasContext: context,
      viewport: viewport
    };
    page.render(renderContext);
  });
});
]]>
                </script>
{'fraction_non_alphanumeric': 0.1727680034968856, 'fraction_numerical': 0.004808217681127745, 'mean_word_length': 2.2662384011420413, 'pattern_counts': {'":': 0, '<': 191, '<?xml version=': 2, '>': 191, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6822384', 'n_tokens_mistral': 3036, 'n_tokens_neox': 2762, 'n_words': 451}