/[opental]/opental/pax/paxtransform.py
ViewVC logotype

Diff of /opental/pax/paxtransform.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by lalo, Mon Apr 14 21:06:17 2003 UTC revision 1.33 by lalo, Mon Apr 14 22:13:02 2003 UTC
# Line 5  Line 5 
5  from backwards_compatibility import *  from backwards_compatibility import *
6  from utils import pack_list, XML  from utils import pack_list, XML
7  from core import Literal  from core import Literal
8  import types  import types, sys, traceback
9    
10  class StopTransform(Exception):  class StopTransform(Exception):
11      def __init__(self, result=None, *args):      def __init__(self, result=None, *args):
# Line 55  class Engine(object): Line 55  class Engine(object):
55              result = pack_list(result)              result = pack_list(result)
56          except:          except:
57              # usually we're not interested in errors from pack              # usually we're not interested in errors from pack
58                traceback.print_exc()
59              pass              pass
60          context.postprocess_remaining = processed          context.postprocess_remaining = processed
61          try:          try:
# Line 119  class RenderingEngine(Engine): Line 120  class RenderingEngine(Engine):
120      "Transforms something, and renders it to XML"      "Transforms something, and renders it to XML"
121      def transform(self, element, context):      def transform(self, element, context):
122          result = Engine.transform(self, element, context)          result = Engine.transform(self, element, context)
123          return XML(result, context.root_xmlns_map, context.encoding)          if hasattr(result, 'children'):
124                return XML(result, context.root_xmlns_map, context.encoding)
125            elif type(result) in (types.ListType, types.TupleType):
126                return ''.join([str(child) for child in result])
127            return result
128    
129      def transform_children(self,element,context):      def transform_children(self,element,context):
130          element = Engine.transform_children(self, element, context)          element = Engine.transform_children(self, element, context)
131          # except that the children will be strings          # except that the children will be strings
132          if hasattr(element, 'children'):          if hasattr(element, 'children'):
133              element.children = (Literal(''.join(element)),)              element.children = (Literal(''.join([str(child) for child in element if child])),)
         elif type(element) in (types.ListType, types.TupleType):  
             element = Literal(''.join(element))  
134          return element          return element
135    
136    

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26