summaryrefslogtreecommitdiffstats
path: root/misc/xml/format.xsl
blob: 92abcbbe28860408993a1d96249db931100092a0 (plain)
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
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="register|field">
    <xsl:if test="local-name() = 'field'">
      <xsl:value-of select="preceding-sibling::text()"/>
    </xsl:if>

    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*"/>
      <xsl:for-each select="view">
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
        </xsl:copy>
      </xsl:for-each>
      <xsl:apply-templates select="field"/>
      <xsl:if test="field">
        <xsl:value-of select="text()[last()]"/>
      </xsl:if>
    </xsl:element>
  </xsl:template>

  <xsl:template match="//model/bank|//model/transform|//model/enum|//model/unit">
    <xsl:value-of select="preceding-sibling::text()"/>
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="model">
    <xsl:copy>
      <xsl:apply-templates select="bank"/>
      <xsl:apply-templates select="transform"/>
      <xsl:apply-templates select="enum"/>
      <xsl:apply-templates select="unit"/>
      <xsl:value-of select="text()[last()]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>