You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/12/08 22:32:26 UTC

cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation WidgetReplacingPipe.java

vgritsenko    2003/12/08 13:32:26

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/transformation
                        WidgetReplacingPipe.java
  Log:
  Figting with namespaces:
  WidgetReplacingPipe processes all elements in wt: namespace,
  so there is no reason to propagate this namespace declaration
  down the pipe.
  
  Revision  Changes    Path
  1.16      +42 -11    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WidgetReplacingPipe.java
  
  Index: WidgetReplacingPipe.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WidgetReplacingPipe.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- WidgetReplacingPipe.java	17 Nov 2003 10:04:00 -0000	1.15
  +++ WidgetReplacingPipe.java	8 Dec 2003 21:32:26 -0000	1.16
  @@ -68,10 +68,11 @@
   import org.xml.sax.helpers.AttributesImpl;
   
   /**
  - * The basic operation of this Pipe is that it replaces wi:widget tags (having an id attribute)
  + * The basic operation of this Pipe is that it replaces wt:widget (in the
  + * {@link Constants#WT_NS} namespace) tags (having an id attribute)
    * by the XML representation of the corresponding widget instance.
    *
  - * <p>These XML fragments (normally all in the {@link Constants#WI_NS "Woody Instance"} namespace, can
  + * <p>These XML fragments (normally all in the {@link Constants#WI_NS "Woody Instance"} namespace), can
    * then be translated to a HTML presentation by an XSL. This XSL will then only have to style
    * individual widget, and will not need to do the whole page layout.
    *
  @@ -92,35 +93,59 @@
       private static final String FORM_TEMPLATE_EL = "form-template";
       private static final String STYLING_EL = "styling";
   
  -    /** Default key under which the woody form is stored in the JXPath context. */
  +    /**
  +     * Default key under which the woody form is stored in the JXPath context.
  +     */
       public static final String WOODY_FORM = "woody-form";
   
       protected Widget contextWidget;
  -    /** Indicates whether we're currently in a widget element. */
  +
  +    /**
  +     * Indicates whether we're currently in a widget element.
  +     */
       protected boolean inWidgetElement;
  -    /** Buffer used to temporarily record SAX events. */
  +
  +    /**
  +     * Buffer used to temporarily record SAX events.
  +     */
       protected SaxBuffer saxBuffer;
  -    /** Counts the element nesting. */
  +
  +    /**
  +     * Counts the element nesting.
  +     */
       protected int elementNestingCounter;
  +
       /**
        * Contains the value of the {@link #elementNestingCounter} on the moment the transformer
        * encountered a wi:widget element. Used to detect the corresponding endElement call
        * for the wi:widget element.
        */
       protected int widgetElementNesting;
  +
       /**
        * If {@link #inWidgetElement} = true, then this contains the widget currenlty being handled.
        */
       protected Widget widget;
  -    /** Boolean indicating wether the current widget requires special repeater-treatement. */
  +
  +    /**
  +     * Boolean indicating wether the current widget requires special repeater-treatement.
  +     */
       protected boolean repeaterWidget;
   
       protected WoodyTemplateTransformer.InsertStylingContentHandler stylingHandler = new WoodyTemplateTransformer.InsertStylingContentHandler();
       protected WoodyTemplateTransformer pipeContext;
   
  -    /** Have we encountered a <wi:style> element in a widget ? */
  +    /**
  +     * Have we encountered a <wi:style> element in a widget ?
  +     */
       protected boolean gotStylingElement;
   
  +    /** 
  +     * Namespace prefix used for the namespace <code>Constants.WT_NS</code>.
  +     */
  +    protected String namespacePrefix;
  +    
  +
       public void init(Widget newContextWidget, WoodyTemplateTransformer newPipeContext) {
           contextWidget = newContextWidget;
           inWidgetElement = false;
  @@ -397,7 +422,10 @@
   
       public void startPrefixMapping(String prefix, String uri)
               throws SAXException {
  -        if (inWidgetElement) {
  +        if (Constants.WT_NS.equals(uri)) {
  +            // We consume this namespace completely
  +            this.namespacePrefix = prefix;
  +        } else if (inWidgetElement) {
               saxBuffer.startPrefixMapping(prefix, uri);
           } else {
               super.startPrefixMapping(prefix, uri);
  @@ -406,7 +434,9 @@
   
       public void endPrefixMapping(String prefix)
               throws SAXException {
  -        if (inWidgetElement) {
  +        if (prefix.equals(this.namespacePrefix)) {
  +            // We consume this namespace completely
  +        } else if (inWidgetElement) {
               saxBuffer.endPrefixMapping(prefix);
           } else {
               super.endPrefixMapping(prefix);
  @@ -497,6 +527,7 @@
           super.recycle();
           this.contextWidget = null;
           this.widget = null;
  +        this.namespacePrefix = null;
       }
   
       /**