Re: [xml] libxml2 add <p> tag



Manuel Guesdon wrote:
I understand. Even having the possibility to add tags in html40ElementTable probably won't solve files like <html> <gsweb name="MyBodyElement>.... </gsweb> </html>

Thank you for your help. I'll see how to deal with this.

Manuel, your problem is that you use an HTML parser for a file which is not a HTML resource even though it looks like one and is named .html (a WebObjects template). libxml always parses full HTML documents, not parts of them and it always produces valid HTML document tree's in memory. Since WebObjects components are often only fragments of an HTML page (this is why they are called components ;-) it won't work very well with a HTML document parser.

Besides this, you need to understand that WebObjects component .html files are not HTML files at all ! The WebObjects template parser only looks for a single tag "WEBOBJECT":

  <WEBOBJECT NAME="abc">...</WEBOBJECT>

For example this is a perfectly valid WebObject tag (see WOActionURL):

  <a href="<WEBOBJECT NAME="MyURL"></WEBOBJECT>">mylink</a>

but will obviously break any HTML and even XML parser. Another thing which is handled by libxml but passed through by the WO parser are entities. Because WO only replaces WEBOBJECT in the templates it can also be used to generate almost any kind of textfile, not only HTML (eg iCalendar or XML). If you are using a full HTML parser you will loose this capability !

I really suggest that you drop using libxml for parsing GNUstepWeb templates and write an own, real WO parser instead. It's a really simple task (only one tag with one attribute to parse !) and will provide you with proper WO compatibility and much more flexibility.

Greetings
  Helge




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