1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Just for fun also parse <?xml-stylesheet attributes

This commit is contained in:
Jonas Fonseca 2005-12-31 03:13:39 +01:00 committed by Jonas Fonseca
parent b2295572fe
commit 4a766f350b
4 changed files with 20 additions and 11 deletions

View File

@ -151,9 +151,7 @@ parse_sgml_attributes(struct dom_stack *stack, struct dom_scanner *scanner)
assert(dom_scanner_has_tokens(scanner)
&& (get_dom_scanner_token(scanner)->type == SGML_TOKEN_ELEMENT_BEGIN
|| (get_dom_stack_top(stack)->node->type == DOM_NODE_PROCESSING_INSTRUCTION
&& get_dom_stack_top(stack)->node->data.proc_instruction.type
== DOM_PROC_INSTRUCTION_XML)));
|| (get_dom_stack_top(stack)->node->type == DOM_NODE_PROCESSING_INSTRUCTION)));
if (get_dom_scanner_token(scanner)->type == SGML_TOKEN_ELEMENT_BEGIN)
skip_dom_scanner_token(scanner);
@ -279,6 +277,7 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
skip_dom_scanner_token(scanner);
break;
case SGML_TOKEN_PROCESS_XML_STYLESHEET:
case SGML_TOKEN_PROCESS_XML:
case SGML_TOKEN_PROCESS:
copy_struct(&target, token);
@ -290,7 +289,8 @@ parse_sgml_plain(struct dom_stack *stack, struct dom_scanner *scanner)
assert(token->type == SGML_TOKEN_PROCESS_DATA);
if (add_sgml_proc_instruction(stack, &target, token)
&& target.type == SGML_TOKEN_PROCESS_XML
&& (target.type == SGML_TOKEN_PROCESS_XML
|| target.type == SGML_TOKEN_PROCESS_XML_STYLESHEET)
&& token->string.length > 0) {
/* Parse the <?xml data="attributes"?>. */
struct dom_scanner attr_scanner;

View File

@ -47,13 +47,14 @@ static struct dom_scan_table_info sgml_scan_table_info[] = {
{ INIT_DOM_STRING(str, -1), SGML_TOKEN_##type, SGML_TOKEN_##family }
static struct dom_scanner_string_mapping sgml_string_mappings[] = {
SGML_STRING_MAP("--", NOTATION_COMMENT, NOTATION),
SGML_STRING_MAP("ATTLIST", NOTATION_ATTLIST, NOTATION),
SGML_STRING_MAP("DOCTYPE", NOTATION_DOCTYPE, NOTATION),
SGML_STRING_MAP("ELEMENT", NOTATION_ELEMENT, NOTATION),
SGML_STRING_MAP("ENTITY", NOTATION_ENTITY, NOTATION),
SGML_STRING_MAP("--", NOTATION_COMMENT, NOTATION),
SGML_STRING_MAP("ATTLIST", NOTATION_ATTLIST, NOTATION),
SGML_STRING_MAP("DOCTYPE", NOTATION_DOCTYPE, NOTATION),
SGML_STRING_MAP("ELEMENT", NOTATION_ELEMENT, NOTATION),
SGML_STRING_MAP("ENTITY", NOTATION_ENTITY, NOTATION),
SGML_STRING_MAP("xml", PROCESS_XML, PROCESS),
SGML_STRING_MAP("xml", PROCESS_XML, PROCESS),
SGML_STRING_MAP("xml-stylesheet", PROCESS_XML_STYLESHEET, PROCESS),
DOM_STRING_MAP_END,
};

View File

@ -29,6 +29,7 @@ enum sgml_token_type {
SGML_TOKEN_PROCESS, /* <?{ident} */
SGML_TOKEN_PROCESS_XML, /* <?xml */
SGML_TOKEN_PROCESS_XML_STYLESHEET,/* <?xml-stylesheet */
SGML_TOKEN_PROCESS_DATA, /* data after <?{ident} until ?> */
SGML_TOKEN_ELEMENT, /* <{ident}> */

View File

@ -148,7 +148,6 @@ entity-reference: #
#text: -
entity-reference: #xx'
# Test <?>
test_output_equals \
'Parse processing instructions.' \
'<?xml encoding="UTF8"?>
@ -170,6 +169,14 @@ proc-instruction: xml -> version="1.0" />
attribute: version -> 1.0
proc-instruction: xml -> /'
test_output_equals \
'Parse XML stylesheet processing instructions.' \
'<?xml-stylesheet type="text/xsl" href="url"?>' \
'
proc-instruction: xml-stylesheet -> type="text/xsl" href="url"
attribute: type -> text/xsl
attribute: href -> url'
test_output_equals \
'Parse exotic processing instructions.' \
'<?xml ?+>+?>-?>-<?js?>-<??>-' \