You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ivelin Ivanov <iv...@apache.org> on 2002/06/08 06:48:29 UTC

Re: [VOTE] Schematron validator in Anteater (and Cocoonvalidating Transformer)

I will be interested to contribute some code.
The validator package is totally independent of Avalon.
It only needs commons-jxpath.jar

The package is org.apache.cocoon.components.validation

I guess I can just zip up the files in the package for anteater.

I would like us to work out the exact syntax before starting, though.

How do we plan to generate junit reports.
Right now I don't see a nice way to interrupt a test, if there was a
validation error, and jump straight to the junit reporting.

I have also asked a question about reusing steps among test cases.
How do you suggest this can be done?

Once we work out the architectural problems, I'll move to coding.

My sf.net login is "ivelin"




Ivelin



----- Original Message -----
From: "Ovidiu Predescu" <ov...@apache.org>
To: "Ivelin Ivanov" <iv...@apache.org>; <af...@lists.sourceforge.net>;
<co...@xml.apache.org>
Sent: Friday, June 07, 2002 10:18 PM
Subject: Re: [VOTE] Schematron validator in Anteater (and Cocoonvalidating
Transformer)


> Ivelin,
>
> This sounds very interesting, are you interested in adding this feature to
> Anteater and writing some documentation for it? If you're interested, I
can
> make you a committer to the project, so you can develop more easily. Just
> let me know your SourceForge account.
>
> The way I'd see this added is through an additional package in CVS. As I'm
> not familiar with the internals of the validator, I can't comment much on
> how this can be integrated. Is the validator implemented as a component
> using Avalon? If so you'd need to change it to match the Ant style of
> writing extensions. If exactly the same code from Cocoon can be reused
> unmodified in Anteater, then perhaps the best option is to build a jar
file
> in Cocoon, and just drop it in Anteater's lib/ directory.
>
> Cheers,
> Ovidiu
>
> On 6/7/02 4:51 PM, "Ivelin Ivanov" <iv...@apache.org> wrote:
>
> >
> >
> > =================================
> > ||     VERY LONG !!!           ||
> > =================================
> > ||    AND INTERESTING.         ||
> > =================================
> >
> >
> > I am surprised that there is not much interest in the Cocoon community
for
> > Anteater. What do people use for web apps functional test suites?
> > There are a few other open source test tools, but I think Anteater has
great
> > potential. Especially for Cocoon apps.
> >
> > So, let's begin:
> >
> >
> >
> >                       - 1 -
> >
> >
> >
> >
> > While Anteater is still not solidified and has a relatively small user
base,
> > I would like to suggest an architectural change, which is compatible
with
> > Anteater's values, but will hopefully
> > improve it in the following areas:
> >
> > 1) standartization
> > 2) learning curve
> > 3) cross project code reuse
> > 4) maintainance
> >
> > The ideas is to use references to schema documents of standard XML
languages
> > (like Schematron, DTD, XML Schema, Relax NG) for response validation,
> > instead of supporting a proprietary grammar.
> > I suggest that we use the org.apache.cocoon.components.validation
package
> > which is an independent component in Cocoon's main tree and is used by
> > XMLForm.
> > The Schematron implementation is already available and I think it is
quite
> > suitable for Anteater, because Schematron is a superset of Anteater's
match
> > element.
> > To be precise it is a superset of the validating use, i.e the cases when
> > match is used to assign value to a "result" property. Asigning values
within
> > <match/> to other properties which are used for subsequent requests is a
> > separate concern.
> >
> >
> >
> >
> >                       - 2 -
> >
> >
> >
> >
> > Schematron was specificly designed for partial, multi-phase validation
and
> > user friendly error reporting.
> >
> > I'll explain how points 1-4 above are addressed by this proposal:
> >
> > 1) Schematron is relatively popular. There are a number of articles in
> > popular magazines which promote Schematron over other validating
schemas.
> > 2) Schematron is very easy to learn. Specification and tutorials are
> > availbel. There is also supporing discussion groups with decent response
> > time.
> > 3) Schematron is used for a number of projects. For example there is a
> > complete RSS 1.0 validating schema available on the RSS site.
> > http://home.freeuk.com/leigh.dodds/rss_validator/
> > XMLForm is using schematron extensively as well. Slash-edit is another
> > example.
> > 4) Maintainance of Schematron documents is easy. Minor local changes are
> > made as the underlying (validated) model changes.
> >
> >
> >
> >
> >
> >                       - 3 -
> >
> >
> >
> >
> >
> > 5) Bonus ;)
> >
> > Here is one additional reason why I posted this proposal.
> > Validating Schematron documents can be referenced in a transparent
> > transformer prior to a page serialization.
> > This can be useful in development and QA, to catch and report bugs in
> > content (HTML, WAP, XML, etc.) during navigation.
> >
> > Searching for problems in a broken HTML page (or other xml markup) can
be
> > painful.
> > Instead of searching for the missing tags or label or icon, the tester
(or
> > developer) will see a meaningful error report in place of the actual
page.
> > After testing certain pages time and again, the eye tends to ignore
elements
> > peripheral to the currently tested feature.
> > If there is an underlying validating document which is applied before
> > display, then things may be easier. The developer (tester) has to only
make
> > changes to it when the page structure changes.
> > The rest of the time this document will be a safeguard of unexpected
> > problems caused as side efects by the development of other features or
bug
> > fixes or another one of the infinite other possible reasons.
> > The transformer applying the validating document can be, of course,
turned
> > off in production.
> >
> > Now the next interesting part. The forementioned validating documents
can be
> > referenced just as well by Anteater regression suites as they can by a
> > pipeline embedded validating transformer.
> >
> >
> >
> >
> >
> >
> >                       - 4 -
> >
> >
> >
> >
> > As a quick thought, this is how an Anteater script may look:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <project name="calc-test" default="calc">
> >
> > <!-- Simulate the behavior of a user that opens a browser, starts
> > the calculator example, and goes back in the processing several
> > times. -->
> > <target name="calc">
> >   <property name="calc" value="${cocoon}/samples/flow/examples/calc/"/>
> >   <property name="schema-doc-ns"
> > value="http://www.ascc.net/xml/schematron"/>
> >   <property name="schema-doc-url"
> > value="${cocoon}/samples/flow/examples/calc/sch-report.xml"/>
> >   <http description="Test the 'calc' JavaScript implementation">
> >     <httpRequest href="${calc}/">
> >       <match>
> >         <xpath select="html/body//form/@action" assign="cont1"/>
> >         <validate phase="page1" assign="violations">
> >       </match>
> >     </httpRequest>
> >
> >     <echo>result = ${violations}</echo>
> >   </http>
> >
> > ....
> >
> > Then the Schematron document would be something like:
> >
> > <schema xmlns="http://www.ascc.net/xml/schematron">
> >
> >   <title>Schema for the Calc example</title>
> >
> >   <phase id="page1">
> >           <p>first page check.</p>
> >           <active pattern="form-present"/>
> >   </phase>
> >   ... other phases ...
> >   <pattern name="Test for HTML form element" id="form-present">
> > <rule context="/">
> > <assert  test="//form">
> >       Form element expected on this page.
> >     </assert>
> > <assert  test="//form/@action">
> > Form element must have action attribute.
> >     </assert>
> > </rule>
> > ... other rules ...
> > </pattern>
> >   ... other patterns...
> >
> >  </schema>
> > ...
> >
> >
> >
> >
> > Where the validate element will use the validation package to apply the
> > schema against the document.
> > The violations can be then nicely integrated in the JUnit reporting
package.
> >
> >
> >
> > If there are enough votes I'll contribute some of the work myself.
> > Help would be certainly appreciated.
> >
> >
> > Thanks for reading this far.
> >
> >
> > Thoughts?
> >
> >
> > -= Ivelin =-
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [VOTE] Schematron validator in Anteater (andCocoonvalidatingTransformer)

