Skip to content

Commit

Permalink
changed the way figures are defined and treated in LDF
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@673 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Aug 3, 2009
1 parent 80255d5 commit 9e1861c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 15 deletions.
4 changes: 2 additions & 2 deletions shared/python/repp.py
Expand Up @@ -38,7 +38,7 @@ def repp(localpath,tree,prettyprinter):
for e in ET.parse(inputfile).findall('/*/*'):
#for e in ET.XML('<t>'+''.join(open(inputfile,'r').readlines())+'</t>').findall('*'):
tree.append(createCleanElementFrom(e))
print '[++++] Re-pretty-printed.'
print '[++++] Re-pretty-printed',tree.get('src')
return


Expand All @@ -50,7 +50,7 @@ def main(inldffile,ppfile,outldffile):
localpath = '/'.join(inldffile.split('/')[:-1])+'/'
cx = 0
for s in tree.findall('//sample'):
print '[????] Found',identify(s),'of',s.get('src')
#print '[????] Found',identify(s),'of',s.get('src')
repp(localpath,s,ppfile)
cx += 1
print 'Total',cx,'samples processed'
Expand Down
25 changes: 23 additions & 2 deletions shared/xsd/ldf.xsd
Expand Up @@ -221,6 +221,17 @@
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="figureType">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="PDF"/>
<xsd:enumeration value="PostScript"/>
<xsd:enumeration value="SVG"/>
<xsd:enumeration value="PNG"/>
<xsd:enumeration value="GIF"/>
<xsd:enumeration value="JPEG"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:group name="topSection">
<xsd:choice>
<xsd:element name="foreword" type="ldf:simpleSection">
Expand Down Expand Up @@ -395,9 +406,19 @@

<xsd:complexType name="simpleFigure">
<xsd:sequence>
<xsd:element name="shortcaption" type="xsd:string" minOccurs="0"/>
<xsd:element name="caption" type="xsd:string"/>
<xsd:element name="type" type="xsd:string"/>
<xsd:element name="file" type="xsd:string"/>
<xsd:element name="source" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="type" type="ldf:figureType"/>
<xsd:choice>
<xsd:element name="localfile" type="xsd:string"/>
<xsd:element name="url" type="xsd:anyURI"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="optional"/>
</xsd:complexType>
Expand Down
3 changes: 2 additions & 1 deletion shared/xsd/xbgf.xsd
Expand Up @@ -496,7 +496,8 @@
<xsd:element name="extract">
<xsd:annotation>
<xsd:documentation>
A new definition is introduced by extraction. The argument provided for this transformation
A new definition is introduced by extraction. The argument provided for this
transformation
is a production that identifies both the fresh nonterminal to be introduced and the
expression that is used both as a pattern for folding and as a right hand side of
the added definition.
Expand Down
20 changes: 17 additions & 3 deletions shared/xsl/ldf2tex.xslt
Expand Up @@ -120,6 +120,14 @@
%% START_CORE
</xsl:text>
<xsl:apply-templates select="core"/>
<xsl:for-each select="backMatter/*">
<xsl:call-template name="sectionize">
<xsl:with-param name="target" select="."/>
</xsl:call-template>
<xsl:call-template name="process-SimpleSection">
<xsl:with-param name="section" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:text>\appendix</xsl:text>
<xsl:apply-templates select="annex"/>
<xsl:text>\end{document} %% END_CONTENT</xsl:text>
Expand Down Expand Up @@ -441,16 +449,22 @@
\begin{figure}\begin{center}
</xsl:text>
<xsl:choose>
<xsl:when test="type = 'PDF'">
<xsl:when test="source[type = 'PDF']">
<xsl:text>\includegraphics[width=0.5\textwidth]{</xsl:text>
<xsl:value-of select="file"/>
<xsl:value-of select="source[type = 'PDF']/localfile"/>
<xsl:text>}</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>...don't know how to insert a figure...</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>\end{center}\caption{</xsl:text>
<xsl:text>\end{center}\caption</xsl:text>
<xsl:if test="shortcaption">
<xsl:text>[</xsl:text>
<xsl:value-of select="shortcaption"/>
<xsl:text>]</xsl:text>
</xsl:if>
<xsl:text>{</xsl:text>
<xsl:value-of select="caption"/>
<xsl:text>}</xsl:text>
<xsl:if test="@id">
Expand Down
10 changes: 6 additions & 4 deletions shared/xsl/ldf2xhtml.xslt
Expand Up @@ -526,19 +526,18 @@
<a>
<xsl:attribute name="name">
<xsl:value-of select="@id"/>

</xsl:attribute>
</a>
</xsl:if>
<center>
<xsl:choose>
<xsl:when test="type = 'PNG'">
<xsl:when test="source[type = 'PNG']">
<img>
<xsl:attribute name="src">
<xsl:value-of select="file"/>
<xsl:value-of select="source[type = 'PNG']/*[2]"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="caption"/>
<xsl:value-of select="shortcaption"/>
</xsl:attribute>
</img>
</xsl:when>
Expand All @@ -547,6 +546,9 @@
</xsl:otherwise>
</xsl:choose>
<br/>
<strong>
<xsl:text>Figure.</xsl:text>
</strong>
<xsl:value-of select="caption"/>
</center>
</p>
Expand Down
Binary file added topics/languedoc/xbgf/bnfbgf.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 35 additions & 3 deletions topics/languedoc/xbgf/xldf/completeIntro.xldf
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xldf:evolution-sequence
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:bgf="http://planet-sl.org/bgf"
xmlns:xbgf="http://planet-sl.org/xbgf"
xmlns:ldf="http://planet-sl.org/ldf"
Expand Down Expand Up @@ -344,14 +345,21 @@

<xldf:add-figure>
<figure>
<shortcaption>Full convergence diagram for BNF and BGF.</shortcaption>
<caption>
Full convergence diagram for BNF and BGF. The top nodes are sources, the bottom node
is the target, the arc labels are separate XBGF scripts, the nodes contain
numbers of name mismatches and structural mismatches between each step and
the synch point (marked as a double circle).
</caption>
<type>PDF</type>
<file>bnfbgf.pdf</file>
<source>
<type>PDF</type>
<localfile>bnfbgf.pdf</localfile>
</source>
<source>
<type>PNG</type>
<localfile>bnfbgf.png</localfile>
</source>
</figure>
<to>compatibility-section</to>
</xldf:add-figure>
Expand All @@ -362,7 +370,31 @@
<text>
Finally we run a grammar comparator to see what is left and notice
one mismatch that is easily fixed with <ldf:keyword>massage</ldf:keyword>, as well as the right
hand side still having $(symbol^+)^+$ instead of just $symbol$. This
hand side still having
<ldf:formula>
<mml:math>
<mml:mrow>
<mml:msup>
<mml:mfenced>
<mml:msup>
<mml:mi>symbol</mml:mi>
<mml:mo>+</mml:mo>
</mml:msup>
</mml:mfenced>
<mml:mo>+</mml:mo>
</mml:msup>
</mml:mrow>
</mml:math>
</ldf:formula>
instead of just
<ldf:formula>
<mml:math>
<mml:mrow>
<mml:mi>symbol</mml:mi>
</mml:mrow>
</mml:math>
</ldf:formula>
. This
corresponds to the design decision that treats top-level choices
and top-level sequences differently in BNF to make them more appealing
to the eye by avoiding unnecessary parenthesizing. The very specific
Expand Down

0 comments on commit 9e1861c

Please sign in to comment.