-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathunique-metas.xsl
More file actions
39 lines (39 loc) · 1.62 KB
/
unique-metas.xsl
File metadata and controls
39 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<!--
* SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com
* SPDX-License-Identifier: MIT
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eo="https://www.eolang.org" id="unique-metas" version="2.0">
<xsl:import href="/org/eolang/funcs/lineno.xsl"/>
<xsl:import href="/org/eolang/funcs/defect-context.xsl"/>
<xsl:output encoding="UTF-8"/>
<xsl:variable name="unique" select="('version', 'architect', 'home', 'package', 'syntax')"/>
<xsl:variable name="metas" select="/object/metas/meta"/>
<xsl:variable name="heads" select="/object/metas/meta/head"/>
<xsl:template match="/">
<defects>
<xsl:for-each select="$unique">
<xsl:variable name="head" select="current()"/>
<xsl:if test="count($heads[text() = $head])>1">
<xsl:element name="defect">
<xsl:variable name="line" select="eo:lineno($metas[head = $head][2]/@line)"/>
<xsl:attribute name="line">
<xsl:value-of select="$line"/>
</xsl:attribute>
<xsl:if test="$line = '0'">
<xsl:attribute name="context">
<xsl:value-of select="eo:defect-context(.)"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="severity">
<xsl:text>error</xsl:text>
</xsl:attribute>
<xsl:text>There are more than one "+</xsl:text>
<xsl:value-of select="$head"/>
<xsl:text>" meta specified</xsl:text>
</xsl:element>
</xsl:if>
</xsl:for-each>
</defects>
</xsl:template>
</xsl:stylesheet>