OSPFold_to_OSPFnew.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2. <!-- transform old OSPF.xml to new OSPF.xml -->
  3. <!--
  4. usage:
  5. xsltproc this_xsl_file old_xml_file >new_xml_file
  6. -->
  7. <!-- AddressRange -->
  8. <xsl:template match="Area/AddressRange/Address" mode="toAttr">
  9. <xsl:attribute name="address"><xsl:value-of select="." /></xsl:attribute>
  10. </xsl:template>
  11. <xsl:template match="Area/AddressRange/Mask" mode="toAttr">
  12. <xsl:attribute name="mask"><xsl:value-of select="." /></xsl:attribute>
  13. </xsl:template>
  14. <xsl:template match="Area/AddressRange/Status" mode="toAttr">
  15. <xsl:attribute name="status"><xsl:value-of select="." /></xsl:attribute>
  16. </xsl:template>
  17. <xsl:template match="Area/AddressRange/Address|Area/AddressRange/Mask|Area/AddressRange/Status">
  18. </xsl:template>
  19. <!-- BroadcastInterface -->
  20. <xsl:template match="BroadcastInterface/AreaID" mode="toAttr">
  21. <xsl:attribute name="areaID"><xsl:value-of select="." /></xsl:attribute>
  22. </xsl:template>
  23. <xsl:template match="BroadcastInterface/InterfaceOutputCost" mode="toAttr">
  24. <xsl:attribute name="interfaceOutputCost"><xsl:value-of select="." /></xsl:attribute>
  25. </xsl:template>
  26. <xsl:template match="BroadcastInterface/RetransmissionInterval" mode="toAttr">
  27. <xsl:attribute name="retransmissionInterval"><xsl:value-of select="." /></xsl:attribute>
  28. </xsl:template>
  29. <xsl:template match="BroadcastInterface/InterfaceTransmissionDelay" mode="toAttr">
  30. <xsl:attribute name="interfaceTransmissionDelay"><xsl:value-of select="." /></xsl:attribute>
  31. </xsl:template>
  32. <xsl:template match="BroadcastInterface/RouterPriority" mode="toAttr">
  33. <xsl:attribute name="routerPriority"><xsl:value-of select="." /></xsl:attribute>
  34. </xsl:template>
  35. <xsl:template match="BroadcastInterface/HelloInterval" mode="toAttr">
  36. <xsl:attribute name="helloInterval"><xsl:value-of select="." /></xsl:attribute>
  37. </xsl:template>
  38. <xsl:template match="BroadcastInterface/RouterDeadInterval" mode="toAttr">
  39. <xsl:attribute name="routerDeadInterval"><xsl:value-of select="." /></xsl:attribute>
  40. </xsl:template>
  41. <xsl:template match="BroadcastInterface/AuthenticationType" mode="toAttr">
  42. <xsl:attribute name="authenticationType"><xsl:value-of select="." /></xsl:attribute>
  43. </xsl:template>
  44. <xsl:template match="BroadcastInterface/AuthenticationKey" mode="toAttr">
  45. <xsl:attribute name="authenticationKey"><xsl:value-of select="." /></xsl:attribute>
  46. </xsl:template>
  47. <xsl:template match="BroadcastInterface/AreaID|BroadcastInterface/InterfaceOutputCost|BroadcastInterface/RetransmissionInterval|BroadcastInterface/InterfaceTransmissionDelay|BroadcastInterface/RouterPriority|BroadcastInterface/HelloInterval|BroadcastInterface/RouterDeadInterval|BroadcastInterface/AuthenticationType|BroadcastInterface/AuthenticationKey">
  48. </xsl:template>
  49. <!-- PointToPointInterface -->
  50. <xsl:template match="PointToPointInterface/AreaID" mode="toAttr">
  51. <xsl:attribute name="areaID"><xsl:value-of select="." /></xsl:attribute>
  52. </xsl:template>
  53. <xsl:template match="PointToPointInterface/InterfaceOutputCost" mode="toAttr">
  54. <xsl:attribute name="interfaceOutputCost"><xsl:value-of select="." /></xsl:attribute>
  55. </xsl:template>
  56. <xsl:template match="PointToPointInterface/RetransmissionInterval" mode="toAttr">
  57. <xsl:attribute name="retransmissionInterval"><xsl:value-of select="." /></xsl:attribute>
  58. </xsl:template>
  59. <xsl:template match="PointToPointInterface/InterfaceTransmissionDelay" mode="toAttr">
  60. <xsl:attribute name="interfaceTransmissionDelay"><xsl:value-of select="." /></xsl:attribute>
  61. </xsl:template>
  62. <xsl:template match="PointToPointInterface/RouterPriority" mode="toAttr">
  63. <xsl:attribute name="routerPriority"><xsl:value-of select="." /></xsl:attribute>
  64. </xsl:template>
  65. <xsl:template match="PointToPointInterface/HelloInterval" mode="toAttr">
  66. <xsl:attribute name="helloInterval"><xsl:value-of select="." /></xsl:attribute>
  67. </xsl:template>
  68. <xsl:template match="PointToPointInterface/RouterDeadInterval" mode="toAttr">
  69. <xsl:attribute name="routerDeadInterval"><xsl:value-of select="." /></xsl:attribute>
  70. </xsl:template>
  71. <xsl:template match="PointToPointInterface/AuthenticationType" mode="toAttr">
  72. <xsl:attribute name="authenticationType"><xsl:value-of select="." /></xsl:attribute>
  73. </xsl:template>
  74. <xsl:template match="PointToPointInterface/AuthenticationKey" mode="toAttr">
  75. <xsl:attribute name="authenticationKey"><xsl:value-of select="." /></xsl:attribute>
  76. </xsl:template>
  77. <xsl:template match="PointToPointInterface/AreaID|PointToPointInterface/InterfaceOutputCost|PointToPointInterface/RetransmissionInterval|PointToPointInterface/InterfaceTransmissionDelay|PointToPointInterface/RouterPriority|PointToPointInterface/HelloInterval|PointToPointInterface/RouterDeadInterval|PointToPointInterface/AuthenticationType|PointToPointInterface/AuthenticationKey">
  78. </xsl:template>
  79. <!-- PointToMultiPointInterface -->
  80. <xsl:template match="PointToMultiPointInterface/AreaID" mode="toAttr">
  81. <xsl:attribute name="areaID"><xsl:value-of select="." /></xsl:attribute>
  82. </xsl:template>
  83. <xsl:template match="PointToMultiPointInterface/InterfaceOutputCost" mode="toAttr">
  84. <xsl:attribute name="interfaceOutputCost"><xsl:value-of select="." /></xsl:attribute>
  85. </xsl:template>
  86. <xsl:template match="PointToMultiPointInterface/RetransmissionInterval" mode="toAttr">
  87. <xsl:attribute name="retransmissionInterval"><xsl:value-of select="." /></xsl:attribute>
  88. </xsl:template>
  89. <xsl:template match="PointToMultiPointInterface/InterfaceTransmissionDelay" mode="toAttr">
  90. <xsl:attribute name="interfaceTransmissionDelay"><xsl:value-of select="." /></xsl:attribute>
  91. </xsl:template>
  92. <xsl:template match="PointToMultiPointInterface/RouterPriority" mode="toAttr">
  93. <xsl:attribute name="routerPriority"><xsl:value-of select="." /></xsl:attribute>
  94. </xsl:template>
  95. <xsl:template match="PointToMultiPointInterface/HelloInterval" mode="toAttr">
  96. <xsl:attribute name="helloInterval"><xsl:value-of select="." /></xsl:attribute>
  97. </xsl:template>
  98. <xsl:template match="PointToMultiPointInterface/RouterDeadInterval" mode="toAttr">
  99. <xsl:attribute name="routerDeadInterval"><xsl:value-of select="." /></xsl:attribute>
  100. </xsl:template>
  101. <xsl:template match="PointToMultiPointInterface/AuthenticationType" mode="toAttr">
  102. <xsl:attribute name="authenticationType"><xsl:value-of select="." /></xsl:attribute>
  103. </xsl:template>
  104. <xsl:template match="PointToMultiPointInterface/AuthenticationKey" mode="toAttr">
  105. <xsl:attribute name="authenticationKey"><xsl:value-of select="." /></xsl:attribute>
  106. </xsl:template>
  107. <xsl:template match="PointToMultiPointInterface/AreaID|PointToMultiPointInterface/InterfaceOutputCost|PointToMultiPointInterface/RetransmissionInterval|PointToMultiPointInterface/InterfaceTransmissionDelay|PointToMultiPointInterface/RouterPriority|PointToMultiPointInterface/HelloInterval|PointToMultiPointInterface/RouterDeadInterval|PointToMultiPointInterface/AuthenticationType|PointToMultiPointInterface/AuthenticationKey">
  108. </xsl:template>
  109. <!-- NBMAInterface -->
  110. <xsl:template match="NBMAInterface/AreaID" mode="toAttr">
  111. <xsl:attribute name="areaID"><xsl:value-of select="." /></xsl:attribute>
  112. </xsl:template>
  113. <xsl:template match="NBMAInterface/InterfaceOutputCost" mode="toAttr">
  114. <xsl:attribute name="interfaceOutputCost"><xsl:value-of select="." /></xsl:attribute>
  115. </xsl:template>
  116. <xsl:template match="NBMAInterface/RetransmissionInterval" mode="toAttr">
  117. <xsl:attribute name="retransmissionInterval"><xsl:value-of select="." /></xsl:attribute>
  118. </xsl:template>
  119. <xsl:template match="NBMAInterface/InterfaceTransmissionDelay" mode="toAttr">
  120. <xsl:attribute name="interfaceTransmissionDelay"><xsl:value-of select="." /></xsl:attribute>
  121. </xsl:template>
  122. <xsl:template match="NBMAInterface/RouterPriority" mode="toAttr">
  123. <xsl:attribute name="routerPriority"><xsl:value-of select="." /></xsl:attribute>
  124. </xsl:template>
  125. <xsl:template match="NBMAInterface/HelloInterval" mode="toAttr">
  126. <xsl:attribute name="helloInterval"><xsl:value-of select="." /></xsl:attribute>
  127. </xsl:template>
  128. <xsl:template match="NBMAInterface/RouterDeadInterval" mode="toAttr">
  129. <xsl:attribute name="routerDeadInterval"><xsl:value-of select="." /></xsl:attribute>
  130. </xsl:template>
  131. <xsl:template match="NBMAInterface/AuthenticationType" mode="toAttr">
  132. <xsl:attribute name="authenticationType"><xsl:value-of select="." /></xsl:attribute>
  133. </xsl:template>
  134. <xsl:template match="NBMAInterface/AuthenticationKey" mode="toAttr">
  135. <xsl:attribute name="authenticationKey"><xsl:value-of select="." /></xsl:attribute>
  136. </xsl:template>
  137. <xsl:template match="NBMAInterface/AreaID|NBMAInterface/InterfaceOutputCost|NBMAInterface/RetransmissionInterval|NBMAInterface/InterfaceTransmissionDelay|NBMAInterface/RouterPriority|NBMAInterface/HelloInterval|NBMAInterface/RouterDeadInterval|NBMAInterface/AuthenticationType|NBMAInterface/AuthenticationKey">
  138. </xsl:template>
  139. <!-- HostInterface -->
  140. <xsl:template match="HostInterface/AreaID" mode="toAttr">
  141. <xsl:attribute name="areaID"><xsl:value-of select="." /></xsl:attribute>
  142. </xsl:template>
  143. <xsl:template match="HostInterface/AttachedHost" mode="toAttr">
  144. <xsl:attribute name="attachedHost"><xsl:value-of select="." /></xsl:attribute>
  145. </xsl:template>
  146. <xsl:template match="HostInterface/LinkCost" mode="toAttr">
  147. <xsl:attribute name="linkCost"><xsl:value-of select="." /></xsl:attribute>
  148. </xsl:template>
  149. <xsl:template match="HostInterface/AreaID|HostInterface/AttachedHost|HostInterface/LinkCost">
  150. </xsl:template>
  151. <!-- VirtualLink -->
  152. <xsl:template match="VirtualLink/TransitAreaID" mode="toAttr">
  153. <xsl:attribute name="transitAreaID"><xsl:value-of select="." /></xsl:attribute>
  154. </xsl:template>
  155. <xsl:template match="VirtualLink/RetransmissionInterval" mode="toAttr">
  156. <xsl:attribute name="retransmissionInterval"><xsl:value-of select="." /></xsl:attribute>
  157. </xsl:template>
  158. <xsl:template match="VirtualLink/InterfaceTransmissionDelay" mode="toAttr">
  159. <xsl:attribute name="interfaceTransmissionDelay"><xsl:value-of select="." /></xsl:attribute>
  160. </xsl:template>
  161. <xsl:template match="VirtualLink/HelloInterval" mode="toAttr">
  162. <xsl:attribute name="helloInterval"><xsl:value-of select="." /></xsl:attribute>
  163. </xsl:template>
  164. <xsl:template match="VirtualLink/RouterDeadInterval" mode="toAttr">
  165. <xsl:attribute name="routerDeadInterval"><xsl:value-of select="." /></xsl:attribute>
  166. </xsl:template>
  167. <xsl:template match="VirtualLink/AuthenticationType" mode="toAttr">
  168. <xsl:attribute name="authenticationType"><xsl:value-of select="." /></xsl:attribute>
  169. </xsl:template>
  170. <xsl:template match="VirtualLink/AuthenticationKey" mode="toAttr">
  171. <xsl:attribute name="authenticationKey"><xsl:value-of select="." /></xsl:attribute>
  172. </xsl:template>
  173. <xsl:template match="VirtualLink/TransitAreaID|VirtualLink/RetransmissionInterval|VirtualLink/InterfaceTransmissionDelay|VirtualLink/HelloInterval|VirtualLink/RouterDeadInterval|VirtualLink/AuthenticationType|VirtualLink/AuthenticationKey">
  174. </xsl:template>
  175. <!-- ExternalInterface -->
  176. <xsl:template match="ExternalInterface/ForwardingAddress" mode="toAttr">
  177. <xsl:attribute name="forwardingAddress"><xsl:value-of select="." /></xsl:attribute>
  178. </xsl:template>
  179. <xsl:template match="ExternalInterface/ExternalRouteTag" mode="toAttr">
  180. <xsl:attribute name="externalRouteTag"><xsl:value-of select="." /></xsl:attribute>
  181. </xsl:template>
  182. <xsl:template match="ExternalInterface/ForwardingAddress|ExternalInterface/ExternalRouteTag">
  183. </xsl:template>
  184. <xsl:template match="ExternalInterface/AdvertisedExternalNetwork" mode="toAttr">
  185. <xsl:for-each select="Address|Mask">
  186. <xsl:attribute name="advertisedExternalNetwork{name()}"><xsl:value-of select="." /></xsl:attribute>
  187. </xsl:for-each>
  188. </xsl:template>
  189. <xsl:template match="ExternalInterface/AdvertisedExternalNetwork">
  190. <xsl:for-each select="*[local-name()!='Address' and local-name()!='Mask']">
  191. <xsl:apply-templates select="."/>
  192. </xsl:for-each>
  193. </xsl:template>
  194. <xsl:template match="ExternalInterface/ExternalInterfaceOutputParameters" mode="toAttr">
  195. <xsl:for-each select="ExternalInterfaceOutputCost">
  196. <xsl:attribute name="externalInterfaceOutputCost"><xsl:value-of select="." /></xsl:attribute>
  197. </xsl:for-each>
  198. <xsl:for-each select="ExternalInterfaceOutputType">
  199. <xsl:attribute name="externalInterfaceOutputType"><xsl:value-of select="." /></xsl:attribute>
  200. </xsl:for-each>
  201. </xsl:template>
  202. <xsl:template match="ExternalInterface/ExternalInterfaceOutputParameters">
  203. <xsl:for-each select="*[local-name()!='ExternalInterfaceOutputType' and local-name()!='ExternalInterfaceOutputCost']">
  204. <xsl:apply-templates select="."/>
  205. </xsl:for-each>
  206. </xsl:template>
  207. <!-- RFC1583Compatible -->
  208. <xsl:template match="Router/RFC1583Compatible" mode="toAttr">
  209. <xsl:attribute name="RFC1583Compatible">true</xsl:attribute>
  210. </xsl:template>
  211. <xsl:template match="Router/RFC1583Compatible">
  212. </xsl:template>
  213. <xsl:template match="Router">
  214. <xsl:copy>
  215. <xsl:apply-templates select="@*"/>
  216. <xsl:apply-templates select="RFC1583Compatible" mode="toAttr"/>
  217. <xsl:apply-templates select="node()"/>
  218. </xsl:copy>
  219. </xsl:template>
  220. <!-- do not convert other nodes to attribute -->
  221. <xsl:template match="*" mode="toAttr">
  222. </xsl:template>
  223. <!-- -->
  224. <xsl:template match="AddressRange|BroadcastInterface|PointToPointInterface|PointToMultiPointInterface|NBMAInterface|HostInterface|VirtualLink|ExternalInterface">
  225. <!--
  226. <xsl:template match="*">
  227. -->
  228. <xsl:element name="{name()}">
  229. <xsl:for-each select="@*">
  230. <xsl:attribute name="{local-name()}"><xsl:value-of select="." /></xsl:attribute>
  231. </xsl:for-each>
  232. <xsl:for-each select="*">
  233. <xsl:apply-templates select="." mode="toAttr"/>
  234. </xsl:for-each>
  235. <xsl:for-each select="*">
  236. <xsl:apply-templates select="."/>
  237. </xsl:for-each>
  238. </xsl:element>
  239. </xsl:template>
  240. <xsl:template match="@*" mode="toAttr">
  241. <xsl:copy>
  242. <xsl:apply-templates select="@*"/>
  243. </xsl:copy>
  244. </xsl:template>
  245. <xsl:template match="@*|node()">
  246. <xsl:copy>
  247. <xsl:apply-templates select="@*|node()"/>
  248. </xsl:copy>
  249. </xsl:template>
  250. </xsl:stylesheet>