Skip to content

Commit

Permalink
add page-ensure-textequiv-conf.xsl
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Dec 4, 2023
1 parent 630fd07 commit cbc3234
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions page-ensure-textequiv-conf.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pc="http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" extension-element-prefixes="exslt">
<xsl:output omit-xml-declaration="no" indent="yes" method="xml" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="pc:Unicode"/>
<xsl:template match="//pc:TextEquiv">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="not(@conf)">
<xsl:attribute name="conf">
<xsl:choose>
<xsl:when test="../*/pc:TextEquiv/@conf">
<xsl:value-of select="sum(../*/pc:TextEquiv/@conf) div count(../*/pc:TextEquiv)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="1.0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()" name="identity">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

0 comments on commit cbc3234

Please sign in to comment.