blob: 65f63c3db4c50f7c9f27fc8bce289a7c6b4ff4f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
using Mammoth.Couscous.java.io;
using Mammoth.Couscous.java.util;
using System.Xml;
namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing {
internal static class SimpleSax {
internal static void parseStream(InputStream input, SimpleSaxHandler handler) {
var reader = XmlReader.Create(input.Stream);
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
var name = new ElementName(reader.NamespaceURI, reader.LocalName);
var attributes = new HashMap<ElementName, string>();
var isEmpty = reader.IsEmptyElement;
for (int attributeIndex = 0; attributeIndex < reader.AttributeCount; attributeIndex++) {
reader.MoveToAttribute(attributeIndex);
attributes.put(new ElementName(reader.NamespaceURI, reader.LocalName), reader.Value);
}
handler.startElement(name, attributes);
if (isEmpty) {
handler.endElement();
}
break;
case XmlNodeType.CDATA:
case XmlNodeType.Text:
case XmlNodeType.SignificantWhitespace:
handler.characters(reader.Value);
break;
case XmlNodeType.EntityReference:
throw new System.NotImplementedException();
case XmlNodeType.EndElement:
handler.endElement();
break;
}
}
}
internal static void parseString(string value, SimpleSaxHandler handler) {
throw new System.NotImplementedException();
}
}
}
|