Ticket #253 (assigned defect)
Improve handling of default namespaces
| Reported by: | llasram@… | Owned by: | cmlenz |
|---|---|---|---|
| Priority: | major | Milestone: | 0.6.1 |
| Component: | Serialization | Version: | devel |
| Keywords: | Cc: |
Description
The NamespaceFlattener class attempts to resolve all uses of a particular namespace to a single prefix at any given point, but makes no allowance for the common practice of binding the same namespace as both the default and to an explicit prefix. The attached patch implements this support.
With the patch applied one test (MatchDirectiveTestCase.test_namespace_context) fails. I've modified the test in the patch to show the difference as I'm not sure what the correct output should in fact be. Modifying NamespaceFlattener to print out events before interpreting them shows the following for this test case:
('START_NS', (u'x', u'http://www.example.org/'))
('START', (QName(u'html'), Attrs()))
('TEXT', <Markup u'\n '>)
('START_NS', ('', u'http://www.example.org/'))
('START', (QName(u'div'), Attrs()))
('TEXT', <Markup u'Foo'>)
('END', QName(u'div'))
('END_NS', '')
('TEXT', <Markup u'\n '>)
('END', QName(u'html'))
('END_NS', u'x')}}}
Which to me implies that my patch is actually generating the correct behavior?
Thanks and hope this helps!

