]>
Pierre Choffet | Git repositories - wdef_tools.git/blob - xslts/canonicalize.xslt
1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!-- canonicalize.xslt - Rewrite a wdef file into its normal form.
3 Copyright (C) 2021 Pierre Choffet
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of version 3 of the GNU General Public License as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 <xsl:stylesheet version=
"1.0" xmlns:
wdef=
"https://purl.choffet.net/wdef"
18 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform">
19 <xsl:output indent=
"yes" method=
"xml" encoding=
"utf-8" />
20 <xsl:strip-space elements=
"*" />
22 <xsl:template match=
"node()|@*">
24 <xsl:apply-templates select=
"node()|@*" />
28 <!-- wdef:element with no child nodes -->
29 <xsl:template match=
"wdef:element[not(*)]" />
31 <!-- Local-only wdef:element with no label -->
32 <xsl:template match=
"wdef:element[substring(@wdef:id, 1, 1) != 'Q' and not(wdef:label)]" />
34 <!-- wdef:property with no child nodes -->
35 <xsl:template match=
"wdef:property[not(*)]" />
37 <!-- wdef:value or wdef:novalue with no temporary @wdef:value and no qualifier -->
38 <xsl:template match=
"wdef:value[substring(@wdef:id, 1, 1) != '?' and not(wdef:qualifier)]" />
39 <xsl:template match=
"wdef:novalue[substring(@wdef:id, 1, 1) != '?' and not(wdef:qualifier)]" />
41 <!-- wdef:qualifier with no wdef:value having temporary @wdef:id -->
42 <xsl:template match=
"wdef:qualifier[wdef:property/wdef:value[substring(@wdef:id, 1, 1) != '?']]" />