Greetings.

Alternatively, it would probably be good to add a new keyword argument
to function write() to xml.etree.ElementTree.

    def write(self, file_or_filename,
              encoding=None,
              xml_declaration=None,
              default_namespace=None,
              method=None, *,
              short_empty_elements=True,
              xslt_stylesheet=None):

Keyword argument xslt_stylesheet would only need to include filename
(that is, pathname) or basename, as developer requires.

Where is the best appropriate venue to ask for such enhancement?

Kind regards,
Schimon

On Sat, 14 Jun 2025 21:33:52 +0300
Schimon Jehudah via lxml - The Python XML Toolkit <lxml@python.org>
wrote:

> Greetings.
> 
> This code:
> 
> import xml.etree.ElementTree as ET
> 
> e_feed = ET.Element("feed")
> e_feed.set("xmlns", "http://www.w3.org/2005/Atom";)
> xslt_reference = ET.ProcessingInstruction(
>     "xml-stylesheet",
>     "type=\"text/xml\" href=\"stylesheet.xsl\"")
> e_feed.insert(0, xslt_reference)
> 
> Would yield this result:
> 
> <feed xmlns="http://www.w3.org/2005/Atom";>
> <?xml-stylesheet type="text/xml" href="stylesheet.xsl"?>
> </feed>
> 
> Would it be sensible to allow a negative value:
> 
> e_feed.insert(-1, xslt_reference)
> 
> So that the result be:
> 
> <?xml-stylesheet type="text/xml" href="stylesheet.xsl"?>
> <feed xmlns="http://www.w3.org/2005/Atom";>
> </feed>
> 
> Regards,
> Schimon
> 
_______________________________________________
lxml - The Python XML Toolkit mailing list -- lxml@python.org
To unsubscribe send an email to lxml-le...@python.org
https://mail.python.org/mailman3//lists/lxml.python.org
Member address: arch...@mail-archive.com

Reply via email to