Posted by Ovidiu Predescu <ov...@apache.org>.
On 6/9/02 11:17 PM, "Nicola Ken Barozzi" <ni...@apache.org> wrote:

> From: "Ovidiu Predescu" <ov...@apache.org>
> To: <co...@xml.apache.org>; <af...@lists.sourceforge.net>
> Sent: Monday, June 10, 2002 4:14 AM
> Subject: Re: [VOTE] Schematron validator in Anteater
> (andCocoonvalidatingTransformer)
> 
> 
>> On 6/9/02 2:36 PM, "Nicola Ken Barozzi" <ni...@apache.org> wrote:
>> 
>>> From: "Ovidiu Predescu" <ov...@apache.org>
>>>> If you want to reuse functionality across multiple ant files, just
> define
>>>> the common functionality in targets in a common file, and call them
> using
>>>> the <ant> target.
>>> 
>>> Which really slows down things sometimes and precludes the Ant
> dependency
>>> mechanism.
>> 
>> Why does it slow down things? Another build file should just parse and add
>> the targets to the pool of already existing targets. And since you're
>> calling the task directly, yes, you are avoiding the dependency mechanism,
>> but in this case this exactly what you want.
> 
> I referred to "reuse functionality across multiple ant files".
> Since it's a generic statemement, I gave a generic answer ;-)

;)

