Re: [xslt] XSLT transformation to Plain Text using Python bindingsrequires using children().serialize()?


Thanks for the quick response...

Le grande pinguin wrote:
> On Thu, Aug 22, 2002 at 09:00:05PM -0400, Craeg K Strong wrote:
>>The problem is this:
>>- the result of applyStylesheet always returns an instance of
> Where is the problem? That's what is is supposed to return.

I understand, but this is confusing, especially for a newbie.  For example,
I use XSLT to generate Python code from XML.  And I am
supposed to retrieve my Python code from an object called "xmlDoc"???
This is non-intuitive IMO.

I also sometimes generate HTML that is not XHTML compliant. This is,
of course, not legal XML, and therefore strange to be retrieved
from an object called "xmlDoc"  unless "xmlDoc" is meant to be
viewed as "a document of some kind produced by libxml"
(a rather liberal interpretation...)

>>- some of my stylesheets specify html or plain text
>>-  for plain text, xmlDoc.serialize() prints
>>out an XML header
> Hmm, i just built a small test case and can _not_ verify this.
> What's the version of your libxslt? Can you provide us with a 
> little test case? Are your shure you didn't forget the 
> 'omit-xml-declaration="yes"' attribute in the xsl:output tag?

I included my test case (xml, xslt, and python code) in the original message--
let me know if you didn't get it via private email, I don't want to
spam the list unecessarily...

I am using the RPMs that were just released today.
I installed all of the packages:


on Red Hat Linux 7.2

I am using xsl:output method="text".   I don't believe it is
meaningful to say "omit-xml-declaration" when the method is
text..(not sure what the spec says, though).  Anyways, I tried
serialize() both with and without "omit-xml-declaration" and I get
<?xml version="1.0" encoding="ascii"?> regardless.

>>Perhaps there is some way to query the xmlDoc to
>>find the content type?  Or should one always use
>>children().serialize() instead?
> What do you mean by 'content-type' ? That's a concept of HTTP
> and not of XML. The content type is part of the semantic of a 
> document (an text/html page _can_ be valid XML) and the library
> has no idea about that. Or do you want to know the output type
> (xml/html/text)?

Yes.  I want the output type-- something like the following:

if resultDoc.type == "document_html":
             result = resultDoc.serialize('ascii', 1)
         elif type == "document_xml":
             result = resultDoc.serialize('ascii', 1)
         elif type == "document_text":
             result = resultDoc.children.serialize('ascii', 1)

Obviously, this code will not compile today, because
the only choices are XML and HTML.  Am I missing something
or is the API missing something?

Thanks again,

--Craeg Strong

>  Ralf Mattes

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