sboag       01/03/11 22:29:29

  Modified:    java/src/org/apache/xpath/patterns NodeTest.java
  Log:
  Xerces at some point decided to use "" instead
  of null for null namespaces.  There has been a
  discussion between Gary Peskin in
  Joe Kessleman on xalan-dev about this,
  but I hadn't been fully keeping up the the
  thread that well, and missed it's relation to
  this problem.  I include some of the discussion
  at the end of this note.  I made Xalan be able to
  compare a "" namespace to null for now, until
  we get this resolved.
  
  The gist of the discussion on xalan-dev regarding this is:
  
  >>1.  Declare the Xerces-J support of schemas to have a bug and ask that
  >>Xerces be corrected to always use a null namespace URI to indicate that
  >>there is no default namespace.  Even if the Xerces people change this
  >>behavior, is this correct?
  >
  > Yes. If your description of the problem is accurate (you should probably
  > submit a more detailed case so it can be reproduced in the lab), this is a
  > parser/DOM-builder bug.
  
  Revision  Changes    Path
  1.20      +19 -2     
xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java
  
  Index: NodeTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/NodeTest.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- NodeTest.java     2001/02/14 03:10:41     1.19
  +++ NodeTest.java     2001/03/12 06:29:29     1.20
  @@ -361,6 +361,23 @@
       // System.out.println("subPartMatch - p: "+p+", t: "+t+", result: "+b);
       return (p == t) || ((null != p) && ((t == WILD) || p.equals(t)));
     }
  +  
  +  /**
  +   * This is temporary to patch over Xerces issue with representing DOM 
  +   * namespaces as "".
  +   *
  +   * @param p part string from the node, which may represent the null 
namespace 
  +   *        as null or as "".
  +   * @param t target string, which may be [EMAIL PROTECTED] #WILD}.
  +   *
  +   * @return true if the strings match according to the rules of this method.
  +   */
  +  private static final boolean subPartMatchNS(String p, String t)
  +  {
  +
  +    return (p == t) || ((null != p) && ((p.length() > 0) ? ((t == WILD) || 
p.equals(t)) : null == t));
  +  }
  +
   
     /**
      * Tell what the test score is for the given node.
  @@ -447,7 +464,7 @@
           DOMHelper dh = xctxt.getDOMHelper();
   
           if (!dh.isNamespaceNode(context))
  -          return (m_isTotallyWild || 
(subPartMatch(dh.getNamespaceOfNode(context), m_namespace) && 
subPartMatch(dh.getLocalNameOfNode(context), m_name)))
  +          return (m_isTotallyWild || 
(subPartMatchNS(dh.getNamespaceOfNode(context), m_namespace) && 
subPartMatch(dh.getLocalNameOfNode(context), m_name)))
                    ? m_score : SCORE_NONE;
           else
             return SCORE_NONE;
  @@ -468,7 +485,7 @@
       {
         DOMHelper dh = xctxt.getDOMHelper();
   
  -      return (m_isTotallyWild || 
(subPartMatch(dh.getNamespaceOfNode(context), m_namespace) && 
subPartMatch(dh.getLocalNameOfNode(context), m_name)))
  +      return (m_isTotallyWild || 
(subPartMatchNS(dh.getNamespaceOfNode(context), m_namespace) && 
subPartMatch(dh.getLocalNameOfNode(context), m_name)))
                ? m_score : SCORE_NONE;
       }
       default :
  
  
  

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

Reply via email to