>b's YML 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.2 KiB

6 years ago
6 years ago
5 years ago
6 years ago
5 years ago
6 years ago
6 years ago
  1. // YSLT version 2.5.5
  2. !!
  3. def indent(level):
  4. return "value 'substring($space, 1, $_indent+" + str(level) + "*$autoindent)';"
  5. !!
  6. in exsl decl document(href, method) alias document;
  7. in func decl def(name) alias function, result(select);
  8. decl debug_off(exclude-result-prefixes="yml");
  9. in xsl {
  10. decl _trace_param(%text, name="yml:trace", select='yml:debug("* %text")') alias param;
  11. decl _trace_with is _trace_param alias with-param;
  12. decl param(name, select);
  13. decl const(name, select) alias variable, variable is const;
  14. decl output(method), key(name, match, use);
  15. decl value(select) alias value-of, copy(select) alias copy-of;
  16. decl indent is value(%level, select='substring($space, 1, $_indent + (%level) * $autoindent)');
  17. decl stylesheet(
  18. *output="xml",
  19. version="1.0",
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. ) {
  22. output *output;
  23. const "space", !"'" + " " * 200 + "'"!;
  24. param "autoindent", 4;
  25. content;
  26. };
  27. decl estylesheet is stylesheet (
  28. xmlns:exsl='http://exslt.org/common',
  29. xmlns:math='http://exslt.org/math',
  30. xmlns:func='http://exslt.org/functions',
  31. xmlns:str='http://exslt.org/strings',
  32. xmlns:dyn='http://exslt.org/dynamic',
  33. xmlns:set='http://exslt.org/sets',
  34. xmlns:sets='http://exslt.org/sets',
  35. xmlns:date='http://exslt.org/dates-and-times',
  36. xmlns:yml='http://fdik.org/yml',
  37. extension-element-prefixes='exsl func str dyn set sets math date yml'
  38. );
  39. decl textstylesheet is estylesheet(*output="text") {
  40. output *output;
  41. const "space", !"'" + " " * 200 + "'"!;
  42. param "autoindent", 4;
  43. xsl:template match="text()";
  44. content;
  45. }, tstylesheet is textstylesheet;
  46. decl template(match) {
  47. _trace_param *_trace_info;
  48. param "_indent", 0;
  49. content;
  50. };
  51. decl function(name) alias template {
  52. _trace_param *_trace_info;
  53. param "_indent", 0;
  54. content;
  55. };
  56. decl call(name) alias call-template {
  57. _trace_with *_trace_info;
  58. content;
  59. };
  60. decl namespace_alias(stylesheet-prefix, result-prefix);
  61. decl text, raw(disable-output-escaping='yes') alias text;
  62. decl with(name, select) alias with-param;
  63. decl withIndent(%level, name="_indent", select='$_indent + (%level) * $autoindent') alias with-param;
  64. decl apply(select, *indent=1) alias apply-templates {
  65. _trace_with *_trace_info;
  66. withIndent *indent;
  67. content;
  68. };
  69. decl choose, when(test), otherwise;
  70. decl if(test);
  71. decl for(select) alias for-each, foreach is for;
  72. decl element(name, namespace);
  73. decl attrib(name, namespace) alias attribute, attrib_set(name) alias attribute-set;
  74. decl processing(name) alias processing-instruction;
  75. decl comment;
  76. decl number(value), sort(select), decimal_format(name, decimal-separator=".", grouping-separator=",");
  77. decl import(href), fallback;
  78. decl message, error is message(terminate='yes'), warning is message(terminate='no');
  79. decl debug(%text, select='yml:debug(%text)') alias value-of;
  80. decl assert(%test, %msg="''", select='yml:assert(%test,%msg)') alias value-of;
  81. }
  82. define operator "«(.*?)»" as value "%1";