1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:exsl="http://exslt.org/common"
6 <xsl:output method="xml" version="1.0" encoding="UTF-8" />
8 <xsl:include href="tree-view.xsl"/>
10 <xsl:template match="blacklist" mode="flatten" />
12 <xsl:template match="document" mode="flatten">
13 <xsl:apply-templates mode="flatten" select="parsetree"/>
16 <xsl:template match="nonterminal" mode="flatten">
17 <xsl:variable name="temp" select="@id" />
20 <xsl:when test="count(*)=3 and contains($temp,'expr') and *[contains(@id,'expr')]">
21 <xsl:apply-templates mode="flatten"/>
24 <!-- collapses degenerated trees like lists, conserving the blacklist subtrees-->
25 <xsl:when test="../@id = @id and count(/document/blacklist[1]/symbol[text() = $temp])=0">
26 <xsl:apply-templates mode="flatten"/>
29 <!-- collapses unary productions -->
30 <xsl:when test="count(*)=3 and count(/document/blacklist[1]/symbol[text() = $temp])=0">
31 <xsl:apply-templates mode="flatten"/>
35 <xsl:element name="{@id}" >
36 <xsl:attribute name="variant"><xsl:value-of select="@variant" /></xsl:attribute>
37 <xsl:apply-templates mode="flatten"/>
44 <xsl:template match="terminal" mode="flatten">
45 <xsl:element name="{@id}">
46 <xsl:apply-templates mode="flatten"/>
50 <xsl:template match="/">
51 <xsl:variable name="flatten">
52 <xsl:apply-templates mode="flatten"/>
54 <xsl:variable name="rendered">
55 <xsl:apply-templates mode="rendered" select="exsl:node-set($flatten)"/>
58 <!--xsl:copy-of select="$rendered" /-->
59 <xsl:copy-of select="$flatten" />