You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2002/10/01 22:59:16 UTC

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

zongaro     2002/10/01 13:59:16

  Modified:    java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
                        SAXImpl.java
  Log:
  ..\..\..\temp\dup.txt
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.14  +57 -65    xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
  
  Index: SAXImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- SAXImpl.java	27 Sep 2002 21:54:39 -0000	1.1.2.13
  +++ SAXImpl.java	1 Oct 2002 20:59:15 -0000	1.1.2.14
  @@ -225,15 +225,17 @@
        */
       public boolean isElement(final int node)
       {
  -      return (((node < _firstAttributeNode) && (getType(node) >= DTM.NTYPES)) || getNodeType(node) == DTM.ELEMENT_NODE);
  +      return (((node < _firstAttributeNode) && (getType(node) >= DTM.NTYPES))
  +              || getNodeType(node) == DTM.ELEMENT_NODE);
       }
   
       /**
  -     * Returns 'true' if a specific node is an element (of any type)
  +     * Returns 'true' if a specific node is an attribute (of any type)
        */
       public boolean isAttribute(final int node)
       {
  -      return (((node >= _firstAttributeNode) && (getType(node) >= DTM.NTYPES)) || getNodeType(node) == DTM.ATTRIBUTE_NODE);
  +      return (((node >= _firstAttributeNode) && (getType(node) >= DTM.NTYPES))
  +              || getNodeType(node) == DTM.ATTRIBUTE_NODE);
       }
   
       /**
  @@ -748,8 +750,7 @@
   	return _parent[node];
       }  use DTM's */
   
  -    public int getElementPosition(int node)
  -    {
  +    public int getElementPosition(int node) {
         // Initialize with the first sbiling of the current node
         int match = 0;
         int curr  = getFirstChild(getParent(node));
  @@ -902,16 +903,13 @@
       /**
        * Sets up a translet-to-dom type mapping table
        */
  -    private int[] setupMapping(String[] namesArray)
  -    {
  -      final int nNames = namesArray.length;
  +    private int[] setupMapping(String[] namesArray, int nNames) {
         // Padding with number of names, because they
         // may need to be added, i.e for RTFs. See copy03  
  -      final int[] types = new int[m_expandedNameTable.getSize() /*+ nNames*/]; //(nNames);
  +      final int[] types = new int[m_expandedNameTable.getSize()];
         for (int i = 0; i < nNames; i++)      {
  -        //types.put(namesArray[i], new Integer(i + DTM.NTYPES));
             int type = getGeneralizedType(namesArray[i]);
  -          types[type] = type; //(i + DTM.NTYPES);
  +          types[type] = type;
         }
         return types;
       }
  @@ -1123,7 +1121,7 @@
   	    _dontEscape = null;
           }
   
  -      _types         = setupMapping(_namesArray);
  +      _types         = setupMapping(_namesArray, _namesArray.length);
       }
   
       /*
  @@ -2068,8 +2066,7 @@
   
   	/**
   	 * Generate the internal type for an element's expanded QName
  -	 */
  -	public short makeElementNode(String uri, String localname)
  +	public void makeElementNode(String uri, String localname)
   	    throws SAXException
     {
   
  @@ -2080,18 +2077,15 @@
         name = localname;
   
       // Stuff the QName into the names vector & hashtable
  -    Integer obj = (Integer)_names.get(name);
  -    if (obj == null)
  +    if (_names.get(name) == null)
       {
  -      _names.put(name, obj = new Integer(_nextNameCode++));
  +      _names.put(name, new Integer(_nextNameCode++));
       }
  -    return (short)obj.intValue();
     }
   
   	/**
   	 * Generate the internal type for an element's expanded QName
  -	 */
  -	private short makeElementNode(String name, int col)
  +	private void makeElementNode(String name, int col)
   	    throws SAXException
     {
       // Expand prefix:localname to full QName
  @@ -2108,13 +2102,12 @@
       }
   
       // Stuff the QName into the names vector & hashtable
  -    Integer obj = (Integer)_names.get(name);
  -    if (obj == null)
  +    if (_names.get(name) == null)
       {
  -      _names.put(name, obj = new Integer(_nextNameCode++));
  +      _names.put(name, new Integer(_nextNameCode++));
       }
  -    return (short)obj.intValue();
     }
  +*/
   
   	/**
   	 *
  @@ -2125,7 +2118,7 @@
       if (stack != null)
       {
         Integer obj = (Integer)stack.elementAt(0);
  -      return (short)obj.intValue();
  +      return obj.shortValue();
       }
       return 0;
     }
  @@ -2232,8 +2225,7 @@
   
   	/**
   	 * Creates an attribute node
  -	 */
  -  private int makeAttributeNode(int parent, Attributes attList, int i)
  +  private void makeAttributeNode(int parent, Attributes attList, int i)
       throws SAXException
     {
       final int node = nextAttributeNode();
  @@ -2252,24 +2244,23 @@
   
       // Create the internal attribute node name (uri+@+localname)
       final String uri = attList.getURI(i);
  -    if (uri != null && !uri.equals(EMPTYSTRING))
  -    {
  +    if (uri != null && !uri.equals(EMPTYSTRING)) {
         namebuf.append(uri);
  -      namebuf.append(':');
  +      namebuf.append(":@");
  +    } else {
  +      namebuf.append('@');
       }
  -    namebuf.append('@');
       namebuf.append((localName.length() != 0) ? localName : qname);
   
       String name = namebuf.toString();
   
       // Get the index of the attribute node name (create new if non-ex).
  -    Integer obj = (Integer)_names.get(name);
  -    if (obj == null)
  +    if (_names.get(name) == null)
       {
  -      _names.put(name, obj = new Integer(_nextNameCode++));
  +      _names.put(name, new Integer(_nextNameCode++));
       }
  -    return node;
     }
  +	 */
   
   	/****************************************************************/
   	/*               SAX Interface Starts Here                      */
  @@ -2327,20 +2318,35 @@
       makeTextNode(false);
   
       _shortTexts = null;
  -    final int namesSize = _nextNameCode - DTM.NTYPES;
  +    final int namesSize = m_expandedNameTable.getSize() - DTM.NTYPES;
   
       // Fill the _namesArray[] array
  -    _namesArray = new String[namesSize];
  -    Enumeration keys = _names.keys();
  -    while (keys.hasMoreElements())
  -    {
  -      final String name = (String)keys.nextElement();
  -      final Integer idx = (Integer)_names.get(name);
  -      _namesArray[idx.intValue() - DTM.NTYPES] = name;
  +    String[] namesArray = new String[namesSize];
  +    int nameCount = 0;
  +
  +    for (int i = 0; i < namesSize; i++) {
  +        final short nodeType =
  +                        m_expandedNameTable.getType(i+DTM.NTYPES);
  +        final boolean isAttr = (nodeType == DTM.ATTRIBUTE_NODE);
  +        if (isAttr || nodeType == DTM.ELEMENT_NODE) {
  +            final String uri = m_expandedNameTable
  +                                        .getNamespace(i+DTM.NTYPES);
  +            final String lName = m_expandedNameTable
  +                                        .getLocalName(i+DTM.NTYPES);
  +
  +            if (uri != null && uri.length() != 0) {
  +                namesArray[nameCount++] = isAttr ? (uri + ":@" + lName)
  +                                               : uri + ":" + lName;
  +            } else {
  +                namesArray[nameCount++] = isAttr ? ("@"+lName) : lName;
  +            }
  +        }
       }
  +    _namesArray = namesArray;
  +    _nextNameCode = nameCount;
   
       _names = null;
  -    _types = setupMapping(_namesArray);
  +    _types = setupMapping(_namesArray, nameCount);
   
       // trim arrays' sizes
       //resizeTextArray(_currentOffset);
  @@ -2352,9 +2358,9 @@
       //_treeNodeLimit = _currentNode + _currentAttributeNode;
   
       // Fill the _namespace[] and _uriArray[] array
  -    _namespace = new short[namesSize];
  +    _namespace = new short[nameCount];
       _uriArray = new String[_uriCount];
  -    for (int i = 0; i<namesSize; i++)
  +    for (int i = 0; i<nameCount; i++)
       {
         final String qname = _namesArray[i];
         final int col = _namesArray[i].lastIndexOf(':');
  @@ -2400,26 +2406,12 @@
   
       final int count = attributes.getLength();
   
  -    // Append any attribute nodes
  -    if (count > 0)
  -    {
  -      for (int i = 0; i<count; i++)
  -      {
  -        if (!attributes.getQName(i).startsWith(XMLNS_PREFIX)) {
  -          makeAttributeNode(node, attributes, i);
  -        }
  +    // Look for any xml:space attributes
  +    for (int i = 0; i<count; i++) {
  +      if (attributes.getQName(i).equals(XMLSPACE_STRING)) {
  +        xmlSpaceDefine(attributes.getValue(i), node);
         }
       }
  -
  -    final int col = qname.lastIndexOf(':');
  -
  -// %HZ% Fix comments - no assignment is happening anymore
  -    // Assign an internal type to this element (may exist)
  -    if ((uri != null) && (localName.length() > 0))
  -        makeElementNode(uri, localName);
  -    else
  -        makeElementNode(qname, col);
  -
     }
   
   	/**
  
  
  

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