Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaConchFirstPass display option #507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Source/Resource/displays/MediaConchCSV.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mc="https://mediaarea.net/mediaconch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" extension-element-prefixes="xsi">
<xsl:output encoding="UTF-8" method="text" version="1.0" indent="yes"/>
<xsl:template match="/mc:MediaConch">
<xsl:text>filename</xsl:text>
<xsl:for-each select="mc:media[1]/mc:policy/mc:policy|mc:media[1]/mc:policy/mc:rule|mc:media[1]/mc:rule|mc:media[1]/mc:implementationChecks/mc:check">
<xsl:text>,</xsl:text>
<xsl:choose>
<xsl:when test="local-name()='check'">
<xsl:value-of select="@icid"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>"</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>"</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="mc:media">
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="escapecommas">
<xsl:with-param name="text" select="@ref"/>
</xsl:call-template>
<xsl:for-each select="mc:policy/mc:policy|mc:policy/mc:rule|mc:rule">
<xsl:text>,</xsl:text>
<xsl:value-of select="@outcome"/>
</xsl:for-each>
<xsl:for-each select="mc:implementationChecks/mc:check">
<xsl:text>,</xsl:text>
<xsl:choose>
<xsl:when test="@fail_count = '0'">pass</xsl:when>
<xsl:when test="@fail_count > '0'">fail</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template name="escapecommas">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="$text = ''" >
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:when test="contains($text, ',')">
<xsl:value-of select="substring-before($text,',')"/>
<xsl:text>\,</xsl:text>
<xsl:call-template name="escapecommas">
<xsl:with-param name="text" select="substring-after($text,',')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
43 changes: 43 additions & 0 deletions Source/Resource/displays/MediaConchFirstPass.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mc="https://mediaarea.net/mediaconch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" extension-element-prefixes="xsi">
<xsl:output encoding="UTF-8" method="text" version="1.0" indent="yes"/>
<xsl:template match="/mc:MediaConch">
<xsl:choose>
<xsl:when test="count(mc:media[1]/mc:policy|mc:media[1]/mc:rule)=0">
<xsl:text>This display only supports policy results</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>filename</xsl:text>
<xsl:text>,</xsl:text>
<xsl:text>first passing policy or rule</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:for-each select="mc:media">
<xsl:call-template name="escapecommas">
<xsl:with-param name="text" select="@ref"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:value-of select="mc:policy/mc:policy[@outcome='pass'][1]/@name|mc:policy/mc:rule[@outcome='pass'][1]/@name|mc:policy/mc:rule[@outcome='pass'][1]/@name"/>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="escapecommas">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="$text = ''" >
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:when test="contains($text, ',')">
<xsl:value-of select="substring-before($text,',')"/>
<xsl:text>\,</xsl:text>
<xsl:call-template name="escapecommas">
<xsl:with-param name="text" select="substring-after($text,',')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
68 changes: 68 additions & 0 deletions Source/Resource/displays/MediaConchSimple.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mc="https://mediaarea.net/mediaconch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" extension-element-prefixes="xsi">
<xsl:output encoding="UTF-8" method="text" version="1.0" indent="yes"/>
<xsl:template match="/mc:MediaConch">
<xsl:for-each select="mc:media">
<xsl:if test="position() != '1'">
<xsl:text>&#xa;</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="boolean(mc:rule/@outcome|mc:policy/@outcome)">
<xsl:value-of select="mc:rule/@outcome|mc:policy/@outcome"/>
</xsl:when>
<xsl:when test="boolean(mc:implementationChecks/@fail_count)">
<xsl:choose>
<xsl:when test="sum(mc:implementationChecks/@pass_count) = '0' and sum(mc:implementationChecks/@fail_count) = '0'">N/A</xsl:when>
<xsl:when test="sum(mc:implementationChecks/@fail_count) = '0'">pass</xsl:when>
<xsl:when test="sum(mc:implementationChecks/@fail_count) > '0'">fail</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
<xsl:text>! </xsl:text>
<xsl:value-of select="@ref"/>
<xsl:apply-templates select="mc:implementationChecks"/>
<xsl:apply-templates select="mc:rule|mc:policy"/>
</xsl:for-each>
</xsl:template>
<xsl:template match="mc:implementationChecks">
<xsl:for-each select="mc:check[@fail_count > '0']">
<xsl:text>&#xa;</xsl:text>
<xsl:text> -- </xsl:text>
<xsl:value-of select="@icid"/>
<xsl:for-each select="mc:test[@outcome='fail']">
<xsl:text>&#xa;</xsl:text>
<xsl:text> --</xsl:text>
<xsl:value-of select="substring(' ',1,count(ancestor::*))"/>
<xsl:text>[</xsl:text>
<xsl:value-of select="@outcome"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="@reason"/>
<xsl:text>]</xsl:text>
<xsl:for-each select="mc:value">
<xsl:text>&#xa;</xsl:text>
<xsl:text> --</xsl:text>
<xsl:value-of select="substring(' ',1,count(ancestor::*))"/>
<xsl:text>[</xsl:text>
<xsl:value-of select="@context"/>
<xsl:text> at bytes offset of </xsl:text>
<xsl:value-of select="@offset"/>
<xsl:text>]</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="mc:policy|mc:rule">
<xsl:if test="@outcome!='pass'">
<xsl:text>&#xa;</xsl:text>
<xsl:text> </xsl:text>
<xsl:text> --</xsl:text>
<xsl:value-of select="substring(' ',1,count(ancestor::*))"/>
<xsl:text>[</xsl:text>
<xsl:value-of select="@outcome"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>]</xsl:text>
<xsl:apply-templates select="mc:rule[@outcome!='pass']|mc:policy[@outcome!='pass']"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>