Skip to content

Commit

Permalink
more commands in XLDF
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@519 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Mar 21, 2009
1 parent e06ca2e commit aa1fd1e
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
22 changes: 22 additions & 0 deletions shared/tools/xldf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/sh

# Get our hands on basedir
LOCAL1=${PWD}
cd `dirname $0`
cd ../..
SLPS=${PWD}
cd ${LOCAL1}

if [ $# -ne 3 ]; then
echo "Usage: xldf <XLDF-input> <LDF-input> <LDF-output>"
exit 1
elif [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 1
elif [ ! -r $2 ]; then
echo "Oops: $2 not found or not readable."
exit 1
else
rm -f $3
python ${SLPS}/topics/transformation/xldf/xldf.py $1 $2 $3
fi
40 changes: 37 additions & 3 deletions shared/xsd/xldf.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<xsd:element ref="xldf:insert"/>
<xsd:element ref="xldf:import-grammar"/>
<xsd:element ref="xldf:import-sample"/>
<xsd:element ref="xldf:drop"/>
<xsd:element ref="xldf:place"/>
<xsd:element ref="xldf:combine"/>
<xsd:element ref="xldf:rename"/>
<xsd:element ref="xldf:append"/>
<xsd:element ref="xldf:remove-section"/>
Expand Down Expand Up @@ -125,7 +127,7 @@
</xsd:choice>
</xsd:complexType>
</xsd:element>

<xsd:element name="place">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -134,8 +136,40 @@
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="section" type="xsd:string"/> <!-- IDREF -->
<xsd:element name="inside" type="xsd:string"/> <!-- IDREF -->
<xsd:element name="section" type="xsd:string"/>
<!-- IDREF -->
<xsd:element name="inside" type="xsd:string"/>
<!-- IDREF -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="combine">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="section" type="xsd:string"/>
<!-- IDREF -->
<xsd:element name="with" type="xsd:string"/>
<!-- IDREF -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="drop">
<xsd:annotation>
<xsd:documentation>
TBD
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="section" type="xsd:string"/>
<!-- IDREF -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Expand Down
31 changes: 31 additions & 0 deletions topics/transformation/xldf/xldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,33 @@ def xldf_place(cmd,tree):
print '[----] xldf:place failed: don''t know how to place subsections in',found2.tag
return

def xldf_drop(cmd,tree):
found = findnode(tree,cmd.findtext('section'))
if not found:
print '[----] xldf:drop failed: the node not found!'
return
tree.getroot().remove(found)
print '[XLDF] drop('+cmd.findtext('section')+')'
return

def xldf_combine(cmd,tree):
found = findnode(tree,cmd.findtext('section'))
if not found:
print '[----] xldf:combine failed: source node not found!'
return
found2 = findnode(tree,cmd.findtext('with'))
if not found2:
print '[----] xldf:combine failed: target node not found!'
return
target = found2.findall('content')[0]
for p in found.findall('*/content/*'):
target.append(p)
tree.getroot().remove(found)
print '[XLDF] combine('+cmd.findtext('section')+',',cmd.findtext('with')+')'
#else:
# print '[----] xldf:combine failed: don''t know how to place subsections in',found2.tag
return

def xldf_rename(cmd,tree):
if cmd.findall('from/title'):
byid = False
Expand Down Expand Up @@ -295,8 +322,12 @@ def main(xldffile,inldffile,outldffile):
xldf_import_grammar(cmd,ltree)
elif cmdname == 'import-sample':
xldf_import_sample(cmd,ltree)
elif cmdname == 'drop':
xldf_drop(cmd,ltree)
elif cmdname == 'place':
xldf_place(cmd,ltree)
elif cmdname == 'combine':
xldf_combine(cmd,ltree)
elif cmdname == 'rename':
xldf_rename(cmd,ltree)
elif cmdname == 'append':
Expand Down

0 comments on commit aa1fd1e

Please sign in to comment.