> <ant> is not the root of all evil, but shoudn't be used just to "call build
> functions", but call sub builds.

<ant> is the only way you can load and execute test scripts dynamically at
runtime. Even with an xinclude facility, it would be very difficult to load
arbitrary build files, since xinclude would be executed at parse time, while
<ant> is evaluated at runtime.

To understand what I mean, take a look at test/anteater/all-tests.xml in
Cocoon. The main target determines, at runtime, what are all the test files,
and executes them accordingly. I don't think this would be possible with an
xinclude target, since <xinclude> would have to refer to known URLs at parse
time.

>>> I'm writing a simple xinclude system to patch Ant.
>>> Any suggestion on what to use to manage xinclude tags?
>> 
>> What would be the semantics of xinclude in the context of Ant? Suppose you
>> xinclude a target fragment inside the <project> element; this should
> create
>> a new target. But I imagine you could also xinclude a fragment inside a
>> target: this should only add whatever tasks are referred to that target.
>> 
>> If this is the semantics, then I'd say the xinclude element cannot be a
>> regular task. What you instead need is a special element which
> transparently
>> substitutes at _parse_ time XML fragments from other sources in the
> parsing
>> stream.
> 
> I would make a XIncludeProjectHelper, so I would intervene in the parsing
> stage.
> 
> What I would like to know, are there any separate xinclude implementations
> already?

I don't know, better ask on ant-dev about it. Also check the Sourceforge
Antcontrib project, they have a bunch of tasks which are not part of Ant.

Cheers,
Ovidiu


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [VOTE] Schematron validator in Anteater (andCocoonvalidatingTransformer)

Posted by Nicola Ken Barozzi <ni...@apache.org>.
From: "Ovidiu Predescu" <ov...@apache.org>
To: <co...@xml.apache.org>; <af...@lists.sourceforge.net>
Sent: Monday, June 10, 2002 4:14 AM
Subject: Re: [VOTE] Schematron validator in Anteater
(andCocoonvalidatingTransformer)


> On 6/9/02 2:36 PM, "Nicola Ken Barozzi" <ni...@apache.org> wrote:
>
> > From: "Ovidiu Predescu" <ov...@apache.org>
> >> If you want to reuse functionality across multiple ant files, just
define
> >> the common functionality in targets in a common file, and call them
using
> >> the <ant> target.
> >
> > Which really slows down things sometimes and precludes the Ant
dependency
> > mechanism.
>
> Why does it slow down things? Another build file should just parse and add
> the targets to the pool of already existing targets. And since you're
> calling the task directly, yes, you are avoiding the dependency mechanism,
> but in this case this exactly what you want.

I referred to "reuse functionality across multiple ant files".
Since it's a generic statemement, I gave a generic answer ;-)

<ant> is not the root of all evil, but shoudn't be used just to "call build
functions", but call sub builds.

> > I'm writing a simple xinclude system to patch Ant.
> > Any suggestion on what to use to manage xinclude tags?
>
> What would be the semantics of xinclude in the context of Ant? Suppose you
> xinclude a target fragment inside the <project> element; this should
create
> a new target. But I imagine you could also xinclude a fragment inside a
> target: this should only add whatever tasks are referred to that target.
>
> If this is the semantics, then I'd say the xinclude element cannot be a
> regular task. What you instead need is a special element which
transparently
> substitutes at _parse_ time XML fragments from other sources in the
parsing
> stream.

I would make a XIncludeProjectHelper, so I would intervene in the parsing
stage.

What I would like to know, are there any separate xinclude implementations
already?

--
Nicola Ken Barozzi                   nicolaken@apache.org
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [VOTE] Schematron validator in Anteater (and CocoonvalidatingTransformer)

Posted by Ovidiu Predescu <ov...@apache.org>.
On 6/9/02 2:36 PM, "Nicola Ken Barozzi" <ni...@apache.org> wrote:

> From: "Ovidiu Predescu" <ov...@apache.org>
> 
>> On 6/7/02 9:48 PM, "Ivelin Ivanov" <iv...@apache.org> wrote:
>>> I have also asked a question about reusing steps among test cases.
>>> How do you suggest this can be done?
>> 
>> Just group the different test cases in two different targets. In a common
>> test target, just do the login, then call the two targets sequentially,
> and
>> then do the logout. If you want the two steps to happen in parallel, you
> can
>> use Ant's <parallel> element.
>> 
>> Something like this:
>> 
>> <target name="test1">
>>   // Do the steps for test case 1
>> </target>
>> 
>> <target name="test2">
>>   // Do the steps for test case 2
>> </target>
>> 
>> <target name="full-test">
>>   <http>
>>     // Do the login here
>> 
>>     <antcall target="test1"/>
>>     <antcall target="test2"/>
>> 
>>     // Do the logout here
>>   </http>
>> </target>
>> 
>> The <target> element acts as a function here, and you make use of
> <antcall>
>> to invoke it.
>> 
>> If you want to reuse functionality across multiple ant files, just define
>> the common functionality in targets in a common file, and call them using
>> the <ant> target.
> 
> Which really slows down things sometimes and precludes the Ant dependency
> mechanism.

