Menu

[r27]: / branches / parse_tree / toWrite.xsl  Maximize  Restore  History

Download this file

69 lines (69 with data), 2.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0"?>
<!DOCTYPE stylesheet [
<!ENTITY xsl "http://www.w3.org/1999/XSL/Transform">
<!ENTITY php "http://php.net/xsl">
<!ENTITY separator1 ":">
<!ENTITY separator2 "&#10;">
<!ENTITY separator3 " ">
<!ENTITY newline "
">
<!ENTITY indent " ">
<!ENTITY quote '"'>
]>
<xsl:stylesheet version="1.0" xmlns="&xsl;" xmlns:xsl="&xsl;" xmlns:php="&php;">
<xsl:output method="text" indent="no"/>
<xsl:variable name="punctuation" select="'CHAR40,CHAR41,CHAR59,CHAR123,CHAR125,CHAR44,CHAR63,CHAR58,CHAR61,'" />
<xsl:variable name="include" select="'
T_INCLUDE,
T_INCLUDE_ONCE,
T_REQUIRE,
T_REQUIRE_ONCE,'" />
<xsl:variable name="construct" select="'
T_FUNCTION,
T_PRINT,
T_RETURN,
T_ECHO,
T_NEW,
T_CLASS,
T_VAR,
T_GLOBAL,
T_THROW,'" />
<xsl:variable name="access" select="'
T_INTERFACE,
T_FINAL,
T_ABSTRACT,
T_PRIVATE,
T_PUBLIC,
T_PROTECTED,
T_CONST,
T_STATIC,'" />
<xsl:template match="php:*">
<xsl:choose>
<xsl:when test="name(.) = 'php:start'">
<xsl:text>&lt;?php&newline;</xsl:text>
<xsl:for-each select="child::php:*">
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:text>&newline;?&gt;</xsl:text>
</xsl:when>
<xsl:when test="name(.) = 'php:T_INLINE_HTML'">
<xsl:text>&newline;?&gt;</xsl:text>
<xsl:value-of select="."/>
<xsl:text>&lt;?php&newline;</xsl:text>
</xsl:when>
<xsl:when test="count(child::php:*)=0">
<xsl:if test="./text()!='' and ./text()!='&#10;' and ./text()!='&lt;?='">
<xsl:value-of select="." />
</xsl:if>
<xsl:if test="contains(concat($access,$construct,$include), substring-after(name(.), 'php:'))">
<xsl:text>&separator3;</xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="child::php:*">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>