Re: [xslt] Python bindings, escaping problems

On Fri, Jan 14, 2005 at 11:35:34AM +0000, Neil Dunn wrote:
> As an example from this page:
> When applying a stylesheet to a document with string parameters you 
> have to do something like so:
> result = style.applyStylesheet(doc, { "bar": "'success'" })
> The comment about double quoting is:
> 	Note that the string passed "success" had to be quoted, otherwise it 
> is interpreted as an XPath query for the childs of root named 
> "success".
> Therefore I cannot do something as follows:
> result = style.applyStylesheet(doc, { "bar": "'dog\'s'" })

  use """ .... """ python construct, it's really basic and the usual
way to avoid this.

   style.applyStylesheet(doc, { "bar": """"dog's"""" })
this should pass down "dog's" as the string.

> If there is no way of passing in a document fragment as a string in 
> this way I'm going to have to write a lot more code for what should be 
> a simple thing, so I was hoping there was an easy answer to my escaping 
> problems.

  The correct way to pass XML markup is with document(). Passing 
a fragment that way won't work properly IMHO.


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]