Re: PULL Parser in PHP

"lrargerich" <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
Hi,

I love the idea to write the tests as XML, then convert the XML to
X-Language using XSLT, then run the code and the code should directly
show if the tests passed or failed.

Based on this assumption I think that the vocabulary for defining the
tests should be refined to allow an easy XSLT translation to code, If
you can think about the vocabulary and/or format I may try to write
the XSLT to PHP and someone (?) can write the XSLT to Java. Then it
will be easy to write tests and as long as the XSLT exists you can
test it in all the supported languages.

What do you think?

Luis




--- In xmlpull-dev@y..., Aleksander Slominski <aslom@e...> wrote:
> 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>&lt;foo/&gt;</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);
>         //...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.