zongaro     2005/01/20 08:59:35

  Modified:    java/src/org/apache/xalan/serialize SerializerUtils.java
  Log:
  Applying patch for Jira bug report XALANJ-1640.
  
  As it's currently written, SerializerUtils.outputResultTreeFragment loops
  through the nodes in a result tree fragment, and for each one, it checks
  whether the node is in some namespace.  If it is not, the code undeclares the
  default namespace by calling handler.startPrefixMapping("", "").  The problem
  is that if the RTF that's being copied just consists of a text node (or PIs or
  comments), that undeclaration of the default namespace hangs around until some
  subsequent child element picks it up as one of its attributes, even if that
  element is in some namespace - even what should be the default!
  
  The fix is to check whether the node that is being output is an element node
  prior to issuing the handler.startPrefixMapping call - that ensures the prefix
  mapping is not issued unless it's actually going to be used by the node that 
is
  about to be serialized.
  
  This patch was reviewed by Brian Minchau (minchau () ca ! ibm ! com).
  
  Revision  Changes    Path
  1.4       +5 -3      
xml-xalan/java/src/org/apache/xalan/serialize/SerializerUtils.java
  
  Index: SerializerUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/SerializerUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SerializerUtils.java      16 Feb 2004 20:27:14 -0000      1.3
  +++ SerializerUtils.java      20 Jan 2005 16:59:34 -0000      1.4
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -130,9 +130,11 @@
                   n = dtm.getNextSibling(n))
               {
                   handler.flushPending();
  +
                   // I think. . . . This used to have a (true) arg
                   // to flush prefixes, will that cause problems ???
  -                if (dtm.getNamespaceURI(n) == null)
  +                if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
  +                        && dtm.getNamespaceURI(n) == null)
                       handler.startPrefixMapping("", "");
                   dtm.dispatchToEvents(n, handler);
               }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to