Edgewall Software

Opened 18 years ago

Last modified 7 years ago

#68 new defect

results of select don't contain required namespace prefixes

Reported by: davidf@… Owned by: cmlenz
Priority: major Milestone: 0.9
Component: General Version: 0.3.3
Keywords: Cc: davidf@…

Description

There are two commented out tests in path.py containing this description:

attributes that would need a namespace prefix that isn't in the prefix map would need to get an artificial prefix, but currently don't

A cutdown example is:

  XML('<root xmlns:f="FOO"><foo f:bar="baz"/></root>').select("foo").render()

which returns

  <foo bar="baz"/>

but should return something like

  <foo xmlns:f="FOO" f:bar="baz"/>

Attachments (1)

select-namespaces-68-stab1.patch (1.5 KB) - added by David Fraser <davidf@…> 18 years ago.
initial stab at producing namespace code using the namespace dictionary

Download all attachments as: .zip

Change History (10)

comment:1 Changed 18 years ago by David Fraser <davidf@…>

The actual example I was testing with:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
 <head><title py:content="1+1">3</title></head>
</html>

The following python code

  page = '''<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:py="http://genshi.edgewall.org/">
    <head><title py:content="1+1">3</title></head>
    </html>'''
  genshi.XML(page).select("//head").render()

returns

  <head xmlns="http://www.w3.org/1999/xhtml">
    <title content="1+1" xmlns="http://www.w3.org/1999/xhtml">3</title>
  </head>

instead of

  <head xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
    <title py:content="1+1" xmlns="http://www.w3.org/1999/xhtml">3</title>
  </head>

i.e. the py: is missing

Changed 18 years ago by David Fraser <davidf@…>

initial stab at producing namespace code using the namespace dictionary

comment:2 Changed 18 years ago by David Fraser <davidf@…>

The attached patch (select-namespaces-68-stab1.patch) is an initial attempt to take the namespaces dictionary passed in and used that to look up and include namespaces.

This is not ideal but provides a way for me to at least pass namespaces in and get what I need for now. I'm not really sure that this is what the namespaces dictionary is intended for; in particular since it now breaks some other tests :-)

comment:3 Changed 17 years ago by cmlenz

[502] moved the code base further along to be able to support this, but doesn't yet use the passed in prefixes… that would require tracking where namespaces run out of scope, which will require a couple more LOCs.

comment:4 Changed 17 years ago by cmlenz

  • Milestone changed from 0.4 to 0.5

I'll try to implement a more complete solution for this for the next release.

comment:5 Changed 16 years ago by cmlenz

  • Milestone changed from 0.5 to 0.6

Postponing again, sorry :/

comment:6 Changed 14 years ago by cmlenz

  • Milestone changed from 0.6 to 0.7

comment:7 Changed 14 years ago by anonymous

s

comment:8 Changed 14 years ago by Carsten Klein <carsten.klein@…>

Currently, elements and attributes, when prefixed, will be issued as START events using the following notation

namespace-url}element|attribute-name

Why not simply extend upon this using

prefix}namespace-url}attribute-name

That way, the prefixes could be preserved in the stream, as otherwise they will be lost. The benefit would be that they could be restored upon rendering the stream, which is currently not the case - genshi will introduce ns<n> prefixes upon rendering the stream.

comment:9 Changed 7 years ago by hodgestar

  • Milestone changed from 0.7 to 0.9

Moved to milestone 0.9.

Note: See TracTickets for help on using tickets.