cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation SourceWritingTransformer.java
Date Sun, 01 Dec 2002 20:57:52 GMT
sylvain     2002/12/01 12:57:52

  Modified:    src/scratchpad/src/org/apache/cocoon/transformation Tag:
                        cocoon_2_0_3_branch SourceWritingTransformer.java
  Log:
  Fix namespace : namespaces declared outside source:write are redeclared for proper serialization
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +22 -1     xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/Attic/SourceWritingTransformer.java
  
  Index: SourceWritingTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/Attic/SourceWritingTransformer.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- SourceWritingTransformer.java	22 Mar 2002 13:14:55 -0000	1.3
  +++ SourceWritingTransformer.java	1 Dec 2002 20:57:52 -0000	1.3.2.1
  @@ -72,9 +72,10 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  -import java.lang.SecurityException;
  +import org.xml.sax.helpers.NamespaceSupport;
   import java.io.IOException;
   import java.io.OutputStream;
  +import java.util.Enumeration;
   import java.util.Map;
   import java.util.Properties;
   
  @@ -178,6 +179,8 @@
   		/** the WritableSource. */
       private WriteableSource wsource = null;
       
  +    private NamespaceSupport nsSupport = new NamespaceSupport();
  +    
       
       public void WriteableSourceTransformer() {
       }
  @@ -223,7 +226,10 @@
        */
       public void startPrefixMapping(String prefix, String uri) throws SAXException {
   			if (!this.processing) {
  +				// Pass through
   				super.startPrefixMapping(prefix,uri);
  +				// and register it.
  +				this.nsSupport.declarePrefix(prefix, uri);
   			} else if (this.ch != null){
   				this.ch.startPrefixMapping(prefix, uri);
   			}
  @@ -258,6 +264,7 @@
       public void startElement(String uri, String loc, String raw, Attributes a)
       throws SAXException {
   			if (!this.processing) {
  +				this.nsSupport.pushContext();
   				if (SWT_URI.equals(uri) && SWT_ELEMENT.equals(loc)) {
   					getLogger().debug("start processing xmlns:source");
   					this.failed = false;
  @@ -305,6 +312,12 @@
   					// start the document
   					if (!this.failed) {
   						this.ch.startDocument();
  +						// and give it all declared namespaces.
  +						Enumeration prefixes = this.nsSupport.getPrefixes();
  +						while (prefixes.hasMoreElements()) {
  +							String prefix = (String)prefixes.nextElement();
  +							ch.startPrefixMapping(prefix, this.nsSupport.getURI(prefix));
  +						}
   					}						
   					this.processing = true;
   					getLogger().debug("Processing Started");
  @@ -331,10 +344,18 @@
       public void endElement(String uri, String loc, String raw)
       throws SAXException {
   			if (!this.processing) {
  +                this.nsSupport.popContext();
   				super.endElement(uri,loc,raw);
   			} else {
   				if (SWT_URI.equals(uri) && SWT_ELEMENT.equals(loc)){
   					if (!this.failed) {
  +						// and close all declared namespaces.
  +						Enumeration prefixes = this.nsSupport.getPrefixes();
  +						while (prefixes.hasMoreElements()) {
  +							String prefix = (String)prefixes.nextElement();
  +							ch.endPrefixMapping(prefix);
  +						}
  +
   						this.ch.endDocument();
   					}
   					this.processing = false;
  
  
  

----------------------------------------------------------------------
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


Mime
View raw message