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

Re: [xml] SAX parsing



matthias pieroth t-online de writes:
 > cbozeman hiwaay net schrieb:
 > > You seem to be confused. The result (res) of
 > > xsltApplyStylesheet is an in 
 > > memory document, i.e it is already parsed. As Daniel
 > > stated previously, all 
 > > you need to do is walk the tree to get the information
 > > you want.
 > 
 > Yes, I know, but isn't this less efficient than using SAX.

        This doesn't make much sense - SAX is used for parsing an XML
file; what you do with the information in the file is up to you. One
of the options is building a tree structure representation of the
document.

        An XML tree structure is handy for working with documents. One
of the operations you might perform on such a structure would be to
serialize (print) it. Another would be to apply an XSLT transform,
which would give you a new XML tree (as long as you're using the 'xml'
output method).

        Note that the methods in libxml2/libxslt for applying
stylesheets and serializing documents assume a particular tree
structure. Building this tree structure yourself is a lot of work.
Fortunately, it is not necessary, as you can just use xmlParseFile
instead.

 > And I want to know how I can apply a stylesheet on an xmltree (not a
 > file). Can you tell me how I can do this?

        Take a look at the source code for xsltproc (xsltproc.c); this
gives you *exactly* the sequence of operations you need.

 > In the tutorial is only this mentioned:
 > 
 > cur = xsltParseStylesheetFile((const xmlChar *)argv[i]);

        This is used for setting up the XSLT stylesheet structure.
There are other ways of doing this, including using xmlParseFile and
xslParseStylesheetDoc. Once you have a stylesheet structure, you can
apply the stylesheet to an XML document - from a file, or from an XML
tree that has been built from a call to xmlParseFile.

-- 
Raymond Wiker                        Mail:  Raymond Wiker fast no
Senior Software Engineer             Web:   http://www.fast.no/
Fast Search & Transfer ASA           Phone: +47 23 01 11 60
P.O. Box 1677 Vika                   Fax:   +47 35 54 87 99
NO-0120 Oslo, NORWAY                 Mob:   +47 48 01 11 60

Try FAST Search: http://alltheweb.com/




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