2
0

make_checks.xslt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
  4. <xsl:template match="/">
  5. <xsl:variable name="master_xml">
  6. <xsl:copy-of select="document('phrase_en.xml')/*"/>
  7. </xsl:variable>
  8. <xsl:variable name="current_xml">
  9. <xsl:copy-of select="*"/>
  10. </xsl:variable>
  11. <xsl:apply-templates select="$master_xml" mode="checkElements">
  12. <xsl:with-param name="current_xml" select="$current_xml/*"/>
  13. </xsl:apply-templates>
  14. </xsl:template>
  15. <xsl:template match="en" mode="checkElements">
  16. <xsl:param name="current_xml"/>
  17. <xsl:copy>
  18. <xsl:attribute name="translated-to" select="name($current_xml)"/>
  19. <xsl:apply-templates select="@*|node()" mode="#current">
  20. <xsl:with-param name="current_xml" select="$current_xml/*"/>
  21. </xsl:apply-templates>
  22. </xsl:copy>
  23. </xsl:template>
  24. <xsl:template match="prompt" mode="checkElements">
  25. <xsl:param name="current_xml"/>
  26. <xsl:variable name="translation"
  27. select="$current_xml[@filename=current()/@filename]/@phrase"/>
  28. <xsl:copy>
  29. <xsl:apply-templates select="@*" mode="#current"/>
  30. <xsl:choose>
  31. <xsl:when test="count($translation)=0">
  32. <xsl:attribute name="translated" select="false()"/>
  33. </xsl:when>
  34. <xsl:when test="@phrase = $translation">
  35. <xsl:attribute name="translated" select="false()"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:attribute name="translated-to" select="$translation[1]"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. <xsl:if test="count($translation) > 1">
  42. <xsl:attribute name="more-then-one-translation" select="true()"/>
  43. </xsl:if>
  44. </xsl:copy>
  45. </xsl:template>
  46. <xsl:template match="@*|node()" mode="checkElements">
  47. <xsl:param name="current_xml"/>
  48. <xsl:copy>
  49. <xsl:apply-templates select="@*|node()" mode="#current">
  50. <xsl:with-param name="current_xml" select="$current_xml/*"/>
  51. </xsl:apply-templates>
  52. </xsl:copy>
  53. </xsl:template>
  54. </xsl:stylesheet>