You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Carmona Perez, David" <DP...@fcc.es> on 2003/11/07 11:44:56 UTC

Woody error summary

Here is a custom version of woody-samples-styling.xsl, I made that think can be of general interest:
 
I've added the new <wi:validation-errors> tag that show a summary of errors that may have happened, and can be embedded inside the <wt:form-template> tag.
 
What do you think?
 
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:wi="http://apache.org/cocoon/woody/instance/1.0"
            exclude-result-prefixes="wi"
      >
      <xsl:import href="woody-page-styling.xsl"/>
      <xsl:import href="woody-field-styling.xsl"/>
  
      <!-- head and body stuff required to use the calendar popup -->
      <xsl:template match="head">
            <xsl:copy>
                  <xsl:apply-templates/>
                  <!-- insert the head snippets required by the styling stylesheets -->
                  <xsl:call-template name="woody-page-head"/>
                  <xsl:call-template name="woody-field-head"/>
                  <link rel="stylesheet" type="text/css" href="woody-tabs.css"/>
      </xsl:copy>
      </xsl:template>
  
      <xsl:template match="body">
            <xsl:copy>
                  <!-- insert the body  snippets required by the styling stylesheets -->
                  <xsl:call-template name="woody-page-body"/>
                  <xsl:call-template name="woody-field-body"/>
                  <xsl:apply-templates/>
            </xsl:copy>
      </xsl:template>
  
      <xsl:template match="wi:validation-errors">
            <xsl:param name="header">
                  <p class="validation-errors">The following errors have been detected (marked with !):</p>
            </xsl:param>
            <xsl:param name="footer">
                  <p class="validation-errors">Please, correct them and re-submit the form.</p>
            </xsl:param>
            <xsl:variable name="frm" select="ancestor::wi:form-template"/>
            <xsl:if test="$frm and $frm//wi:validation-message">
                  <xsl:copy-of select="$header"/>
                  <ul>
                        <xsl:for-each select="$frm//wi:validation-message">
                             <li class="validation-error">
                                   <xsl:if test="../wi:label">
                                         <xsl:value-of select="../wi:label"/><xsl:text>: </xsl:text>
                                   </xsl:if>
                                   <xsl:value-of select="."/>
                             </li>
                        </xsl:for-each>
                  </ul>
                  <xsl:copy-of select="$footer"/>
            </xsl:if>
      </xsl:template>
</xsl:stylesheet>
 
 
--------
David
 

Re: Woody error summary

Posted by Bruno Dumon <br...@outerthought.org>.
On Fri, 2003-11-07 at 11:44, Carmona Perez, David wrote:
> Here is a custom version of woody-samples-styling.xsl, I made that
> think can be of general interest:
>
> I've added the new <wi:validation-errors> tag that show a summary of
> errors that may have happened, and can be embedded inside the
> <wt:form-template> tag.
> 

David, I've now added your wi:validation-errors template to the
woody-field-styling.xsl in CVS, so no need to bother anymore with
submitting a patch to bugzilla. Thanks again for this contribution.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Woody error summary

Posted by Bruno Dumon <br...@outerthought.org>.
On Fri, 2003-11-07 at 11:44, Carmona Perez, David wrote:
> Here is a custom version of woody-samples-styling.xsl, I made that
> think can be of general interest:
> 
>  
> 
> I've added the new <wi:validation-errors> tag that show a summary of
> errors that may have happened, and can be embedded inside the
> <wt:form-template> tag.
> 
>  
> 
> What do you think?

Looks good, other people have asked for this too (or maybe it was you, I
don't remember). However, I would add this template to
woody-field-styling.xsl. If you could do that and submit a proper diff
to bugzilla, that would be excellent. I think there's information on the
cocon website about how to do this, otherwise just ask.

PS: please don't send HTML email to the mailing list.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


RE: Woody Populate Form with xsp (flow)

Posted by JD Daniels <jd...@datatrio.com>.
Awesome.

Thanks :)

-----Original Message-----
From: Bruno Dumon [mailto:bruno@outerthought.org]
Sent: Saturday, November 08, 2003 9:22 AM
To: users@cocoon.apache.org
Subject: Re: Woody Populate Form with xsp (flow)


On Fri, 2003-11-07 at 22:37, Upayavira wrote:
> JD Daniels wrote:
>
> >I was wondering if it was possible to load an xsp pipeline instead of a
> >source xml file..
> >
> >ex.
> >// parse the document to a DOM-tree
> >var document = loadDocument("forms/test.xml");
> >
> >// bind the document data to the form
> >form.load(document);
> >form.showForm("display-pipeline");
> >
> >Change to:
> >
> >// Load DOM-tree From Xsp
> >
> var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");
>
> var resolver =
>
cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE
);
> var source = resolver.resolve(uri);
> var parser =
> cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
> var document =
>
parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil
.getInputSource(source));
>
> form.load(document);

A bit more optimized would be:

var document =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM(source);

this will build the DOM directly from the SAX events comming out of the
XSP, instead of first serializing to XML and then reparsing.

--
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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



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


Re: Woody Populate Form with xsp (flow)

Posted by Bruno Dumon <br...@outerthought.org>.
On Fri, 2003-11-07 at 22:37, Upayavira wrote:
> JD Daniels wrote:
> 
> >I was wondering if it was possible to load an xsp pipeline instead of a
> >source xml file..
> >
> >ex.
> >// parse the document to a DOM-tree
> >var document = loadDocument("forms/test.xml");
> >
> >// bind the document data to the form
> >form.load(document);
> >form.showForm("display-pipeline");
> >
> >Change to:
> >
> >// Load DOM-tree From Xsp
> >
> var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");
> 
> var resolver = 
> cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
> var source = resolver.resolve(uri);
> var parser = 
> cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
> var document = 
> parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(source));
> 
> form.load(document);

