cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: Dynamic Schematron validation works!
Date Sat, 16 Mar 2002 12:00:02 GMT
At 11:49 am +0100 16/3/02, Torsten Curdt wrote:
>Jeremy, I don't want to spoil your enthusiasm but there still two major
>issues... I've been talking with Ivelin off the list about these issues.
>(Maybe we should move our discussion to the list?!)
>1) current binding prohibits the use of checkboxes (good old checkbox
>   problem *sigh*) You cannot turn the checkbox off via request.

I am taking a different approach, it should not be a problem in
<slash-edit/>; you have to supply (very simple) StyleSheet snippets to
convert _your_ incoming request data into an instance to be validated.

This gives you the opportunity to detect a missing field (un-checked box),
because your StyleSheet should know about it.

There are two samples of this happening, one for the StreamGenerator, and
one for the RequestGenerator, it could easily be done in XSP too, depending
on your taste.

>2) AFAIU validation happens inside the XSLT transformer. IMHO this should
>   happen inside an action. Otherwise we have to choose what page to show
>   from the XML *content*. Only way I see do this is to create another
>   transformer for this. But still you are not able to react on the
>   validation result inside the sitemap... Or am I missing here something?
>   (Could a transformer set a request attribute that can become available
>   in the sitemap?)

I do not think you can easily send data back to the sitemap, though I am
not needing to do that .....

The scheme I am working on uses several Transformers and XSLT along the
pipeline to adapt the XML according to what needs to be done to it.

For instance, after the validation XSLT has run, another XSLT checks for
generated errors. If there are none, the instance content is wrapped with
the appropriate <source:write/> and the <validationResult/> is discarded.
Otherwise, the instance is not wrapped, the <validationResult/> is left,
but the behaviour is changed to 'get', meaning 'editor2html.xsl' XSLT will
generate a form from your instance, to show the user again, with errors
appropriately displayed.

Next in line is the SourceWritingTransformer, there may or may not be a job
for it to do ..... this is dependant on the tags in the stream. No need for
conditional sitemap components.

Someone wanting to use <slash-edit/> as the basis for editing their own
project, mainly has to write simple "Adaptor" XSLTs for their own doctype.

Internal 'put' pipeline
	request data -> validateable editor/instance
	validated editor/instance -> writeable editor/instance
                               (or not, if not validated)
	written editor/instance -> main pipeline

Main Pipeline (aggregates above with the config file)

	editor/instance -> html, depending on 'behaviour'

	ie. 'get' & 'new' make the editor/instance into a form
			'see' makes it into a simple editor view
			'put' displays result of successful save
			'dir' shows a directory listing

>Currently I am trying to merge Ivelin work what I'm am currently working
>on. I hope I can present this in a few days to the list...

With any luck I'll get this finished today, you can see what I mean.

If this helps, here are my notes (for the internal pipelines) for how it

(where <page/> represents arbitrarily complex XML)

			<map:match pattern="fetch-put(alpha,**)">
				<map:act type="request">
					<map:parameter name="parameters" value="true"/>
					<map:generate type="stream">
						<map:parameter name="form-name" value="xml-field"/>
					<map:transform src="editor/stylesheets/stream2editor.xsl">
						<map:parameter name="sub" value="alpha"/>
						<map:parameter name="target" value="{target}"/>
					<map:transform src="cocoon:/make-validator(page)"/>
					<map:transform src="editor/stylesheets/editor2writer.xsl">
						<map:parameter name="base" value="docs"/>
					<map:transform type="sourcewriter"/>
					<map:serialize type="xml"/>

      <map:match pattern="*-validator">
	      <map:generate src="editor/docs/schematron-{1}-validator.xml"/>
	      <map:transform src="editor/stylesheets/schematron-validator2xsl.xsl"/>
	      <map:serialize type="xml"/>

stream2editor.xsl outputs:

<editor sub="alpha">
	<instance behaviour="put" target="/blah.xml">

cocoon:page-validator outputs:

<editor sub="alpha">
	<instance behaviour="put" target="/blah.xml">

editor2writer.xsl outputs:

<editor sub="alpha">
	<instance behaviour="put" target="/blah.xml">
		<source:write src="base/blah.xml">

or this on validation error (the behaviour change means you get it back as
a form):

<editor sub="alpha">
	<instance behaviour="get" target="/blah.xml">

Hope this helps

regards Jeremy

   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <>     		 <>
   <phone:+44.[0].20.7737.6831>             <>

To unsubscribe, e-mail:
For additional commands, email:

View raw message