diff --git a/shared/python/xldf.py b/shared/python/xldf.py index 7e936495..03151203 100755 --- a/shared/python/xldf.py +++ b/shared/python/xldf.py @@ -43,12 +43,16 @@ def normalise(tree): for e in tree.findall('*'): for e2 in e.findall('*'): if len(e2.findall('content'))>1: - print '[????] In',identify(e),'/',identify(e2),'found double content!' + print '[++++] In',identify(e),'/',identify(e2),'found double content!' first = e2.findall('content')[0] for e3 in e2.findall('content')[1:]: for e4 in e3.findall('*'): first.append(e4) e2.remove(e3) + for e in tree.findall('//content'): + if not len(e): + print '[++++] Empty content made explicit.' + ET.SubElement(e,'empty') return def main(xldffile,inldffile,outldffile): diff --git a/shared/python/xldfCommands.py b/shared/python/xldfCommands.py index 63cc5f78..0f97d1d4 100644 --- a/shared/python/xldfCommands.py +++ b/shared/python/xldfCommands.py @@ -171,7 +171,11 @@ def xldf_drop(localpath,cmd,tree): if not found: print '[----] xldf:drop failed: node',cmd.findtext('section'),'not found!' return - tree.getroot().remove(found) + # houwtje-touwtje + try: + tree.getroot().remove(found) + except ValueError,e: + tree.findall('part')[0].remove(found) print '[XLDF] drop('+cmd.findtext('section')+')' return @@ -196,14 +200,17 @@ def xldf_combine(localpath,cmd,tree): continue if found2.findall(s.tag): # the same role present, appending - print '[////] Concatenating',s.tag,'of',cmd.findtext('section'),'and',cmd.findtext('with') + #print '[////] Concatenating',s.tag,'of',cmd.findtext('section'),'and',cmd.findtext('with') content2content(s.findall('content')[0],found2.findall(s.tag+'/content')[0]) else: # the same role absent, copying - print '[////] Copying',s.tag,'of',cmd.findtext('section'),'to',cmd.findtext('with') + #print '[////] Copying',s.tag,'of',cmd.findtext('section'),'to',cmd.findtext('with') found2.append(s) # wtf? - tree.getroot().remove(found) + try: + tree.getroot().remove(found) + except ValueError,e: + tree.findall('part')[0].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 @@ -258,7 +265,7 @@ def xldf_add_section(localpath,cmd,tree): print '[XLDF] add-section to lexical part' success = True elif s.tag in ('core','annex'): - tree.getroot().append(s) + tree.findall('part')[0].append(s) print '[XLDF] add-section to the',s.tag success = True elif s.tag == 'placeholder': diff --git a/shared/python/xsd2ldf.py b/shared/python/xsd2ldf.py index 80af73ad..a92b6cb7 100755 --- a/shared/python/xsd2ldf.py +++ b/shared/python/xsd2ldf.py @@ -107,16 +107,27 @@ def main(xsdfile,bgffile,ldffile): el = ET.SubElement(section,'normativeReferences') el = ET.SubElement(el,'content') el = ET.SubElement(el,'list') + part = ET.SubElement(dtree,'part') for p in stree.findall('/'+slpsns.xsd_('import')): pel = ET.SubElement(el,'item') pel.text = p.attrib['schemaLocation'] istree = ET.parse('/'.join(xsdfile.split('/')[:-1])+'/'+p.attrib['schemaLocation']) - mapXSD2LDF(istree,dtree,grammar) + mapXSD2LDF(istree,part,grammar) print len(stree.findall('/'+slpsns.xsd_('import'))),'external schema(ta) imported.' - mapXSD2LDF(stree,dtree,grammar) - - ET.ElementTree(dtree).write(ldffile) + if dtree.findall('part'): + part = dtree.findall('part')[0] + else: + part = ET.SubElement(dtree,'part') + mapXSD2LDF(stree,part,grammar) + # bit of normalisation + fullTree = ET.ElementTree(dtree) + for e in fullTree.findall('//content'): + if not len(e): + print '[++++] Empty content made explicit.' + ET.SubElement(e,'empty') + # serialise! + fullTree.write(ldffile) return def copymixedcontent (parent, name, stree, xpath): diff --git a/shared/xsl/ldf2tex.xslt b/shared/xsl/ldf2tex.xslt index 8d55ecd6..7f98081c 100644 --- a/shared/xsl/ldf2tex.xslt +++ b/shared/xsl/ldf2tex.xslt @@ -119,7 +119,18 @@ %% START_CORE - + + + + + + + + + + + + @@ -282,6 +293,28 @@ + + + \part{ + + + + + } + + \label{ + + + + + + + + + } + + + diff --git a/shared/xsl/ldf2xhtml.xslt b/shared/xsl/ldf2xhtml.xslt index 5b4ec9d7..5b16ef5c 100644 --- a/shared/xsl/ldf2xhtml.xslt +++ b/shared/xsl/ldf2xhtml.xslt @@ -113,7 +113,19 @@ - + + + + + + + + + + + + + @@ -472,6 +484,32 @@ --> + + +

+ + + + + + + + + + + + + + + Part I. + + + + +

+ +
+ diff --git a/topics/languedoc/ldf/prepare.xbgf b/topics/languedoc/ldf/prepare.xbgf index 598a6107..f66691b2 100644 --- a/topics/languedoc/ldf/prepare.xbgf +++ b/topics/languedoc/ldf/prepare.xbgf @@ -4,7 +4,7 @@ xmlns:xbgf="http://planet-sl.org/xbgf"> - frontSection + topSection frontList diff --git a/topics/languedoc/ldf/xldf/beautify.xldf b/topics/languedoc/ldf/xldf/beautify.xldf index f01b7d8f..efed67c4 100644 --- a/topics/languedoc/ldf/xldf/beautify.xldf +++ b/topics/languedoc/ldf/xldf/beautify.xldf @@ -25,32 +25,16 @@ - - - - placeholder - - generated - - - - - - - + + frontMatter - - frontMatter + - - - frontSection - - + topSection - + - + @@ -93,16 +77,61 @@ - + + + + + + core + + structuredSection + + + + + + + + + + + + part + + + + + core + + structuredSection + + + + + + + + + + + + + + + - core + backMatter - structuredSection + + + topSection + + - + @@ -122,36 +151,38 @@ - frontMatter + anyTopSections - + - frontSection + topSection - + - lists - - - frontList - - - + lists + + + + frontList + + + - lexicalPart - - - lexicalSection - - - + lexicalPart + + + + lexicalSection + + + @@ -266,9 +297,10 @@ - name - string - + name + + string + @@ -345,9 +377,9 @@ - - -