A bit more optimized would be:

var document =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM(source);

this will build the DOM directly from the SAX events comming out of the
XSP, instead of first serializing to XML and then reparsing.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Woody Populate Form with xsp (flow)

Posted by Upayavira <uv...@upaya.co.uk>.
JD Daniels wrote:

>I had to change
>source = resolver.resolve(uri); //to
>source = resolver.resolveURI(uri);
>
>and change context:// to cocoon://
>
>Works Now !!
>  
>
Wow. I'm impressed. ^d^d^d^d^d^d^d^d. Well of course. I new it would.

Regards, Upayavira

>Thank You
>
>JD
>
>
>-----Original Message-----
>From: Upayavira [mailto:uv@upaya.co.uk]
>Sent: Friday, November 07, 2003 1:37 PM
>To: users@cocoon.apache.org
>Subject: Re: Woody Populate Form with xsp (flow)
>
>
>JD Daniels wrote:
>
>  
>
>>I was wondering if it was possible to load an xsp pipeline instead of a
>>source xml file..
>>
>>ex.
>>// parse the document to a DOM-tree
>>var document = loadDocument("forms/test.xml");
>>
>>// bind the document data to the form
>>form.load(document);
>>form.showForm("display-pipeline");
>>
>>Change to:
>>
>>// Load DOM-tree From Xsp
>>
>>    
>>
>var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");
>
>var resolver =
>cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE
>);
>var source = resolver.resolve(uri);
>var parser =
>cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
>var document =
>parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil
>.getInputSource(source));
>
>form.load(document);
>
>Now that's me taking a bit of a leap - never done it before, but I think
>it should work.To explain:
>1) Convert your xsp uri into a source using a source resolver
>2) Parse that source into a DOM object
>3) Load that DOM object into your form.
>
>Hope it works!
>
>Regards, Upayavira
>
>  
>
>>// bind the document data to the form
>>form.load(document);
>>form.showForm("display-pipeline");
>>
>>
>>JD
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


RE: Woody Populate Form with xsp (flow)

Posted by JD Daniels <jd...@datatrio.com>.
I had to change
source = resolver.resolve(uri); //to
source = resolver.resolveURI(uri);

and change context:// to cocoon://

Works Now !!

Thank You

JD


-----Original Message-----
From: Upayavira [mailto:uv@upaya.co.uk]
Sent: Friday, November 07, 2003 1:37 PM
To: users@cocoon.apache.org
Subject: Re: Woody Populate Form with xsp (flow)


JD Daniels wrote:

>I was wondering if it was possible to load an xsp pipeline instead of a
>source xml file..
>
>ex.
>// parse the document to a DOM-tree
>var document = loadDocument("forms/test.xml");
>
>// bind the document data to the form
>form.load(document);
>form.showForm("display-pipeline");
>
>Change to:
>
>// Load DOM-tree From Xsp
>
var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");

var resolver =
cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE
);
var source = resolver.resolve(uri);
var parser =
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
var document =
parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil
.getInputSource(source));

form.load(document);

Now that's me taking a bit of a leap - never done it before, but I think
it should work.To explain:
1) Convert your xsp uri into a source using a source resolver
2) Parse that source into a DOM object
3) Load that DOM object into your form.

Hope it works!

Regards, Upayavira

>// bind the document data to the form
>form.load(document);
>form.showForm("display-pipeline");
>
>
>JD
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>



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



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


Re: Woody Populate Form with xsp (flow)

Posted by Upayavira <uv...@upaya.co.uk>.
JD Daniels wrote:

>I was wondering if it was possible to load an xsp pipeline instead of a
>source xml file..
>
>ex.
>// parse the document to a DOM-tree
>var document = loadDocument("forms/test.xml");
>
>// bind the document data to the form
>form.load(document);
>form.showForm("display-pipeline");
>
>Change to:
>
>// Load DOM-tree From Xsp
>
var uri = "context://formdata.xsp?id=" + cocoon.request.get("id");

var resolver = 
cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
var source = resolver.resolve(uri);
var parser = 
cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
var document = 
parser.parseDocument(Packages.org.apache.cocoon.components.source.SourceUtil.getInputSource(source));

form.load(document);

Now that's me taking a bit of a leap - never done it before, but I think 
it should work.To explain:
1) Convert your xsp uri into a source using a source resolver
2) Parse that source into a DOM object
3) Load that DOM object into your form.

Hope it works!

Regards, Upayavira

>// bind the document data to the form
>form.load(document);
>form.showForm("display-pipeline");
>
>
>JD
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


Woody Populate Form with xsp (flow)

Posted by JD Daniels <jd...@datatrio.com>.
I was wondering if it was possible to load an xsp pipeline instead of a
source xml file..

ex.
// parse the document to a DOM-tree
var document = loadDocument("forms/test.xml");

// bind the document data to the form
form.load(document);
form.showForm("display-pipeline");

Change to:

// Load DOM-tree From Xsp
var document = "context://formdata.xsp?id=" + cocoon.request.get("id");

// bind the document data to the form
form.load(document);
form.showForm("display-pipeline");


JD


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


Re: Woody error summary

Posted by Ugo Cei <u....@cbim.it>.
Carmona Perez, David wrote:
> I've added the new <wi:validation-errors> tag that show a summary of 
> errors that may have happened, and can be embedded inside the 
> <wt:form-template> tag.
> What do you think?

Can you please post a patch to Bugzilla? But before doing that, please 
substitute the hardcoded English messages with <i18n:text> elements and 
add them to the message catalogs in the samples.

	Ugo


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