PageRenderTime 161ms CodeModel.GetById 153ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/Ruby/lib/ruby/1.8/rexml/streamlistener.rb

http://github.com/agross/netopenspace
Ruby | 92 lines | 32 code | 0 blank | 60 comment | 0 complexity | d6c573dfa676a3a2d7caea81f0fe7ee7 MD5 | raw file
 1module REXML
 2	# A template for stream parser listeners.
 3	# Note that the declarations (attlistdecl, elementdecl, etc) are trivially
 4	# processed; REXML doesn't yet handle doctype entity declarations, so you 
 5	# have to parse them out yourself.
 6	module StreamListener
 7		# Called when a tag is encountered.
 8		# @p name the tag name
 9		# @p attrs an array of arrays of attribute/value pairs, suitable for
10		# use with assoc or rassoc.  IE, <tag attr1="value1" attr2="value2">
11		# will result in 
12		# tag_start( "tag", # [["attr1","value1"],["attr2","value2"]])
13		def tag_start name, attrs
14		end
15		# Called when the end tag is reached.  In the case of <tag/>, tag_end
16		# will be called immidiately after tag_start
17		# @p the name of the tag
18		def tag_end name
19		end
20		# Called when text is encountered in the document
21		# @p text the text content.
22		def text text
23		end
24		# Called when an instruction is encountered.  EG: <?xsl sheet='foo'?>
25		# @p name the instruction name; in the example, "xsl"
26		# @p instruction the rest of the instruction.  In the example,
27		# "sheet='foo'"
28		def instruction name, instruction
29		end
30		# Called when a comment is encountered.
31		# @p comment The content of the comment
32		def comment comment
33		end
34		# Handles a doctype declaration. Any attributes of the doctype which are
35		# not supplied will be nil.  # EG, <!DOCTYPE me PUBLIC "foo" "bar">
36		# @p name the name of the doctype; EG, "me"
37		# @p pub_sys "PUBLIC", "SYSTEM", or nil.  EG, "PUBLIC"
38		# @p long_name the supplied long name, or nil.  EG, "foo"
39		# @p uri the uri of the doctype, or nil.  EG, "bar"
40		def doctype name, pub_sys, long_name, uri
41		end
42		# Called when the doctype is done
43		def doctype_end
44		end
45		# If a doctype includes an ATTLIST declaration, it will cause this
46		# method to be called.  The content is the declaration itself, unparsed.
47		# EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
48		# attr CDATA #REQUIRED".  This is the same for all of the .*decl
49		# methods.
50		def attlistdecl element_name, attributes, raw_content
51		end
52		# <!ELEMENT ...>
53		def elementdecl content
54		end
55		# <!ENTITY ...>
56		# The argument passed to this method is an array of the entity
57		# declaration.  It can be in a number of formats, but in general it
58		# returns (example, result):
59		#  <!ENTITY % YN '"Yes"'>  
60		#  ["%", "YN", "'\"Yes\"'", "\""]
61		#  <!ENTITY % YN 'Yes'>
62		#  ["%", "YN", "'Yes'", "s"]
63		#  <!ENTITY WhatHeSaid "He said %YN;">
64		#  ["WhatHeSaid", "\"He said %YN;\"", "YN"]
65		#  <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
66		#  ["open-hatch", "SYSTEM", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
67		#  <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
68		#  ["open-hatch", "PUBLIC", "\"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
69		#  <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
70		#  ["hatch-pic", "SYSTEM", "\"../grafix/OpenHatch.gif\"", "\n\t\t\t\t\t\t\tNDATA gif", "gif"]
71		def entitydecl content
72		end
73		# <!NOTATION ...>
74		def notationdecl content
75		end
76		# Called when %foo; is encountered in a doctype declaration.
77		# @p content "foo"
78		def entity content
79		end
80		# Called when <![CDATA[ ... ]]> is encountered in a document.
81		# @p content "..."
82		def cdata content
83		end
84		# Called when an XML PI is encountered in the document.
85		# EG: <?xml version="1.0" encoding="utf"?>
86		# @p version the version attribute value.  EG, "1.0"
87		# @p encoding the encoding attribute value, or nil.  EG, "utf"
88		# @p standalone the standalone attribute value, or nil.  EG, nil
89		def xmldecl version, encoding, standalone
90		end
91	end
92end