Class: Xpp
- Inherits:
-
Object
- Object
- Xpp
- Defined in:
- lib/xamplr-pp/xpp.rb,
lib/xamplr-pp/xppIter.rb,
lib/xamplr-pp/xppDeluxe.rb
Constant Summary collapse
- START_DOCUMENT =
XML ‘event’ types
'START_DOCUMENT'
- END_DOCUMENT =
'END_DOCUMENT'
- START_ELEMENT =
'START_ELEMENT'
- END_ELEMENT =
'END_ELEMENT'
- TEXT =
'TEXT'
- CDATA_SECTION =
'CDATA_SECTION'
- ENTITY_REF =
'ENTITY_REF'
- IGNORABLE_WHITESPACE =
'IGNORABLE_WHITESPACE'
- PROCESSING_INSTRUCTION =
'PROCESSING_INSTRUCTION'
- COMMENT =
'COMMENT'
- DOCTYPE =
'DOCTYPE'
- UNDECIDED_TYPE =
'UNDECIDED_TYPE'
- LOOK_FURTHER =
'LOOK_FURTHER'
Instance Attribute Summary collapse
-
#attributeName ⇒ Object
readonly
Returns the value of attribute attributeName.
-
#attributeNamespace ⇒ Object
readonly
Returns the value of attribute attributeNamespace.
-
#attributePrefix ⇒ Object
readonly
Returns the value of attribute attributePrefix.
-
#attributeQName ⇒ Object
readonly
Returns the value of attribute attributeQName.
-
#attributeValue ⇒ Object
readonly
Returns the value of attribute attributeValue.
-
#checkWellFormed ⇒ Object
Returns the value of attribute checkWellFormed.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#elementName ⇒ Object
readonly
open element information.
-
#elementNamespace ⇒ Object
readonly
Returns the value of attribute elementNamespace.
-
#elementNamespaceDefaultStack ⇒ Object
readonly
Returns the value of attribute elementNamespaceDefaultStack.
-
#elementNamespacePrefixStack ⇒ Object
readonly
Returns the value of attribute elementNamespacePrefixStack.
-
#elementNamespaceValueStack ⇒ Object
readonly
Returns the value of attribute elementNamespaceValueStack.
-
#elementPrefix ⇒ Object
readonly
Returns the value of attribute elementPrefix.
-
#elementQName ⇒ Object
readonly
Returns the value of attribute elementQName.
-
#emptyElement ⇒ Object
readonly
Returns the value of attribute emptyElement.
-
#entityMap ⇒ Object
the entities that we will recognise.
-
#line ⇒ Object
readonly
some information about where we are.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namePattern ⇒ Object
some pre-compiled patterns.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#processNamespace ⇒ Object
‘Features’, acutally just processing options.
-
#qname ⇒ Object
readonly
Returns the value of attribute qname.
-
#reportNamespaceAttributes ⇒ Object
Returns the value of attribute reportNamespaceAttributes.
-
#resolver ⇒ Object
Returns the value of attribute resolver.
-
#skipWhitespacePattern ⇒ Object
Returns the value of attribute skipWhitespacePattern.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
element information.
-
#unresolvedEntity ⇒ Object
readonly
Returns the value of attribute unresolvedEntity.
-
#utf8encode ⇒ Object
Returns the value of attribute utf8encode.
-
#whitespace ⇒ Object
readonly
is the current text whitespace?.
Instance Method Summary collapse
- #cdata? ⇒ Boolean
- #comment? ⇒ Boolean
- #doctype? ⇒ Boolean
- #endDocument? ⇒ Boolean
- #endElement? ⇒ Boolean
- #entityRef? ⇒ Boolean
- #ignorableWhitespace? ⇒ Boolean
- #initInput ⇒ Object
-
#input=(v) ⇒ Object
end.
- #lookFurther? ⇒ Boolean
- #nextEvent ⇒ Object
- #processingInstruction? ⇒ Boolean
- #startDocument? ⇒ Boolean
- #startElement? ⇒ Boolean
- #text? ⇒ Boolean
- #whitespace? ⇒ Boolean
Instance Attribute Details
#attributeName ⇒ Object (readonly)
Returns the value of attribute attributeName.
57 58 59 |
# File 'lib/xamplr-pp/xpp.rb', line 57 def attributeName @attributeName end |
#attributeNamespace ⇒ Object (readonly)
Returns the value of attribute attributeNamespace.
59 60 61 |
# File 'lib/xamplr-pp/xpp.rb', line 59 def attributeNamespace @attributeNamespace end |
#attributePrefix ⇒ Object (readonly)
Returns the value of attribute attributePrefix.
60 61 62 |
# File 'lib/xamplr-pp/xpp.rb', line 60 def attributePrefix @attributePrefix end |
#attributeQName ⇒ Object (readonly)
Returns the value of attribute attributeQName.
58 59 60 |
# File 'lib/xamplr-pp/xpp.rb', line 58 def attributeQName @attributeQName end |
#attributeValue ⇒ Object (readonly)
Returns the value of attribute attributeValue.
61 62 63 |
# File 'lib/xamplr-pp/xpp.rb', line 61 def attributeValue @attributeValue end |
#checkWellFormed ⇒ Object
Returns the value of attribute checkWellFormed.
38 39 40 |
# File 'lib/xamplr-pp/xpp.rb', line 38 def checkWellFormed @checkWellFormed end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
48 49 50 |
# File 'lib/xamplr-pp/xpp.rb', line 48 def column @column end |
#elementName ⇒ Object (readonly)
open element information
68 69 70 |
# File 'lib/xamplr-pp/xpp.rb', line 68 def elementName @elementName end |
#elementNamespace ⇒ Object (readonly)
Returns the value of attribute elementNamespace.
70 71 72 |
# File 'lib/xamplr-pp/xpp.rb', line 70 def elementNamespace @elementNamespace end |
#elementNamespaceDefaultStack ⇒ Object (readonly)
Returns the value of attribute elementNamespaceDefaultStack.
79 80 81 |
# File 'lib/xamplr-pp/xpp.rb', line 79 def elementNamespaceDefaultStack @elementNamespaceDefaultStack end |
#elementNamespacePrefixStack ⇒ Object (readonly)
Returns the value of attribute elementNamespacePrefixStack.
77 78 79 |
# File 'lib/xamplr-pp/xpp.rb', line 77 def elementNamespacePrefixStack @elementNamespacePrefixStack end |
#elementNamespaceValueStack ⇒ Object (readonly)
Returns the value of attribute elementNamespaceValueStack.
78 79 80 |
# File 'lib/xamplr-pp/xpp.rb', line 78 def elementNamespaceValueStack @elementNamespaceValueStack end |
#elementPrefix ⇒ Object (readonly)
Returns the value of attribute elementPrefix.
71 72 73 |
# File 'lib/xamplr-pp/xpp.rb', line 71 def elementPrefix @elementPrefix end |
#elementQName ⇒ Object (readonly)
Returns the value of attribute elementQName.
69 70 71 |
# File 'lib/xamplr-pp/xpp.rb', line 69 def elementQName @elementQName end |
#emptyElement ⇒ Object (readonly)
Returns the value of attribute emptyElement.
52 53 54 |
# File 'lib/xamplr-pp/xpp.rb', line 52 def emptyElement @emptyElement end |
#entityMap ⇒ Object
the entities that we will recognise
42 43 44 |
# File 'lib/xamplr-pp/xpp.rb', line 42 def entityMap @entityMap end |
#line ⇒ Object (readonly)
some information about where we are
47 48 49 |
# File 'lib/xamplr-pp/xpp.rb', line 47 def line @line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
53 54 55 |
# File 'lib/xamplr-pp/xpp.rb', line 53 def name @name end |
#namePattern ⇒ Object
some pre-compiled patterns
74 75 76 |
# File 'lib/xamplr-pp/xpp.rb', line 74 def namePattern @namePattern end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
55 56 57 |
# File 'lib/xamplr-pp/xpp.rb', line 55 def namespace @namespace end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
56 57 58 |
# File 'lib/xamplr-pp/xpp.rb', line 56 def prefix @prefix end |
#processNamespace ⇒ Object
‘Features’, acutally just processing options
36 37 38 |
# File 'lib/xamplr-pp/xpp.rb', line 36 def processNamespace @processNamespace end |
#qname ⇒ Object (readonly)
Returns the value of attribute qname.
54 55 56 |
# File 'lib/xamplr-pp/xpp.rb', line 54 def qname @qname end |
#reportNamespaceAttributes ⇒ Object
Returns the value of attribute reportNamespaceAttributes.
37 38 39 |
# File 'lib/xamplr-pp/xpp.rb', line 37 def reportNamespaceAttributes @reportNamespaceAttributes end |
#resolver ⇒ Object
Returns the value of attribute resolver.
44 45 46 |
# File 'lib/xamplr-pp/xpp.rb', line 44 def resolver @resolver end |
#skipWhitespacePattern ⇒ Object
Returns the value of attribute skipWhitespacePattern.
75 76 77 |
# File 'lib/xamplr-pp/xpp.rb', line 75 def skipWhitespacePattern @skipWhitespacePattern end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
63 64 65 |
# File 'lib/xamplr-pp/xpp.rb', line 63 def text @text end |
#type ⇒ Object (readonly)
element information
51 52 53 |
# File 'lib/xamplr-pp/xpp.rb', line 51 def type @type end |
#unresolvedEntity ⇒ Object (readonly)
Returns the value of attribute unresolvedEntity.
43 44 45 |
# File 'lib/xamplr-pp/xpp.rb', line 43 def unresolvedEntity @unresolvedEntity end |
#utf8encode ⇒ Object
Returns the value of attribute utf8encode.
39 40 41 |
# File 'lib/xamplr-pp/xpp.rb', line 39 def utf8encode @utf8encode end |
#whitespace ⇒ Object (readonly)
is the current text whitespace?
30 31 32 |
# File 'lib/xamplr-pp/xppIter.rb', line 30 def whitespace @whitespace end |
Instance Method Details
#cdata? ⇒ Boolean
102 103 104 |
# File 'lib/xamplr-pp/xpp.rb', line 102 def cdata? @type.equal? CDATA_SECTION end |
#comment? ⇒ Boolean
122 123 124 |
# File 'lib/xamplr-pp/xpp.rb', line 122 def comment? @type.equal? COMMENT end |
#doctype? ⇒ Boolean
126 127 128 |
# File 'lib/xamplr-pp/xpp.rb', line 126 def doctype? @type.equal? DOCTYPE end |
#endDocument? ⇒ Boolean
86 87 88 |
# File 'lib/xamplr-pp/xpp.rb', line 86 def endDocument? @type.equal? END_DOCUMENT end |
#endElement? ⇒ Boolean
94 95 96 |
# File 'lib/xamplr-pp/xpp.rb', line 94 def endElement? @type.equal? END_ELEMENT end |
#entityRef? ⇒ Boolean
106 107 108 |
# File 'lib/xamplr-pp/xpp.rb', line 106 def entityRef? @type.equal? ENTITY_REF end |
#ignorableWhitespace? ⇒ Boolean
110 111 112 |
# File 'lib/xamplr-pp/xpp.rb', line 110 def ignorableWhitespace? @type.equal? IGNORABLE_WHITESPACE end |
#initInput ⇒ Object
183 184 185 |
# File 'lib/xamplr-pp/xpp.rb', line 183 def initInput # override this if needed end |
#input=(v) ⇒ Object
end
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/xamplr-pp/xppIter.rb', line 114 def input=(v) if nil == v then @input = nil @inputBuffer = nil @inputBufferLength = 0 @column = 0 @line = 0 elsif v.kind_of? String then @input = nil @inputBuffer = v @inputBufferLength = v.length @line = 1 @column = 0 elsif v.kind_of? IO then @input = v @inputBuffer = nil @inputBufferLength = 0 @column = 0 @line = 0 else raise "illegalInput" end @nextInputBuffer = nil @textBuffer = '' @elementNamespacePrefixStack = [] @elementNamespaceValueStack = [] @elementNamespaceDefaultStack = [] @elementName = [] @elementQName = [] @elementNamespace = [] @elementPrefix = [] @type = START_DOCUMENT @unresolvedEntity = false @name = nil @namespace = nil @attributeName = [] @attributeQName = [] @attributeNamespace = [] @attributePrefix = [] @attributeValue = [] @emptyElement = false @haveRoot = false initInput end |
#lookFurther? ⇒ Boolean
101 102 103 |
# File 'lib/xamplr-pp/xppIter.rb', line 101 def lookFurther? @type.equal? LOOK_FURTHER end |
#nextEvent ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/xamplr-pp/xpp.rb', line 187 def nextEvent begin @type = END_DOCUMENT if (nil == @inputBuffer) and (nil == @input) then #if END_DOCUMENT == @type then return @type #end #raise "no input defined" end @unresolvedEntity = false @text = nil parseNextEvent return @type rescue Exception => #print message.backtrace.join("\n") if nil != @inputBuffer then = sprintf("parse error: '%s' -- String input, line %d, column %d", , @line, @column) elsif nil != @input then if @input.kind_of? File then = sprintf("parse error: '%s' -- file '%s', line %d, column %d", , @input.path, @line, @column) else = sprintf("parse error: '%s' -- unnamed IO stream, line %d, column %d", , @line, @column) end else = sprintf("parse error: '%s' -- unknown source, line %d, column %d", , @line, @column) end raise end end |
#processingInstruction? ⇒ Boolean
118 119 120 |
# File 'lib/xamplr-pp/xpp.rb', line 118 def processingInstruction? @type.equal? PROCESSING_INSTRUCTION end |
#startDocument? ⇒ Boolean
82 83 84 |
# File 'lib/xamplr-pp/xpp.rb', line 82 def startDocument? @type.equal? START_DOCUMENT end |
#startElement? ⇒ Boolean
90 91 92 |
# File 'lib/xamplr-pp/xpp.rb', line 90 def startElement? @type.equal? START_ELEMENT end |
#whitespace? ⇒ Boolean
114 115 116 |
# File 'lib/xamplr-pp/xpp.rb', line 114 def whitespace? nil == @text.index(@skipWhitespacePattern) end |