1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-25 01:05:37 +00:00

Add basic stuff for XBEL parsing/highlighting using the DOM engine

This commit is contained in:
Jonas Fonseca 2005-12-30 22:19:32 +01:00 committed by Jonas Fonseca
parent 66248849cd
commit 9a0bf83756
12 changed files with 241 additions and 2 deletions

View File

@ -242,7 +242,10 @@ render_encoded_document(struct cache_entry *cached, struct document *document)
#ifdef CONFIG_DOM
if (cached->content_type
&& (!strlcasecmp("text/html", 9, cached->content_type, -1)
|| !strlcasecmp("application/rss+xml", 19, cached->content_type, -1)))
|| !strlcasecmp("application/rss+xml", 19, cached->content_type, -1)
|| !strlcasecmp("application/xbel+xml", 20, cached->content_type, -1)
|| !strlcasecmp("application/x-xbel", 18, cached->content_type, -1)
|| !strlcasecmp("application/xbel", 16, cached->content_type, -1)))
render_dom_document(cached, document, &buffer);
else
#endif

View File

@ -1,7 +1,7 @@
top_builddir=../../..
include $(top_builddir)/Makefile.config
SUBDIRS = html rss
SUBDIRS = html rss xbel
OBJS = sgml.o parser.o scanner.o
include $(top_srcdir)/Makefile.lib

View File

@ -18,6 +18,7 @@
#include "dom/sgml/html/html.h"
#include "dom/sgml/rss/rss.h"
#include "dom/sgml/xbel/xbel.h"
int
@ -32,6 +33,7 @@ sgml_info_strcmp(const void *key_, const void *node_)
struct sgml_info *sgml_info[SGML_DOCTYPES] = {
&sgml_html_info,
&sgml_rss_info,
&sgml_xbel_info,
};
struct sgml_info *

View File

@ -78,6 +78,7 @@ get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node)
enum sgml_document_type {
SGML_DOCTYPE_HTML,
SGML_DOCTYPE_RSS,
SGML_DOCTYPE_XBEL,
SGML_DOCTYPES,
};

View File

@ -0,0 +1,6 @@
top_builddir=../../../..
include $(top_builddir)/Makefile.config
OBJS = xbel.o
include $(top_srcdir)/Makefile.lib

View File

@ -0,0 +1,14 @@
/* XBEL attributes */
/* http://pyxml.sourceforge.net/topics/xbel/docs/html/public-text.html */
#undef VERSION
XBEL_(ATTRIBUTE, ADDED, 0),
XBEL_(ATTRIBUTE, FOLDED, 0),
XBEL_(ATTRIBUTE, HREF, SGML_ATTRIBUTE_REFERENCE),
XBEL_(ATTRIBUTE, ID, SGML_ATTRIBUTE_IDENTIFIER),
XBEL_(ATTRIBUTE, MODIFIED, 0),
XBEL_(ATTRIBUTE, OWNER, 0),
XBEL_(ATTRIBUTE, REF, 0),
XBEL_(ATTRIBUTE, VERSION, 0),
XBEL_(ATTRIBUTE, VISITED, 0),

View File

@ -0,0 +1,12 @@
/* XBEL elements */
/* http://pyxml.sourceforge.net/topics/xbel/docs/html/public-text.html */
XBEL_(ELEMENT, ALIAS, SGML_ELEMENT_EMPTY),
XBEL_(ELEMENT, BOOKMARK, 0),
XBEL_(ELEMENT, DESC, 0),
XBEL_(ELEMENT, FOLDER, 0),
XBEL_(ELEMENT, INFO, 0),
XBEL_(ELEMENT, METADATA, 0),
XBEL_(ELEMENT, SEPARATOR, 0),
XBEL_(ELEMENT, TITLE, 0),
XBEL_(ELEMENT, XBEL, 0),

35
src/dom/sgml/xbel/xbel.c Normal file
View File

@ -0,0 +1,35 @@
/* SGML node handling */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "dom/sgml/xbel/xbel.h"
#include "dom/sgml/sgml.h"
#define XBEL_(node, name, id) SGML_NODE_INFO(XBEL, node, name, id)
static struct sgml_node_info xbel_attributes[XBEL_ATTRIBUTES] = {
SGML_NODE_HEAD(XBEL, ATTRIBUTE),
#include "dom/sgml/xbel/attribute.inc"
};
static struct sgml_node_info xbel_elements[XBEL_ELEMENTS] = {
SGML_NODE_HEAD(XBEL, ELEMENT),
#include "dom/sgml/xbel/element.inc"
};
struct sgml_info sgml_xbel_info = {
SGML_DOCTYPE_XBEL,
xbel_attributes,
xbel_elements,
};

