This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_beta_cnxml.xsl
68 lines (57 loc) · 2.31 KB
/
fix_beta_cnxml.xsl
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<xsl:stylesheet version="1.0"
xmlns="http://cnx.rice.edu/cnxml" xmlns:c="http://cnx.rice.edu/cnxml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="c:para[not(*) and not(text())]">
<xsl:message>empty para delete</xsl:message>
</xsl:template>
<xsl:template match="c:list[not(*) and not(text())]">
<xsl:message>empty list delete</xsl:message>
</xsl:template>
<xsl:template match="*[@id and string(number(substring(@id, 1, 1)))!='NaN']">
<xsl:message>Bad id value: <xsl:value-of select="@id"/></xsl:message>
<xsl:element name="{local-name()}">
<xsl:attribute name="id">id_<xsl:value-of select="@id"/></xsl:attribute>
<xsl:apply-templates select="node()|@*[not(name()='id')]"/>
</xsl:element>
</xsl:template>
<xsl:template match="@draggable" />
<xsl:template match="@hover-placeholder" />
<xsl:template match="@style" />
<xsl:template match="c:document[not(@id)]|
c:section[not(@id)]|
c:para[not(@id) and node()]|
c:figure[not(@id)]|
c:subfigure[not(@id)]|
c:media[not(@id)]|
c:list[not(@id)]|
c:definition[not(@id)]|
c:meaning[not(@id)]|
c:div[not(@id)]">
<xsl:message><xsl:value-of select="local-name()"/></xsl:message>
<xsl:element name="{local-name()}">
<xsl:attribute name="id">
<xsl:value-of select="generate-id(current())"/>
</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="c:title/c:title"/>
<xsl:template match="c:title[c:title]">
<xsl:message>nested titles</xsl:message>
<xsl:element name="title">
<xsl:value-of select="./c:title"/>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="c:caption/c:para">
<xsl:message>para under caption</xsl:message>
<xsl:apply-templates select="node()"/>
</xsl:template>
<xsl:template match="c:newline"/>
</xsl:stylesheet>