CMNamedNodeMapImpl elementMap = isLocal ?
(CMNamedNodeMapImpl)cmDocumentImpl.getLocalElementPool() :
(CMNamedNodeMapImpl)cmDocumentImpl.getElements();
CMElementDeclarationImpl ed = (CMElementDeclarationImpl)elementMap.getNamedItem(localName);
if (ed == null)
{
//System.out.println("create ed " + localName);
ed = new CMElementDeclarationImpl(cmDocument, localName);
ed.setInferred(true);
ed.setLocal(isLocal);
ed.setMaxOccur(1);
CMGroupImpl group = new CMGroupImpl(new CMNodeListImpl(), CMGroup.CHOICE);
group.setInferred(true);
group.setMinOccur(0);
group.setMaxOccur(-1);
ed.setContent(group);
elementMap.put(ed);
}
// lookup or create the attributes
//
NamedNodeMap attributeMap = element.getAttributes();
int attributeMapLength = attributeMap.getLength();
for (int i = 0; i < attributeMapLength; i++)
{
Attr attr = (Attr)attributeMap.item(i);
CMAttributeDeclarationImpl ad = (CMAttributeDeclarationImpl)ed.getAttributeMap().getNamedItem(attr.getNodeName());
if (ad == null)
{
// todo... use an attribute pool to be more efficient?
ad = new CMAttributeDeclarationImpl(attr.getNodeName(), CMAttributeDeclaration.OPTIONAL);
ad.setInferred(true);
ed.getAttributeMap().put(ad);
}
}
return ed;
}