You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by iv...@apache.org on 2002/07/28 16:04:42 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java
ivelin 2002/07/28 07:04:42
Modified: src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
Log:
allowed violations to be used outside the form tag
Revision Changes Path
1.8 +38 -9 xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
Index: XMLFormTransformer.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLFormTransformer.java 8 Jun 2002 17:57:38 -0000 1.7
+++ XMLFormTransformer.java 28 Jul 2002 14:04:41 -0000 1.8
@@ -406,7 +406,16 @@
{
// put on top of the ref stack the full ref
// append the new ref to the last stack top if not referencing the root
- cannonicalRef = aref.startsWith ("/") ? aref : ( ((Entry) refStack.peek()).getValue() + "/" + aref );
+ if ( !refStack.isEmpty() )
+ {
+ // this is a nested reference
+ cannonicalRef = aref.startsWith ("/") ? aref : ( ((Entry) refStack.peek()).getValue() + "/" + aref );
+ }
+ else
+ {
+ // top level reference
+ cannonicalRef = aref;
+ }
Entry entry = new Entry( new Integer(currentTagDepth), cannonicalRef);
refStack.push( entry );
@@ -431,6 +440,11 @@
super.startElement( uri, name, raw, attributes);
this.ignoreHooksCount = 0;
}
+ else if (TAG_INSERTVIOLATIONS.equals(name))
+ {
+ startElementViolations( uri, name, raw, attributes );
+ } // end if TAG_INSERTVIOLATIONS
+
// if we're within a xf:hidden element
// and a value sub-element has been provided
// in the markup, then it will be left
@@ -439,20 +453,16 @@
// attribute
else if ( isHiddenTag && TAG_VALUE.equals( name ) )
{
- hasHiddenTagValue = true;
- super.startElement( uri, name, raw, attributes);
+ hasHiddenTagValue = true;
+ super.startElement( uri, name, raw, attributes);
}
// if the currentForm is still not available
// then we can't process nested form tags
else if (currentForm != null)
{
- if (TAG_INSERTVIOLATIONS.equals(name))
- {
- startElementViolations( uri, name, raw, attributes );
- } // end if TAG_INSERTVIOLATIONS
- else if (
+ if (
TAG_TEXTBOX.equals(name) ||
TAG_TEXTAREA.equals(name) ||
TAG_PASSWORD.equals(name) ||
@@ -529,10 +539,29 @@
protected void startElementViolations(String uri, String name, String raw, Attributes attributes) throws SAXException
{
- SortedSet violations = currentForm.getViolationsAsSortedSet();
+
+ // we will either use the locally referenced form id
+ // or the global id. At least one of the two must be available
+ Form form = null;
+ String formAttr = attributes.getValue( TAG_OUTPUT_ATTR_FORM );
+ if (formAttr == null)
+ {
+ if (currentForm == null)
+ {
+ throw new SAXException( "When used outside of a form tag, the output tag requires an '" + TAG_OUTPUT_ATTR_FORM + "' attribute" );
+ }
+ form = currentForm;
+ }
+ else
+ {
+ form = Form.lookup( objectModel, formAttr );
+ }
+
+ SortedSet violations = form.getViolationsAsSortedSet();
// if there are no violations, there is nothing to show
if (violations == null) return;
+
// if we're immediately under the form tag
// and parent "ref" attribute is not available
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org