etherlab/entries_list.xslt
author Laurent Bessard
Fri, 27 Sep 2013 17:49:40 +0200
changeset 2160 75349c51a34b
parent 2157 a2385e535cf5
child 2161 4bea1d98db46
permissions -rw-r--r--
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
2157
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     1
<xsl:stylesheet version="1.0"
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     2
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     3
    xmlns:ns="entries_list_ns"
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     4
    extension-element-prefixes="ns"
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     5
    exclude-result-prefixes="ns">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     6
  <xsl:param name="min_index"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     7
  <xsl:param name="max_index"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     8
  <xsl:template match="Device">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
     9
    <xsl:apply-templates select="Profile/Dictionary/Objects/Object"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    10
    <xsl:for-each select="RxPdo">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    11
      <xsl:call-template name="pdo_entries">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    12
        <xsl:with-param name="direction" select="'Receive'"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    13
      </xsl:call-template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    14
    </xsl:for-each>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    15
    <xsl:for-each select="TxPdo">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    16
      <xsl:call-template name="pdo_entries">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    17
        <xsl:with-param name="direction" select="'Transmit'"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    18
      </xsl:call-template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    19
    </xsl:for-each>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    20
  </xsl:template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    21
  <xsl:template match="Object">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    22
    <xsl:variable name="index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    23
      <xsl:value-of select="ns:HexDecValue(Index/text())"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    24
    </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    25
    <xsl:variable name="entry_name">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    26
      <xsl:value-of select="ns:EntryName(Name)"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    27
    </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    28
    <xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    29
      <xsl:when test="$index &gt;= $min_index and $index &lt;= $max_index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    30
        <xsl:variable name="datatype_name">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    31
          <xsl:value-of select="Type/text()"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    32
        </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    33
        <xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    34
          <xsl:when test="ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    35
            <xsl:apply-templates select="ancestor::Dictionary/child::DataTypes/DataType[Name/text()=$datatype_name][SubItem]">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    36
              <xsl:with-param name="index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    37
                <xsl:value-of select="$index"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    38
              </xsl:with-param>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    39
              <xsl:with-param name="entry_name">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    40
                <xsl:value-of select="$entry_name"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    41
              </xsl:with-param>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    42
            </xsl:apply-templates>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    43
          </xsl:when>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    44
          <xsl:otherwise>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    45
            <ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    46
              <Index><xsl:value-of select="$index"/></Index>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    47
              <SubIndex><xsl:text>0</xsl:text></SubIndex>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    48
              <Name><xsl:value-of select="$entry_name"/></Name>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    49
              <Type><xsl:value-of select="$datatype_name"/></Type>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    50
              <BitSize><xsl:value-of select="BitSize/text()"/></BitSize>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    51
              <Access><xsl:value-of select="Flags/Access/text()"/></Access>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    52
              <PDOMapping><xsl:value-of select="Flags/PdoMapping/text()"/></PDOMapping>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    53
            </ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    54
          </xsl:otherwise>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    55
        </xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    56
      </xsl:when>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    57
    </xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    58
  </xsl:template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    59
  <xsl:template match="DataType">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    60
    <xsl:param name="index"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    61
    <xsl:param name="entry_name"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    62
    <xsl:for-each select="SubItem">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    63
      <xsl:variable name="subentry_names">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    64
        <xsl:value-of select="DisplayName"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    65
        <Default><xsl:value-of select="Name/text()"/></Default>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    66
      </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    67
      <ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    68
        <Index><xsl:value-of select="$index"/></Index>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    69
        <SubIndex><xsl:value-of select="ns:HexDecValue(SubIdx/text())"/></SubIndex>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    70
        <Name>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    71
          <xsl:value-of select="$entry_name"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    72
          <xsl:text> - </xsl:text>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    73
          <xsl:value-of select="ns:EntryName($subentry_names)"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    74
        </Name>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    75
        <Type><xsl:value-of select="Type/text()"/></Type>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    76
        <BitSize><xsl:value-of select="BitSize/text()"/></BitSize>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    77
        <Access><xsl:value-of select="Flags/Access/text()"/></Access>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    78
        <PDOMapping><xsl:value-of select="Flags/PdoMapping/text()"/></PDOMapping>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    79
      </ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    80
    </xsl:for-each>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    81
  </xsl:template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    82
  <xsl:template name="pdo_entries">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    83
    <xsl:param name="direction"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    84
    <xsl:variable name="pdo_index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    85
      <xsl:value-of select="ns:HexDecValue(Index/text())"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    86
    </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    87
    <xsl:variable name="pdo_name">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    88
      <xsl:value-of select="ns:EntryName(Name)"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    89
    </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    90
    <xsl:for-each select="Entry">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    91
	  <xsl:variable name="index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    92
	    <xsl:value-of select="ns:HexDecValue(Index/text())"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    93
	  </xsl:variable>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    94
	  <xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    95
	    <xsl:when test="$index &gt;= $min_index and $index &lt;= $max_index">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    96
	      <ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    97
            <Index><xsl:value-of select="$index"/></Index>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    98
            <SubIndex><xsl:value-of select="ns:HexDecValue(SubIndex/text())"/></SubIndex>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
    99
            <Name><xsl:value-of select="ns:EntryName(Name)"/></Name>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   100
            <Type><xsl:value-of select="Type/text()"/></Type>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   101
            <BitSize><xsl:value-of select="BitLen/text()"/></BitSize>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   102
            <xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   103
              <xsl:when test="$direction='Transmit'">
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   104
                <Access><xsl:text>ro</xsl:text></Access>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   105
                <PDOMapping><xsl:text>T</xsl:text></PDOMapping>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   106
              </xsl:when>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   107
              <xsl:otherwise>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   108
                <Access><xsl:text>wo</xsl:text></Access>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   109
                <PDOMapping><xsl:text>R</xsl:text></PDOMapping>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   110
              </xsl:otherwise>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   111
            </xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   112
            <PDO>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   113
              <index><xsl:value-of select="$pdo_index"/></index>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   114
              <name><xsl:value-of select="$pdo_name"/></name>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   115
              <type><xsl:value-of select="$direction"/></type>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   116
            </PDO>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   117
          </ns:add_entry>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   118
	    </xsl:when>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   119
	  </xsl:choose>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   120
    </xsl:for-each>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   121
  </xsl:template>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   122
  <xsl:template match="text()"/>
a2385e535cf5 Fixed controllers for working with latest version of xmlclass
Laurent Bessard
parents:
diff changeset
   123
</xsl:stylesheet>