You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@locus.apache.org on 2000/09/29 00:28:22 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/stree ElementImpl.java
mmidy 00/09/28 15:28:18
Modified: java/src/org/apache/xalan/stree ElementImpl.java
Log:
Fix threading problem for elements with attributes
Revision Changes Path
1.10 +46 -18 xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java
Index: ElementImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/ElementImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ElementImpl.java 2000/08/30 19:28:36 1.9
+++ ElementImpl.java 2000/09/28 22:28:17 1.10
@@ -73,7 +73,9 @@
{
// The call to getAttrCount gets the number of attributes in the list.
// The attributes are put in the list before the actual children.
- return (getChildCount() == 0) ? null : getChild(getAttrCount());
+ // Force attributes to be added first!
+ int attrs = getAttrCount();
+ return (getChildCount() == 0) ? null : getChild(attrs);
}
/**
@@ -101,7 +103,7 @@
*/
public int getChildCount()
{
- if (null == m_children && !isComplete())
+ if (null == m_children || !isComplete())
{
synchronized (this)
{
@@ -146,7 +148,8 @@
throws DOMException
{
AttrImpl attr = (AttrImpl)createAttribute(name);
- attr.setValue(value);
+ attr.setValue(value);
+
}
/**
@@ -162,7 +165,8 @@
throws DOMException
{
AttrImplNS attr = (AttrImplNS)createAttributeNS(namespaceURI, qualifiedName);
- attr.setValue(value);
+ attr.setValue(value);
+
}
/**
@@ -186,7 +190,8 @@
attr = (AttrImpl)createAttribute(name);
attr.setValue(atts.getValue(i));
- }
+ }
+
}
public void setIDAttribute(String namespaceURI,
@@ -211,14 +216,23 @@
}
else
attrImpl = new AttrImpl(name, "");
- int index = getIndex(name);
- if (index<0)
- {
+ boolean found = false;
+ for (int i = 0; i < attrsEnd; i++)
+ {
+ AttrImpl attr = (AttrImpl)m_children[i];
+ if (attr.getNodeName().equals(name))
+ {
+ m_children[i] = attrImpl;
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
appendChild(attrImpl);
attrsEnd++;
- }
- else
- m_children[index] = attrImpl;
+
+ }
return (Attr)attrImpl;
}
@@ -231,14 +245,23 @@
{
// System.out.println("qualifiedName: "+qualifiedName);
AttrImplNS attrImpl = new AttrImplNS(namespaceURI, qualifiedName, "");
- int index = getIndex(namespaceURI, qualifiedName);
- if (index<0)
- {
+ boolean found = false;
+ for (int i = 0; i < attrsEnd; i++)
+ {
+ AttrImpl attr = (AttrImpl)m_children[i];
+ if (attr.getLocalName().equals(attrImpl.getLocalName()) &&
+ attr.getNamespaceURI().equals(attrImpl.getNamespaceURI()))
+ {
+ m_children[i] = attrImpl;
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
appendChild(attrImpl);
- attrsEnd++;
- }
- else
- m_children[index] = attrImpl;
+ attrsEnd++;
+ }
return (Attr)attrImpl;
}
@@ -253,6 +276,11 @@
*/
public int getAttrCount ()
{
+ if (null == m_children && !isComplete())
+ {
+ // Force it to wait until children have been added
+ int count = getChildCount();
+ }
return attrsEnd;
}