vgritsenko    2004/02/07 11:34:20

  Modified:    .        status.xml
               java/src/org/apache/xindice/xml/dom ElementImpl.java
  Log:
  Declare Query namespace just once.
  
  Revision  Changes    Path
  1.29      +4 -0      xml-xindice/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/status.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- status.xml        6 Feb 2004 13:38:30 -0000       1.28
  +++ status.xml        7 Feb 2004 19:34:20 -0000       1.29
  @@ -60,6 +60,10 @@
   
       <changes>
           <release version="1.1b4-dev" date="February 6 2004">
  +            <action dev="VG" type="fix">
  +                In results of the queries like "//*", declare
  +                http://xml.apache.org/xindice/Query namespace just once.
  +            </action>
               <action dev="VG" type="update">
                   Lexus, XUpdate implementation, updated to the current CVS 
version
                   (20040205).
  
  
  
  1.18      +17 -6     
xml-xindice/java/src/org/apache/xindice/xml/dom/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/ElementImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ElementImpl.java  25 Dec 2003 03:48:10 -0000      1.17
  +++ ElementImpl.java  7 Feb 2004 19:34:20 -0000       1.18
  @@ -129,7 +129,7 @@
           } else {
               loaded = true;
           }
  -        
  +
           try {
               if (data != null) {
                   DocumentImpl doc = (DocumentImpl) getOwnerDocument();
  @@ -159,10 +159,13 @@
           return symbolID;
       }
   
  +    /**
  +     * Add "src" and "col" attributes in [EMAIL PROTECTED] 
NodeSource#SOURCE_NS} namespace. 
  +     */
       public void expandSource() {
           NodeSource src = getSource();
           if (src != null) {
  -            final String prefix = sourcePrefix("src");
  +            final String prefix = sourcePrefix("src", NodeSource.SOURCE_NS);
   
               setAttribute(XMLNS_PREFIX + ":" + prefix, NodeSource.SOURCE_NS);
               setAttribute(prefix + ":" + NodeSource.SOURCE_COL, 
src.getCollection().getCanonicalName());
  @@ -173,7 +176,11 @@
           }
       }
   
  -    private String sourcePrefix(final String candidatePrefix) {
  +    /**
  +     * Choose unique prefix for a namespace.
  +     * Reuse existing prefix if namespace is already defined.
  +     */
  +    private String sourcePrefix(final String candidatePrefix, final String 
nsuri) {
           Element element = this;
           HashSet prefixes = new HashSet();
           while (element != null) {
  @@ -182,7 +189,11 @@
                   final Attr a = (Attr) nm.item(i);
                   final String name = a.getNodeName();
                   if (name.startsWith("xmlns:")) {
  -                    prefixes.add(name.substring(6));
  +                    final String prefix = name.substring(6);
  +                    if (nsuri.equals(a.getValue())) {
  +                        return prefix;
  +                    }
  +                    prefixes.add(prefix);
                   }
               }
               element = element.getParentNode().getNodeType() == ELEMENT_NODE 
? (Element) element.getParentNode() : null;
  
  
  

Reply via email to