format.xsl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3. <xsl:template match="register|field">
  4. <xsl:if test="local-name() = 'field'">
  5. <xsl:value-of select="preceding-sibling::text()"/>
  6. </xsl:if>
  7. <xsl:element name="{local-name()}">
  8. <xsl:apply-templates select="@*"/>
  9. <xsl:for-each select="view">
  10. <xsl:copy>
  11. <xsl:apply-templates select="@*"/>
  12. </xsl:copy>
  13. </xsl:for-each>
  14. <xsl:apply-templates select="field"/>
  15. <xsl:if test="field">
  16. <xsl:value-of select="text()[last()]"/>
  17. </xsl:if>
  18. </xsl:element>
  19. </xsl:template>
  20. <xsl:template match="//model/bank|//model/transform|//model/enum|//model/unit">
  21. <xsl:value-of select="preceding-sibling::text()"/>
  22. <xsl:copy>
  23. <xsl:apply-templates select="@*|node()"/>
  24. </xsl:copy>
  25. </xsl:template>
  26. <xsl:template match="model">
  27. <xsl:copy>
  28. <xsl:apply-templates select="bank"/>
  29. <xsl:apply-templates select="transform"/>
  30. <xsl:apply-templates select="enum"/>
  31. <xsl:apply-templates select="unit"/>
  32. <xsl:value-of select="text()[last()]"/>
  33. </xsl:copy>
  34. </xsl:template>
  35. <xsl:template match="@*|node()">
  36. <xsl:copy>
  37. <xsl:apply-templates select="@*|node()"/>
  38. </xsl:copy>
  39. </xsl:template>
  40. </xsl:stylesheet>