g***@gmail.com
2013-11-06 13:28:42 UTC
Hi,
I'm trying to do generate a template from a string, containing legacy (i.e.
I am not to change it) xml with namespace declarations, like this:
templatestr = """
<my_output xmlns="http://some-address.com/sub/nr"
xmlns:p="http://some-address.com/sub/nr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=http://some-address.com/sub/nr
http://some-address.com/sub/nr/src/xml/file.xsd" p:majorVersion="0"
p:minorVersion="00" p:version="version 0.00">
<elements xmlns:py="http://genshi.edgewall.org/">
<py:for each="el in elements">
${el}
</py:for>
</elements>
</my_output>
"""
tpl = MarkupTemplate(templatestr)
str = tpl.generate(elements=list_with_xml_markup_strings)
for x in str.serialize():
print x
The elements passed to the template are of the form:
el = '<element p:attribute="something"><child/>...</element>'
However, in the output, even if the list from which to generate elements is empty, genshi seems to remove the xmlns:p declaration from my root element, and add p: attributes to all the elements in the template (but not the ones passed by generate() ).
Basically, it looks like this:
<p:my_output
xmlns="http://some-address.com/sub/nr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=http://some-address.com/sub/nr
http://some-address.com/sub/nr/src/xml/file.xsd" p:majorVersion="0"
p:minorVersion="00" p:version="version 0.00">
<p:elements xmlns:py="http://genshi.edgewall.org/">
etcetera.
Is this expected behaviour? And if yes, what should I do to have the attributes remain in place?
cheers,
jorrit
I'm trying to do generate a template from a string, containing legacy (i.e.
I am not to change it) xml with namespace declarations, like this:
templatestr = """
<my_output xmlns="http://some-address.com/sub/nr"
xmlns:p="http://some-address.com/sub/nr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=http://some-address.com/sub/nr
http://some-address.com/sub/nr/src/xml/file.xsd" p:majorVersion="0"
p:minorVersion="00" p:version="version 0.00">
<elements xmlns:py="http://genshi.edgewall.org/">
<py:for each="el in elements">
${el}
</py:for>
</elements>
</my_output>
"""
tpl = MarkupTemplate(templatestr)
str = tpl.generate(elements=list_with_xml_markup_strings)
for x in str.serialize():
print x
The elements passed to the template are of the form:
el = '<element p:attribute="something"><child/>...</element>'
However, in the output, even if the list from which to generate elements is empty, genshi seems to remove the xmlns:p declaration from my root element, and add p: attributes to all the elements in the template (but not the ones passed by generate() ).
Basically, it looks like this:
<p:my_output
xmlns="http://some-address.com/sub/nr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=http://some-address.com/sub/nr
http://some-address.com/sub/nr/src/xml/file.xsd" p:majorVersion="0"
p:minorVersion="00" p:version="version 0.00">
<p:elements xmlns:py="http://genshi.edgewall.org/">
etcetera.
Is this expected behaviour? And if yes, what should I do to have the attributes remain in place?
cheers,
jorrit
--
You received this message because you are subscribed to the Google Groups "Genshi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genshi+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/genshi.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Genshi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to genshi+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/genshi.
For more options, visit https://groups.google.com/groups/opt_out.