Permalink
Browse files

XSLT >> XPath+sh

git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@842 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information...
grammarware committed Oct 21, 2010
1 parent 3d483d7 commit 5e7c211670068b636d6c2849b559e44530697793
Showing with 36 additions and 19 deletions.
  1. +1 −19 shared/tools/bgflc
  2. +35 −0 topics/presentation/metrics/bgf-overview.xslt
View
@@ -14,24 +14,6 @@ if [ $# -ne 1 ]; then
elif [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 1
elif [ `uname` == "Linux" ] ; then
echo -n "Total productions: "
xpath -e `cat ${SLPS}/topics/presentation/metrics/productions.xpath` $1 2> /dev/null
echo -n "Total nonterminals: "
xpath -e `cat ${SLPS}/topics/presentation/metrics/nonterminals.xpath` $1 2> /dev/null
echo -n "Top nonterminals: "
xpath -e `cat ${SLPS}/topics/presentation/metrics/top.xpath` $1 2> /dev/null
echo -n "Bottom nonterminals: "
xpath -e `cat ${SLPS}/topics/presentation/metrics/bottom.xpath` $1 2> /dev/null
echo
else
/bin/echo -n "Total productions: "
xpath $1 `cat ${SLPS}/topics/presentation/metrics/productions.xpath` 2> /dev/null
/bin/echo -n "Total nonterminals: "
xpath $1 `cat ${SLPS}/topics/presentation/metrics/nonterminals.xpath` 2> /dev/null
/bin/echo -n "Top nonterminals: "
xpath $1 `cat ${SLPS}/topics/presentation/metrics/top.xpath` 2> /dev/null
/bin/echo -n "Bottom nonterminals: "
xpath $1 `cat ${SLPS}/topics/presentation/metrics/bottom.xpath` 2> /dev/null
echo
xsltproc ${SLPS}/topics/presentation/metrics/bgf-overview.xslt $1
fi
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bgf="http://planet-sl.org/bgf" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/bgf:grammar">
<xsl:text>Total productions: </xsl:text>
<xsl:value-of select="count(/*/*[local-name()='production'])"/>
<xsl:text>
Total nonterminals: </xsl:text>
<xsl:value-of select="count(/*[local-name()='grammar']/*/nonterminal[not(text()=../preceding-sibling::*/nonterminal/text())])"/>
<xsl:text>
Top nonterminals: </xsl:text>
<xsl:value-of select="count(/*/*/nonterminal[not(text()=/*/*/*//nonterminal/text()) and not(text()=../preceding-sibling::*/nonterminal/text())])"/>
<xsl:text> (</xsl:text>
<xsl:for-each select="/*/*/nonterminal[not(text()=/*/*/*//nonterminal/text()) and not(text()=../preceding-sibling::*/nonterminal/text())]">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>)</xsl:text>
<xsl:text>
Bottom nonterminals: </xsl:text>
<xsl:value-of select="count(/*/*[not(*//nonterminal)]/nonterminal[not(text()=../preceding-sibling::*/nonterminal/text())])"/>
<xsl:text> (</xsl:text>
<xsl:for-each select="/*/*[not(*//nonterminal)]/nonterminal[not(text()=../preceding-sibling::*/nonterminal/text())]">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>)</xsl:text>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 5e7c211

Please sign in to comment.