Commit | Line | Data |
---|---|---|
bfae91cc A |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!-- Step 1: Read-Print --> | |
3 | <!-- input document must be in the following format --> | |
4 | <!-- | |
5 | <mal> | |
6 | <stdin>...stdin text...</stdin> | |
7 | <stdout> ... ignored, omitted ... </stdout> | |
8 | <state> ignored, preserved </state> | |
9 | </mal> | |
10 | --> | |
11 | <xsl:stylesheet | |
12 | version="3.0" | |
13 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
14 | <xsl:import href="reader.xslt" /> | |
15 | <xsl:import href="printer.xslt" /> | |
16 | <xsl:output method='xml' encoding='utf-8' indent='yes'/> | |
17 | <xsl:template match="mal" name="rep"> | |
18 | <mal> | |
19 | <stdin></stdin> <!-- clear stdin --> | |
20 | <xsl:copy-of select="state" /> <!-- preserve state --> | |
b650f479 A |
21 | <xsl:variable name="_read"> |
22 | <xsl:call-template name="READ" /> | |
23 | </xsl:variable> | |
24 | <xsl:variable name="_eval"> | |
25 | <xsl:for-each select="$_read"> | |
26 | <xsl:call-template name="EVAL"></xsl:call-template> | |
27 | </xsl:for-each> | |
28 | </xsl:variable> | |
29 | <stdout> | |
30 | <xsl:for-each select="$_eval"> | |
31 | <xsl:call-template name="PRINT"></xsl:call-template> | |
32 | </xsl:for-each> | |
33 | </stdout> | |
bfae91cc A |
34 | </mal> |
35 | </xsl:template> | |
36 | ||
37 | <xsl:template name="PRINT"> | |
38 | <xsl:variable name="context"> | |
bfae91cc | 39 | <xsl:variable name="str"> |
78ec3e62 | 40 | <xsl:call-template name="malprinter-pr_str"><xsl:with-param name="readably" select="true()"/></xsl:call-template> |
bfae91cc A |
41 | </xsl:variable> |
42 | <xsl:value-of select="$str" /> | |
bfae91cc A |
43 | </xsl:variable> |
44 | <xsl:for-each select="$context"><xsl:copy-of select="." /></xsl:for-each> | |
45 | </xsl:template> | |
46 | ||
47 | <xsl:template name="EVAL"> | |
b650f479 | 48 | <xsl:copy-of select="." /> |
bfae91cc A |
49 | </xsl:template> |
50 | ||
51 | <xsl:template name="READ"> | |
52 | <xsl:variable name="context"> | |
53 | <str> | |
54 | <xsl:copy-of select="stdin/text()" /> | |
55 | </str> | |
56 | </xsl:variable> | |
57 | <xsl:variable name="form"> | |
58 | <xsl:for-each select="$context"> | |
59 | <xsl:call-template name="malreader-read_str"></xsl:call-template> | |
60 | </xsl:for-each> | |
61 | </xsl:variable> | |
62 | <xsl:for-each select="$form"> | |
63 | <xsl:if test="error"> | |
64 | <xsl:message terminate="yes"> | |
65 | <xsl:value-of select="error" /> | |
66 | </xsl:message> | |
67 | </xsl:if> | |
68 | <xsl:copy-of select="." /> | |
69 | </xsl:for-each> | |
70 | </xsl:template> | |
71 | </xsl:stylesheet> |