mirror of
https://github.com/GNOME/libxml2.git
synced 2025-04-06 19:20:23 +08:00
changed the generator to provide casing for the XmlTextReader similar to
* python/generator.py python/libxml2class.txt python/tests/reader.py python/tests/reader2.py: changed the generator to provide casing for the XmlTextReader similar to C# so that examples and documentation are more directly transposable. Fixed the couple of tests in the suite. Daniel
This commit is contained in:
parent
6943a4db3e
commit
aba976d825
@ -1,3 +1,11 @@
|
||||
Sat Dec 28 22:11:57 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* python/generator.py python/libxml2class.txt
|
||||
python/tests/reader.py python/tests/reader2.py: changed the
|
||||
generator to provide casing for the XmlTextReader similar to
|
||||
C# so that examples and documentation are more directly transposable.
|
||||
Fixed the couple of tests in the suite.
|
||||
|
||||
Sat Dec 28 15:55:32 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* doc/guidelines.html: added a document on guildeline for
|
||||
|
@ -681,7 +681,6 @@ def nameFixup(name, classe, type, file):
|
||||
func = "regexp" + name[6:]
|
||||
elif name[0:13] == "xmlTextReader" and file == "xmlreader":
|
||||
func = name[13:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
elif name[0:11] == "xmlACatalog":
|
||||
func = name[11:]
|
||||
func = string.lower(func[0:1]) + func[1:]
|
||||
|
@ -562,43 +562,43 @@ Class xmlAttr(xmlNode)
|
||||
Class xmlTextReader()
|
||||
|
||||
# functions from module xmlreader
|
||||
attributeCount()
|
||||
baseUri()
|
||||
close()
|
||||
depth()
|
||||
AttributeCount()
|
||||
BaseUri()
|
||||
Close()
|
||||
Depth()
|
||||
GetAttribute()
|
||||
GetAttributeNo()
|
||||
GetAttributeNs()
|
||||
GetParserProp()
|
||||
GetRemainder()
|
||||
HasAttributes()
|
||||
HasValue()
|
||||
IsDefault()
|
||||
IsEmptyElement()
|
||||
LocalName()
|
||||
LookupNamespace()
|
||||
MoveToAttribute()
|
||||
MoveToAttributeNo()
|
||||
MoveToAttributeNs()
|
||||
MoveToElement()
|
||||
MoveToFirstAttribute()
|
||||
MoveToNextAttribute()
|
||||
Name()
|
||||
NamespaceUri()
|
||||
NodeType()
|
||||
Normalization()
|
||||
Prefix()
|
||||
QuoteChar()
|
||||
Read()
|
||||
ReadAttributeValue()
|
||||
ReadInnerXml()
|
||||
ReadOuterXml()
|
||||
ReadState()
|
||||
ReadString()
|
||||
SetParserProp()
|
||||
Value()
|
||||
XmlLang()
|
||||
freeTextReader()
|
||||
getAttribute()
|
||||
getAttributeNo()
|
||||
getAttributeNs()
|
||||
getParserProp()
|
||||
getRemainder()
|
||||
hasAttributes()
|
||||
hasValue()
|
||||
isDefault()
|
||||
isEmptyElement()
|
||||
localName()
|
||||
lookupNamespace()
|
||||
moveToAttribute()
|
||||
moveToAttributeNo()
|
||||
moveToAttributeNs()
|
||||
moveToElement()
|
||||
moveToFirstAttribute()
|
||||
moveToNextAttribute()
|
||||
name()
|
||||
namespaceUri()
|
||||
nodeType()
|
||||
normalization()
|
||||
prefix()
|
||||
quoteChar()
|
||||
read()
|
||||
readAttributeValue()
|
||||
readInnerXml()
|
||||
readOuterXml()
|
||||
readState()
|
||||
readString()
|
||||
setParserProp()
|
||||
value()
|
||||
xmlLang()
|
||||
Class xmlReg()
|
||||
|
||||
# functions from module xmlregexp
|
||||
|
@ -9,56 +9,56 @@ libxml2.debugMemory(1)
|
||||
f = StringIO.StringIO("""<a><b b1="b1"/><c>content of c</c></a>""")
|
||||
input = libxml2.inputBuffer(f)
|
||||
reader = input.newTextReader("test1")
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to first element"
|
||||
sys.exit(1)
|
||||
if reader.name() != "a" or reader.isEmptyElement() != 0 or \
|
||||
reader.nodeType() != 1 or reader.hasAttributes() != 0:
|
||||
if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
|
||||
reader.NodeType() != 1 or reader.HasAttributes() != 0:
|
||||
print "Error reading the first element"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to second element"
|
||||
sys.exit(1)
|
||||
if reader.name() != "b" or reader.isEmptyElement() != 1 or \
|
||||
reader.nodeType() != 1 or reader.hasAttributes() != 1:
|
||||
if reader.Name() != "b" or reader.IsEmptyElement() != 1 or \
|
||||
reader.NodeType() != 1 or reader.HasAttributes() != 1:
|
||||
print "Error reading the second element"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to third element"
|
||||
sys.exit(1)
|
||||
if reader.name() != "c" or reader.isEmptyElement() != 0 or \
|
||||
reader.nodeType() != 1 or reader.hasAttributes() != 0:
|
||||
if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \
|
||||
reader.NodeType() != 1 or reader.HasAttributes() != 0:
|
||||
print "Error reading the third element"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to text node"
|
||||
sys.exit(1)
|
||||
if reader.name() != "#text" or reader.isEmptyElement() != 0 or \
|
||||
reader.nodeType() != 3 or reader.hasAttributes() != 0 or \
|
||||
reader.value() != "content of c":
|
||||
if reader.Name() != "#text" or reader.IsEmptyElement() != 0 or \
|
||||
reader.NodeType() != 3 or reader.HasAttributes() != 0 or \
|
||||
reader.Value() != "content of c":
|
||||
print "Error reading the text node"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to end of third element"
|
||||
sys.exit(1)
|
||||
if reader.name() != "c" or reader.isEmptyElement() != 0 or \
|
||||
reader.nodeType() != 15 or reader.hasAttributes() != 0:
|
||||
if reader.Name() != "c" or reader.IsEmptyElement() != 0 or \
|
||||
reader.NodeType() != 15 or reader.HasAttributes() != 0:
|
||||
print "Error reading the end of third element"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading to end of first element"
|
||||
sys.exit(1)
|
||||
if reader.name() != "a" or reader.isEmptyElement() != 0 or \
|
||||
reader.nodeType() != 15 or reader.hasAttributes() != 0:
|
||||
if reader.Name() != "a" or reader.IsEmptyElement() != 0 or \
|
||||
reader.NodeType() != 15 or reader.HasAttributes() != 0:
|
||||
print "Error reading the end of first element"
|
||||
sys.exit(1)
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 0:
|
||||
print "Error reading to end of document"
|
||||
sys.exit(1)
|
||||
@ -70,14 +70,14 @@ f = StringIO.StringIO("""<test xmlns:dt="urn:datatypes" dt:type="int"/>""")
|
||||
input = libxml2.inputBuffer(f)
|
||||
reader = input.newTextReader("test2")
|
||||
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading test element"
|
||||
sys.exit(1)
|
||||
if reader.getAttributeNo(0) != "urn:datatypes" or \
|
||||
reader.getAttributeNo(1) != "int" or \
|
||||
reader.getAttributeNs("type", "urn:datatypes") != "int" or \
|
||||
reader.getAttribute("dt:type") != "int":
|
||||
if reader.GetAttributeNo(0) != "urn:datatypes" or \
|
||||
reader.GetAttributeNo(1) != "int" or \
|
||||
reader.GetAttributeNs("type", "urn:datatypes") != "int" or \
|
||||
reader.GetAttribute("dt:type") != "int":
|
||||
print "error reading test attributes"
|
||||
sys.exit(1)
|
||||
|
||||
@ -92,14 +92,14 @@ f = StringIO.StringIO("""<root xmlns:a="urn:456">
|
||||
input = libxml2.inputBuffer(f)
|
||||
reader = input.newTextReader("test3")
|
||||
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
while ret == 1:
|
||||
if reader.name() == "ref":
|
||||
if reader.lookupNamespace("a") != "urn:456":
|
||||
if reader.Name() == "ref":
|
||||
if reader.LookupNamespace("a") != "urn:456":
|
||||
print "error resolving namespace prefix"
|
||||
sys.exit(1)
|
||||
break
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error finding the ref element"
|
||||
sys.exit(1)
|
||||
@ -110,125 +110,125 @@ if ret != 1:
|
||||
f = StringIO.StringIO("""<testattr xmlns="urn:1" xmlns:a="urn:2" b="b" a:b="a:b"/>""")
|
||||
input = libxml2.inputBuffer(f)
|
||||
reader = input.newTextReader("test4")
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 1:
|
||||
print "Error reading the testattr element"
|
||||
sys.exit(1)
|
||||
#
|
||||
# Attribute exploration by index
|
||||
#
|
||||
if reader.moveToAttributeNo(0) != 1:
|
||||
if reader.MoveToAttributeNo(0) != 1:
|
||||
print "Failed moveToAttribute(0)"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:1":
|
||||
if reader.Value() != "urn:1":
|
||||
print "Failed to read attribute(0)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "xmlns":
|
||||
if reader.Name() != "xmlns":
|
||||
print "Failed to read attribute(0) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttributeNo(1) != 1:
|
||||
if reader.MoveToAttributeNo(1) != 1:
|
||||
print "Failed moveToAttribute(1)"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:2":
|
||||
if reader.Value() != "urn:2":
|
||||
print "Failed to read attribute(1)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "xmlns:a":
|
||||
if reader.Name() != "xmlns:a":
|
||||
print "Failed to read attribute(1) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttributeNo(2) != 1:
|
||||
if reader.MoveToAttributeNo(2) != 1:
|
||||
print "Failed moveToAttribute(2)"
|
||||
sys.exit(1)
|
||||
if reader.value() != "b":
|
||||
if reader.Value() != "b":
|
||||
print "Failed to read attribute(2)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "b":
|
||||
if reader.Name() != "b":
|
||||
print "Failed to read attribute(2) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttributeNo(3) != 1:
|
||||
if reader.MoveToAttributeNo(3) != 1:
|
||||
print "Failed moveToAttribute(3)"
|
||||
sys.exit(1)
|
||||
if reader.value() != "a:b":
|
||||
if reader.Value() != "a:b":
|
||||
print "Failed to read attribute(3)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "a:b":
|
||||
if reader.Name() != "a:b":
|
||||
print "Failed to read attribute(3) name"
|
||||
sys.exit(1)
|
||||
#
|
||||
# Attribute exploration by name
|
||||
#
|
||||
if reader.moveToAttribute("xmlns") != 1:
|
||||
if reader.MoveToAttribute("xmlns") != 1:
|
||||
print "Failed moveToAttribute('xmlns')"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:1":
|
||||
if reader.Value() != "urn:1":
|
||||
print "Failed to read attribute('xmlns')"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttribute("xmlns:a") != 1:
|
||||
if reader.MoveToAttribute("xmlns:a") != 1:
|
||||
print "Failed moveToAttribute('xmlns')"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:2":
|
||||
if reader.Value() != "urn:2":
|
||||
print "Failed to read attribute('xmlns:a')"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttribute("b") != 1:
|
||||
if reader.MoveToAttribute("b") != 1:
|
||||
print "Failed moveToAttribute('b')"
|
||||
sys.exit(1)
|
||||
if reader.value() != "b":
|
||||
if reader.Value() != "b":
|
||||
print "Failed to read attribute('b')"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttribute("a:b") != 1:
|
||||
if reader.MoveToAttribute("a:b") != 1:
|
||||
print "Failed moveToAttribute('a:b')"
|
||||
sys.exit(1)
|
||||
if reader.value() != "a:b":
|
||||
if reader.Value() != "a:b":
|
||||
print "Failed to read attribute('a:b')"
|
||||
sys.exit(1)
|
||||
if reader.moveToAttributeNs("b", "urn:2") != 1:
|
||||
if reader.MoveToAttributeNs("b", "urn:2") != 1:
|
||||
print "Failed moveToAttribute('b', 'urn:2')"
|
||||
sys.exit(1)
|
||||
if reader.value() != "a:b":
|
||||
if reader.Value() != "a:b":
|
||||
print "Failed to read attribute('b', 'urn:2')"
|
||||
sys.exit(1)
|
||||
#
|
||||
# Go back and read in sequence
|
||||
#
|
||||
if reader.moveToElement() != 1:
|
||||
if reader.MoveToElement() != 1:
|
||||
print "Failed to move back to element"
|
||||
sys.exit(1)
|
||||
if reader.moveToFirstAttribute() != 1:
|
||||
if reader.MoveToFirstAttribute() != 1:
|
||||
print "Failed to move to first attribute"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:1":
|
||||
if reader.Value() != "urn:1":
|
||||
print "Failed to read attribute(0)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "xmlns":
|
||||
if reader.Name() != "xmlns":
|
||||
print "Failed to read attribute(0) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToNextAttribute() != 1:
|
||||
if reader.MoveToNextAttribute() != 1:
|
||||
print "Failed to move to next attribute"
|
||||
sys.exit(1)
|
||||
if reader.value() != "urn:2":
|
||||
if reader.Value() != "urn:2":
|
||||
print "Failed to read attribute(1)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "xmlns:a":
|
||||
if reader.Name() != "xmlns:a":
|
||||
print "Failed to read attribute(1) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToNextAttribute() != 1:
|
||||
if reader.MoveToNextAttribute() != 1:
|
||||
print "Failed to move to next attribute"
|
||||
sys.exit(1)
|
||||
if reader.value() != "b":
|
||||
if reader.Value() != "b":
|
||||
print "Failed to read attribute(2)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "b":
|
||||
if reader.Name() != "b":
|
||||
print "Failed to read attribute(2) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToNextAttribute() != 1:
|
||||
if reader.MoveToNextAttribute() != 1:
|
||||
print "Failed to move to next attribute"
|
||||
sys.exit(1)
|
||||
if reader.value() != "a:b":
|
||||
if reader.Value() != "a:b":
|
||||
print "Failed to read attribute(3)"
|
||||
sys.exit(1)
|
||||
if reader.name() != "a:b":
|
||||
if reader.Name() != "a:b":
|
||||
print "Failed to read attribute(3) name"
|
||||
sys.exit(1)
|
||||
if reader.moveToNextAttribute() != 0:
|
||||
if reader.MoveToNextAttribute() != 0:
|
||||
print "Failed to detect last attribute"
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -32,10 +32,10 @@ for file in valid_files:
|
||||
continue
|
||||
reader = libxml2.newTextReaderFilename(file)
|
||||
#print "%s:" % (file)
|
||||
reader.setParserProp(libxml2.PARSER_VALIDATE, 1)
|
||||
ret = reader.read()
|
||||
reader.SetParserProp(libxml2.PARSER_VALIDATE, 1)
|
||||
ret = reader.Read()
|
||||
while ret == 1:
|
||||
ret = reader.read()
|
||||
ret = reader.Read()
|
||||
if ret != 0:
|
||||
print "Error parsing and validating %s" % (file)
|
||||
#sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user