Re: Re: PULL Parser in PHP
Aleksander Slominski <[email protected]>
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
Stefan Haustein wrote:
> perhaps we could use a list of parser position descriptions as a simple
> conformance test?
hi,
i remember that you have something like that done. however it was text format
and if could take advantage of XML to be more flexible about test conditions
it should work good for testing XMLPULL API with different language
bindings (kind of similiar to OASIS XML test suite).
i was thinking about something like this (see below how would it look translated to Java):
<tests xmlns="http://xmlpull.org/v1/tests/2002-08.xsd">
<test name="simple test">
<input-inline><foo/></input-inline>
<set-feature>http://xmlpull.org/v1/doc/features.html#process-namespaces</set-feature>
<expect state="START_DOCUMENT"/>
<next>
<expect state="START_TAG" name="foo" namespace="" empty="1" />
<!-- and so on --->
</test>
</tests>
in simple syntax it is (? = means optional, * = optional any number of times), this would
describe XMLPULL API calls for parser and serializer and what are expected results
(for serializer it would first serialzie and then check that when parsing back input it is
what expected):
<tests xmlns="http://xmlpull.org/v1/tests/2002-08.xsd">
<test-parser name="descriptive name of test">
<input-inline>inlined xml</input-inline>?
<input-file>name of file</input-file>?
<set-feature>name of feature</set-feature>*
<expect
state="START_DOCUMENT|END_DOCUMENT|START_TAG|END_TAG|TEXT"?
token="COMMENT|..."?
name="getName()"? namespace="getNamespace()"? prefix="getPrefix()"? depth="getDepth()"?
namespaceCount="getNamespacesCount(getDepth())"? attributeCount="getAttributeCount()"?
text="getText()" empty="isEmptyElementTag" isWhitespace="isWhitespace():
/>*
<check-attribute pos="position" prefix="getAttributePrefix(pos)"? namespace=...? name=...?
value="..." is-default="0|1"?/>
<check-namespace pos="position" prefix="getNamespacePrefix(pos)"? namespace=...?/>
<next>*
<nextToken>*
<nextTag>*
<nextText>*
<!-- what about require(), getTextCharacters(), getLineNumber/getColumnNumber(),
defineEntityReplacementText()?/>
</test-parser>*
<test-serializer>
<start-tag name="..." namespace="..."/>
</test-serializer>
</tests>
this should be very easy to parse in any language and translate into XMLPULL API
calls - i would like write simple java utility that read XML (using XMLPULL API of course)
and then executes tests (and verifies results) - this would integrate as part of JUnit tests.
what do you think about it?
thanks,
alek
ps. the example xml test that would translate to Java code:
xpp.setInput(new StringReader("<foo/>"));
checkParserStateNs(xpp, 0, xpp.START_DOCUMENT, null, 0, null, null, null, false, -1);
xpp.next();
checkParserStateNs(xpp, 1, xpp.START_TAG, null, 0, "", "foo", null, true/*empty*/, 0);
//...