vgritsenko    02/01/25 18:18:16

  Modified:    src/java/org/apache/cocoon/serialization
                        AbstractTextSerializer.java
  Log:
  Patch xmlns:xml issue reported by Felix Knecht [mailto:[EMAIL PROTECTED]]
  
  Revision  Changes    Path
  1.4       +21 -20    
xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java
  
  Index: AbstractTextSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/serialization/AbstractTextSerializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractTextSerializer.java       10 Jan 2002 12:08:28 -0000      1.3
  +++ AbstractTextSerializer.java       26 Jan 2002 02:18:16 -0000      1.4
  @@ -43,7 +43,7 @@
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sylvain Wallez</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/01/10 12:08:28 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/01/26 02:18:16 $
    */
   public abstract class AbstractTextSerializer
   extends AbstractSerializer
  @@ -315,8 +315,7 @@
            */
           private boolean hasMappings = false;
   
  -        public void startDocument()
  -          throws SAXException {
  +        public void startDocument() throws SAXException {
               // Cleanup
               this.uriToPrefixMap.clear();
               this.prefixToUriMap.clear();
  @@ -331,20 +330,22 @@
           public void startPrefixMapping(String prefix, String uri)
             throws SAXException {
               // Store the mappings to reconstitute xmlns:attributes
  -            this.hasMappings = true;
  -            this.prefixList.add(prefix);
  -            this.uriList.add(uri);
  -
  -            // append the prefix colon now, in order to save concatenations later, 
but
  -            // only for non-empty prefixes.
  -            if(prefix.length() > 0) {
  -                this.uriToPrefixMap.put(uri, prefix + ":");
  -            } else {
  -                this.uriToPrefixMap.put(uri, prefix);
  -            }
  -
  -            this.prefixToUriMap.put(prefix, uri);
  +            // except prefixes starting with "xml": these are reserved
  +            if (!prefix.startsWith("xml")) {
  +                this.hasMappings = true;
  +                this.prefixList.add(prefix);
  +                this.uriList.add(uri);
  +
  +                // append the prefix colon now, in order to save concatenations 
later, but
  +                // only for non-empty prefixes.
  +                if(prefix.length() > 0) {
  +                    this.uriToPrefixMap.put(uri, prefix + ":");
  +                } else {
  +                    this.uriToPrefixMap.put(uri, prefix);
  +                }
   
  +                this.prefixToUriMap.put(prefix, uri);
  +            }
               super.startPrefixMapping(prefix, uri);
           }
   
  @@ -358,7 +359,7 @@
             throws SAXException {
   
               // try to restore the qName. The map already contains the colon
  -            if (null != eltUri && eltUri.length() != 0 && 
this.uriToPrefixMap.containsKey(eltUri) )
  +            if (null != eltUri && eltUri.length() != 0 && 
this.uriToPrefixMap.containsKey(eltUri))
                 eltQName = (String) this.uriToPrefixMap.get(eltUri) + eltLocalName;
   
               if (this.hasMappings) {
  @@ -379,15 +380,15 @@
   
                       // Search for the corresponding xmlns* attribute
                       boolean found = false;
  -                    find : for (int attr = 0; attr < attrCount; attr++) {
  +                    for (int attr = 0; attr < attrCount; attr++) {
                           if (qName.equals(attrs.getQName(attr))) {
                               // Check if mapping and attribute URI match
                               if (! uri.equals(attrs.getValue(attr))) {
  -                                getLogger().error("AbstractTextSerializer:URI in 
prefix mapping and attribute do not match : '" + uri + "' - '" + attrs.getURI(attr) + 
"'");
  +                                getLogger().error("URI in prefix mapping and 
attribute do not match : '" + uri + "' - '" + attrs.getURI(attr) + "'");
                                   throw new SAXException("URI in prefix mapping and 
attribute do not match");
                               }
                               found = true;
  -                            break find;
  +                            break;
                           }
                       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to