[lxml-dev] Adding a Stylesheet PI when creating new XML documents
Lee Brown
lee.brown at elecdev.com
Thu Mar 22 21:42:02 CET 2007
Greetings!
I think the prependPI() is slightly better, as it is reminiscent of the append()
method.
Here's a silly thought:
Couldn't we just save any PIs preceeding the root element as members of docinfo?
That's where the doctype, xml version, and other "pre-root" stuff lives.
Doesn't "tree.docinfo.stylesheet" or "tree.docinfo.PI['stylesheet']" make more
sense than the way we're doing it now?
(And wouldn't it have been nice if I'd thought of this several months ago?)
-----Original Message-----
From: Stefan Behnel [mailto:stefan_ml at behnel.de]
Sent: Thursday, March 22, 2007 2:23 PM
To: Lee Brown
Cc: lxml-dev at codespeak.net
Subject: Re: [lxml-dev] Adding a Stylesheet PI when creating new XML documents
Hi!
Lee Brown wrote:
> Parsing an XSLT stylesheet from an xml-stylesheet PI is working just
> fine, but now I'm trying to add an xml-stylesheet PI to a new XML tree
> created from within lxml. I've looked back through the list traffic
> and done some code introspection but I can't find anything.
>
> Did we ever decide upon / create an API for adding a stylesheet PI to
> a new tree?
No, not yet. :)
I see two possibilities: add a "prependPI(pi)" method to ElementTree, or add a
method "addToTree(tree)" method to ProcessingInstruction. We might then also
need a way to get rid of them again - although, well, you could always move them
to a different tree, which would obviously remove them from the current one.
Ok, so any preferences?
Stefan
More information about the lxml-dev
mailing list