You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by ig...@apache.org on 2003/11/11 01:36:35 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom DOMAdapter.java SAXImpl.java

igorh       2003/11/10 16:36:35

  Modified:    java/src/org/apache/xalan/xsltc/compiler Tag:
                        xslt20-compiled xpath.cup XSLTC.java
               java/src/org/apache/xalan/xsltc/dom Tag: xslt20-compiled
                        DOMAdapter.java SAXImpl.java
  Log:
  Patch for Bugzilla Bug 14607
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.47.4.1  +3 -3      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.47
  retrieving revision 1.47.4.1
  diff -u -r1.47 -r1.47.4.1
  --- xpath.cup	1 Apr 2003 21:09:00 -0000	1.47
  +++ xpath.cup	11 Nov 2003 00:36:35 -0000	1.47.4.1
  @@ -165,7 +165,7 @@
   
   	    if (axis == Axis.NAMESPACE) {
   		nodeType = (name.toString().equals("*")) ? -1
  -				: _xsltc.registerNamespace(name);
  +				: _xsltc.registerNamespacePrefix(name);
               }
   	    else {
   		final String uri = name.getNamespace();
  @@ -227,7 +227,7 @@
   
   	    if (axis == Axis.NAMESPACE) {
   		return (name.toString().equals("*")) ? -1
  -		    : _xsltc.registerNamespace(name);
  +		    : _xsltc.registerNamespacePrefix(name);
               }
   
   	    if (name.getNamespace() == null) {
  
  
  
  1.54.2.1  +24 -11    xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.54
  retrieving revision 1.54.2.1
  diff -u -r1.54 -r1.54.2.1
  --- XSLTC.java	9 Sep 2003 15:44:48 -0000	1.54
  +++ XSLTC.java	11 Nov 2003 00:36:35 -0000	1.54.2.1
  @@ -125,7 +125,7 @@
       private int       _nextNSType; // Next available namespace type
       private Vector    _namespaceIndex; // Index of all registered namespaces
       private Hashtable _namespaces; // Hashtable of all registered namespaces
  -
  +    private Hashtable _namespacePrefixes;// Hashtable of all registered namespace prefixes
       // All literal text in the stylesheet
       private Vector m_characterData;
   
  @@ -209,6 +209,7 @@
   	_namespaces.put("",new Integer(_nextNSType));
   	_namesIndex     = new Vector(128);
   	_namespaceIndex = new Vector(32);
  +  _namespacePrefixes = new Hashtable();
           _stylesheet     = null;
   	_parser.init();
   	//_variableSerial     = 1;
  @@ -670,15 +671,27 @@
   	return code.intValue();
       }
   
  -    /**
  -     * Registers an element and gives it a type so that it can be mapped to
  -     * DOM element types at run-time.
  -     */
  -    public int registerNamespace(QName name) {
  -	final SymbolTable stable = _parser.getSymbolTable();
  -	final String uri = stable.lookupNamespace(name.toString());
  -	final int code = registerNamespace(uri);
  -	return code;
  +    
  +     /** 
  +      * Registers a namespace prefix and gives it a type so that it can be mapped to
  +      * DOM namespace types at run-time.
  +      */
  +  
  +    public int registerNamespacePrefix(QName name) {
  +    
  +    Integer code = (Integer)_namespacePrefixes.get(name.toString());
  +    if (code == null) {   
  +        code = new Integer(_nextGType++);
  +        _namespacePrefixes.put(name.toString(), code); 
  +        final String uri = name.getNamespace();
  +        if ((uri != null) && (!uri.equals(""))){
  +            // namespace::ext2:ped2 will be made empty in TypedNamespaceIterator
  +            _namesIndex.addElement("?"); 
  +        } else{        
  +           _namesIndex.addElement("?"+name.getLocalPart());        
  +        }
  +    }   
  +    return code.intValue();
       }
   
       /**
  
  
  
  No                   revision
  No                   revision
  1.19.2.1  +2 -10     xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
  
  Index: DOMAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
  retrieving revision 1.19
  retrieving revision 1.19.2.1
  diff -u -r1.19 -r1.19.2.1
  --- DOMAdapter.java	23 Jun 2003 15:58:17 -0000	1.19
  +++ DOMAdapter.java	11 Nov 2003 00:36:35 -0000	1.19.2.1
  @@ -212,15 +212,7 @@
       public DTMAxisIterator getTypedAxisIterator(final int axis,
                                                   final int type) {
           final int[] reverse = getReverse();
  -
  -        if (axis == Axis.NAMESPACE) {
  -            short[] NSReverse = getNSReverse();
  -            if (type == NO_TYPE || type > NSReverse.length) {
  -                return _dom.getAxisIterator(axis);
  -            } else {
  -                return _dom.getTypedAxisIterator(axis, NSReverse[type]);
  -            }
  -        } else if (_saxImpl != null) {
  +        if (_saxImpl != null) {
               return _saxImpl.getTypedAxisIterator(axis, reverse[type]);
           } else {
               return _dom.getTypedAxisIterator(axis, type);
  
  
  
  1.8.2.2   +17 -15    xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- SAXImpl.java	15 Oct 2003 18:08:31 -0000	1.8.2.1
  +++ SAXImpl.java	11 Nov 2003 00:36:35 -0000	1.8.2.2
  @@ -346,8 +346,8 @@
        * model for a given node, filtered by extended type ID.
        */
       public class TypedNamespaceIterator extends NamespaceIterator {
  -        /** The extended type ID that was requested. */
  -        private final int _nodeType;
  +        
  +        private  String _nsPrefix;
   
           /**
            * Constructor TypedChildrenIterator
  @@ -355,9 +355,14 @@
            *
            * @param nodeType The extended type ID being requested.
            */
  -        public TypedNamespaceIterator(int nodeType) {
  +        public TypedNamespaceIterator(int nodeType) { 
               super();
  -            _nodeType = nodeType;
  +            if(m_expandedNameTable != null){
  +                final String prefix = m_expandedNameTable.getLocalName(nodeType);
  +                if((prefix != null) &&  (prefix.charAt(0) == '?') ) {
  +                  _nsPrefix = prefix.substring(1);
  +                }
  +            }
           }
   
          /**
  @@ -366,22 +371,21 @@
           * @return The next node handle in the iteration, or END.
           */
           public int next() {
  -            int node;
  -
  +             if((_nsPrefix == null) ||(_nsPrefix.length() == 0) ){
  +                 return (END);
  +             }          
  +            int node = END;
               for (node = super.next(); node != END; node = super.next()) {
  -                if (getExpandedTypeID(node) == _nodeType
  -                      || getNodeType(node) == _nodeType
  -                      || getIdForNamespace(getStringValueX(node))
  -                             == _nodeType) {
  +                if (_nsPrefix.compareTo(getLocalName(node))== 0) {
                       return returnNode(node);
                   }
               }
  -
               return (END);
           }
       }  // end of TypedNamespaceIterator
   
   
  +
       /**************************************************************
        * This is a specialised iterator for predicates comparing node or
        * attribute values to variable or parameter values.
  @@ -1194,9 +1198,7 @@
               case Axis.PRECEDINGSIBLING:
                   return new TypedPrecedingSiblingIterator(type);
               case Axis.NAMESPACE:
  -                return (type == DTM.ELEMENT_NODE)
  -                       ? new NamespaceIterator()
  -                       : new TypedNamespaceIterator(type);
  +                return  new TypedNamespaceIterator(type);
               default:
                   BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR, Axis.names[axis]);
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org