Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3671

Show
Ignore:
Timestamp:
06/23/08 20:47:18 (3 months ago)
Author:
kris
Message:

added a nasty hack to retain cached whitespace whilst ignoring prior EndElement? tags

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/text/xml/DocPrinter.d

    r3608 r3671  
    6262                        // check for cached output 
    6363                        if (node.end) 
    64                             emit (node.start[0 .. node.end - node.start]); 
     64                           { 
     65                           auto p = node.start; 
     66                           auto l = node.end - p; 
     67                           // nasty hack to retain whitespace while 
     68                           // dodging prior EndElement instances 
     69                           if (*p is '>') 
     70                               ++p, --l; 
     71                           emit (p[0 .. l]); 
     72                           } 
    6573                        else 
    6674                        switch (node.type) 
     
    133141        } 
    134142} 
     143 
     144 
     145debug (DocPrinter) 
     146{ 
     147        import tango.io.Stdout; 
     148        import tango.text.xml.Document; 
     149 
     150        void main() 
     151        { 
     152                char[] document = "<blah><xml>foo</xml></blah>"; 
     153 
     154                auto doc = new Document!(char); 
     155                doc.parse (document); 
     156 
     157                void test (char[][] s...){foreach (t; s) Stdout(t).flush;} 
     158 
     159                auto print = new DocPrinter!(char); 
     160                print(doc.root.firstChild.firstChild, &test); 
     161        } 
     162}