1 #vim:ts=2 sw=2 noexpandtab:
8 # * Work! Not all types of attlists are intelligently parsed, so we just
9 # spew back out what we get in. This works, but it would be better if
10 # we formatted the output ourselves.
12 # AttlistDecls provide *just* enough support to allow namespace
13 # declarations. If you need some sort of generalized support, or have an
14 # interesting idea about how to map the hideous, terrible design of DTD
15 # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate
16 # for anything to make DTDs more palateable.
17 class AttlistDecl < Child
20 # What is this? Got me.
21 attr_reader :element_name
23 # Create an AttlistDecl, pulling the information from a Source. Notice
24 # that this isn't very convenient; to create an AttlistDecl, you basically
25 # have to format it yourself, and then have the initializer parse it.
26 # Sorry, but for the forseeable future, DTD support in REXML is pretty
27 # weak on convenience. Have I mentioned how much I hate DTDs?
28 def initialize(source)
30 if (source.kind_of? Array)
31 @element_name, @pairs, @contents = *source
35 # Access the attlist attribute/value pairs.
36 # value = attlist_decl[ attribute_name ]
41 # Whether an attlist declaration includes the given attribute definition
42 # if attlist_decl.include? "xmlns:foobar"
44 @pairs.keys.include? key
47 # Iterate over the key/value pairs:
48 # attlist_decl.each { |attribute_name, attribute_value| ... }
53 # Write out exactly what we got in.
54 def write out, indent=-1