Skip to content

Commit

Permalink
Extract all the information from the old XML files
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Jan 30, 2013
1 parent 170318b commit fd56545
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions legacy/makemds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/local/bin/python

f = open('allfiles.md','r')
for line in f.readlines():
if line.startswith('File:'):
fname = line.split('File: ')[1].strip().capitalize()
print fname
g = open('wiki/%s.md' % fname, 'w')
else:
g.write(line)
f.close()
g.close()
71 changes: 71 additions & 0 deletions legacy/xml2md.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dict="http://grammarware.net/dict" version="1.0">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:param name="date"/>
<xsl:param name="setup"/>
<xsl:variable name="cols" select="document($setup)/setup/*"/>
<xsl:template match="/dict:glossary">
<xsl:for-each select="term">
<xsl:text>File: </xsl:text>
<xsl:value-of select="en/w"/>
<xsl:for-each select="*">
<xsl:text>
* </xsl:text>
<xsl:choose>
<xsl:when test="local-name()='ab'">Abbreviated as</xsl:when>
<xsl:when test="local-name()='en'">English</xsl:when>
<xsl:when test="local-name()='ru'">Russian</xsl:when>
<xsl:when test="local-name()='nl'">Dutch</xsl:when>
<xsl:when test="local-name()='de'">German</xsl:when>
<xsl:otherwise>???</xsl:otherwise>
</xsl:choose>
<xsl:text>: _</xsl:text>
<xsl:value-of select="w"/>
<xsl:text>_</xsl:text>
<xsl:for-each select="*">
<!-- ([Wikipedia](http://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D0%BD%D1%82%D0%B5%D0%BA%D1%81%D1%82%D0%BD%D0%BE-%D1%81%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%BD%D0%B0%D1%8F_%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B0%D1%82%D0%B8%D0%BA%D0%B0)) -->
<xsl:choose>
<xsl:when test="local-name()='wiki'">
<xsl:text> ([Wikipedia](http://</xsl:text>
<xsl:value-of select="local-name(..)"/>
<xsl:text>.wikipedia.org/wiki/</xsl:text>
<xsl:choose>
<xsl:when test="./text()!=''">
<xsl:value-of select="translate(./text(),' ','_')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../w/text()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="local-name()='wbooks'">
<xsl:text> ([WikiBooks](http://</xsl:text>
<xsl:value-of select="local-name(..)"/>
<xsl:text>.wikibooks.org/wiki/</xsl:text>
<xsl:choose>
<xsl:when test="./text()!=''">
<xsl:value-of select="./text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../w/text()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="local-name()='src'">
<xsl:text> ([Source](</xsl:text>
<xsl:value-of select="./text()"/>
<xsl:text>)</xsl:text>
</xsl:when>
<xsl:when test="local-name()='w'"/>
<xsl:otherwise>???</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
<xsl:text>

</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 5cde37 to f508f3

0 comments on commit fd56545

Please sign in to comment.