28
src/dom/sgml/xbel/xbel.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef EL_DOM_SGML_XBEL_XBEL_H
#define EL_DOM_SGML_XBEL_XBEL_H
#include "dom/sgml/sgml.h"
extern struct sgml_info sgml_xbel_info;
#define XBEL_(node, name, flags) SGML_NODE_INFO_TYPE(XBEL, node, name)
enum xbel_element_type {
XBEL_ELEMENT_UNKNOWN,
#include "dom/sgml/xbel/element.inc"
XBEL_ELEMENTS,
};
enum xbel_attribute_type {
XBEL_ATTRIBUTE_UNKNOWN,
#include "dom/sgml/xbel/attribute.inc"
XBEL_ATTRIBUTES,
};
#undef XBEL_
#endif

View File

@ -99,6 +99,7 @@ static struct option_info default_mime_options[] = {
#endif
#ifdef CONFIG_DOM
INIT_OPT_MIME_EXTENSION("rss", "application/rss+xml"),
INIT_OPT_MIME_EXTENSION("xbel", "application/xbel+xml"),
#endif
NULL_OPTION_INFO,

View File

@ -1148,6 +1148,9 @@ struct {
{ "application/xhtml+xml", 0 }, /* RFC 3236 */
#if CONFIG_DOM
{ "application/rss+xml", 1 },
{ "application/xbel+xml", 1 },
{ "application/xbel", 1 },
{ "application/x-xbel", 1 },
#endif
{ "text/plain", 1 },
{ NULL, 1 },

134
test/xbel/favorez.xbel Normal file
View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="ISO8859-1" ?>
<?xml-stylesheet type="text/xsl" href="op_my_favorites.xsl"?>
<!DOCTYPE xbel PUBLIC
"+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML"
"http://www.python.org/topics/xml/dtds/xbel-1.0.dtd"
[
<!ENTITY % local.url.att "favicon CDATA '01.png' target CDATA '_blank'">
]>
<xbel version="1.0">
<title>Administrator Favorieten</title>
<info><metadata owner="Administrator"/></info>
<desc>Administrator favorite bookmarks</desc>
<folder id="f0">
<title>top</title>
<folder id="f3">
<title>Inside Netscape</title>
<bookmark href="http://home.netscape.com/bookmark/4_79/bbrowser.html" favicon="01.png" target="_self">
<title>Browser Central</title>
</bookmark>
<bookmark href="http://home.netscape.com/bookmark/4_79/bwebmail.html" favicon="01.png" target="_self">
<title>Free E-mail</title>
</bookmark>
<bookmark href="http://groups.google.com/groups?hl=en&amp;ie=UTF-8&amp;oe=UTF-8&amp;q=ACM_PLAY&amp;sa=N&amp;tab=wg" favicon="06.png" target="_self">
<title>Google Search ACM_PLAY</title>
</bookmark>
<bookmark href="http://home.netscape.com/bookmark/4_79/bnetscapechannel.html" favicon="01.png" target="_self">
<title>Netscape Information</title>
</bookmark>
<bookmark href="http://www.redhat.com/" favicon="07.png" target="_self">
<title>Red Hat -- Linux, Embedded Linux and Open Sou...</title>
</bookmark>
<bookmark href="http://home.netscape.com/bookmark/4_79/bshopnetscape.html" favicon="01.png" target="_self">
<title>Shop@Netscape</title>
</bookmark>
</folder>
<folder id="f21">
<title>XML</title>
<bookmark href="http://www.15seconds.com/Issue/010921.htm" favicon="01.png" target="_self">
<title>15 Seconds Advanced UI Design Using XML and ...</title>
</bookmark>
<bookmark href="http://www.bioml.com/BIOML/b_chpt4.htm" favicon="15.png" target="_self">
<title>BIOML - Chapter 4 Extending BIOML</title>
</bookmark>
<bookmark href="http://java.sun.com/webservices/docs/1.0/tutorial/doc/JavaWSTutorialTOC.html" favicon="16.png" target="_self">
<title>JavaWSTutorialTOC.html</title>
</bookmark>
<folder id="f25">
<title>namespaces</title>
<bookmark href="http://mail.python.org/pipermail/xml-sig/1998-October/000429.html" favicon="01.png" target="_self">
<title>[XML-SIG] XBEL documentation, draft</title>
</bookmark>
<bookmark href="http://www.w3.org/TR/REC-xml-names/" favicon="01.png" target="_self">
<title>Namespaces in XML</title>
</bookmark>
</folder>
<bookmark href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xpath_hdi_2_2d9v.asp" favicon="01.png" target="_self">
<title>Navigating Along the ancestor Axis</title>
</bookmark>
<bookmark href="http://www.cogsci.ed.ac.uk/~dmck/xmlperl/xslt-tutorial.html" favicon="01.png" target="_self">
<title>Producing HTML tables with XSLT</title>
</bookmark>
<bookmark href="http://www.stg.brown.edu/service/xmlvalid/" favicon="17.png" target="_self">
<title>STG XML Validation Form</title>
</bookmark>
<bookmark href="http://www.xefer.com/rebel/uris.html" favicon="18.png" target="_self">
<title>URIs and Ids</title>
</bookmark>
<bookmark href="http://www-106.ibm.com/developerworks/xml/library/x-xslrecur/?dwzone=xml" favicon="01.png" target="_self">
<title>Use recursion effectively in XSL</title>
</bookmark>
<bookmark href="http://icg.harvard.edu/~cscie12/xbel/" favicon="19.png" target="_self">
<title>XML Bookmark Exchange Language (XBEL) Informa...</title>
</bookmark>
<bookmark href="http://www.w3schools.com/dom/dom_validate.asp" favicon="20.png" target="_self">
<title>XML DOM - Validate XML</title>
</bookmark>
<bookmark href="http://www.xmlspy.com/features_convert.html" favicon="01.png" target="_self">
<title>XML Spy - Import, Export, and Convert XML dat...</title>
</bookmark>
<bookmark href="http://www.bluewell.nl/en/bwm/0110/ennl011026.htm" favicon="01.png" target="_self">
<title>XML The Language of B2B E-commerce</title>
</bookmark>
<bookmark href="http://www.w3schools.com/xsl/xsl_languages.asp" favicon="20.png" target="_self">
<title>XSL Languages</title>
</bookmark>
<bookmark href="http://xmlfiles.com/xsl/xsl_transformation.asp" favicon="21.png" target="_self">
<title>XSL Transformation</title>
</bookmark>
</folder>
<folder id="f10">
<title>JavaScript</title>
<bookmark href="http://www.ibm.com/us/" favicon="08.png" target="_self">
<title>IBM United States</title>
</bookmark>
<bookmark href="http://sourceforge.net/" favicon="09.png" target="_self">
<title>SourceForge.net Welcome</title>
</bookmark>
<folder id="f13">
<title>subfolder</title>
<bookmark href="http://www.microsoft.com/" favicon="01.png" target="_self">
<title>Microsoft Corporation</title>
</bookmark>
<folder id="f15">
<title>subsubfolder</title>
<bookmark href="http://www.mysql.com/" favicon="10.png" target="_self">
<title>MySQL The World&apos;s Most Popular Open Source Da...</title>
</bookmark>
</folder>
<bookmark href="http://www.warpgear.com/" favicon="11.png" target="_self">
<title>WarpGear Software</title>
</bookmark>
</folder>
<bookmark href="http://www.sun.com/" favicon="12.png" target="_self">
<title>Sun Microsystems</title>
</bookmark>
</folder>
<bookmark href="http://www.amazon.co.uk/exec/obidos/ASIN/B00006IIP1/ref=/t/026-3473547-1760408" favicon="04.png" target="_self">
<title>Amazon.co.uk At a glance IBM ViaVoice 10.0 Pr...</title>
</bookmark>
<bookmark href="http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20249274.html#1" favicon="05.png" target="_self">
<title>Delphi Programming Hide taskbar</title>
</bookmark>
<bookmark href="http://tronche.com/technotes/mpeg/#sequence-header" favicon="13.png" target="_self">
<title>MPEG-1 File Format Specification</title>
</bookmark>
<bookmark href="http://home.netscape.com/bookmark/4_79/ptyellow.html" favicon="01.png" target="_self">
<title>Yellow Pages</title>
</bookmark>
<bookmark href="http://www.nodedb.com/wiki/index.php?Nokia-C110" favicon="14.png" target="_self">
<title>NodeDB.com Wiki - Nokia-C110</title>
</bookmark>
</folder>
</xbel>