Why does it slow down things? Another build file should just parse and add
the targets to the pool of already existing targets. And since you're
calling the task directly, yes, you are avoiding the dependency mechanism,
but in this case this exactly what you want.

> I'm writing a simple xinclude system to patch Ant.
> Any suggestion on what to use to manage xinclude tags?

What would be the semantics of xinclude in the context of Ant? Suppose you
xinclude a target fragment inside the <project> element; this should create
a new target. But I imagine you could also xinclude a fragment inside a
target: this should only add whatever tasks are referred to that target.

If this is the semantics, then I'd say the xinclude element cannot be a
regular task. What you instead need is a special element which transparently
substitutes at _parse_ time XML fragments from other sources in the parsing
stream.

Regards,
Ovidiu


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [VOTE] Schematron validator in Anteater (and CocoonvalidatingTransformer)

Posted by Nicola Ken Barozzi <ni...@apache.org>.
From: "Ovidiu Predescu" <ov...@apache.org>

> On 6/7/02 9:48 PM, "Ivelin Ivanov" <iv...@apache.org> wrote:
> > I have also asked a question about reusing steps among test cases.
> > How do you suggest this can be done?
>
> Just group the different test cases in two different targets. In a common
> test target, just do the login, then call the two targets sequentially,
and
> then do the logout. If you want the two steps to happen in parallel, you
can
> use Ant's <parallel> element.
>
> Something like this:
>
> <target name="test1">
>   // Do the steps for test case 1
> </target>
>
> <target name="test2">
>   // Do the steps for test case 2
> </target>
>
> <target name="full-test">
>   <http>
>     // Do the login here
>
>     <antcall target="test1"/>
>     <antcall target="test2"/>
>
>     // Do the logout here
>   </http>
> </target>
>
> The <target> element acts as a function here, and you make use of
<antcall>
> to invoke it.
>
> If you want to reuse functionality across multiple ant files, just define
> the common functionality in targets in a common file, and call them using
> the <ant> target.

Which really slows down things sometimes and precludes the Ant dependency
mechanism.

I'm writing a simple xinclude system to patch Ant.
Any suggestion on what to use to manage xinclude tags?

--
Nicola Ken Barozzi                   nicolaken@apache.org
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [VOTE] Schematron validator in Anteater (and Cocoonvalidating Transformer)

Posted by Ovidiu Predescu <ov...@apache.org>.
On 6/7/02 9:48 PM, "Ivelin Ivanov" <iv...@apache.org> wrote:

> 
> I will be interested to contribute some code.
> The validator package is totally independent of Avalon.

OK, this is good.

> It only needs commons-jxpath.jar
> 
> The package is org.apache.cocoon.components.validation
> 
> I guess I can just zip up the files in the package for anteater.

Anteater currently uses Jaxen, is it possible for the validation code to use
Jaxen instead of JXPath?

> I would like us to work out the exact syntax before starting, though.

I think the syntax you proposed is reasonable for a start.

> How do we plan to generate junit reports.
> Right now I don't see a nice way to interrupt a test, if there was a
> validation error, and jump straight to the junit reporting.

How does Junit catch the interrupt? We can probably use the same mechanism
to catch the interrupt, and execute the reporting code.

> I have also asked a question about reusing steps among test cases.
> How do you suggest this can be done?

Just group the different test cases in two different targets. In a common
test target, just do the login, then call the two targets sequentially, and
then do the logout. If you want the two steps to happen in parallel, you can
use Ant's <parallel> element.

Something like this:

<target name="test1">
  // Do the steps for test case 1
</target>

<target name="test2">
  // Do the steps for test case 2
</target>

<target name="full-test">
  <http>
    // Do the login here

    <antcall target="test1"/>
    <antcall target="test2"/>

    // Do the logout here
  </http>
</target>

The <target> element acts as a function here, and you make use of <antcall>
to invoke it.

If you want to reuse functionality across multiple ant files, just define
the common functionality in targets in a common file, and call them using
the <ant> target.

Does this answer your question?

> Once we work out the architectural problems, I'll move to coding.
> 
> My sf.net login is "ivelin"

OK, you're in!

Ovidiu


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org