/*
@see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
356546
@Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

        // update element stack
        stack.add(localName);

        // <context-param>
        if (elements("web-app", "context-param")) {
            currentName = null;
            currentValue = null;
        }

    }
1264877
public void startRootElement() throws XMLException, IOException {
		start();
		while (!Type.START_ELEMENT.equals(event.type)) next();
	}
1136269
public void printXMLStartElement(String name, Map<String, String> attributes)
    {
        printXMLStartElement(name, createAttributes(attributes));
    }
933052
@Override
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
		if(localName.equals(TAG_LOG_ENTRY)) {
			if (currentTags != null) {
				throw new IllegalStateException("Should not have tags when a config starts in the XML, but had: " + currentTags);
			}
			currentTags = new LogEntry();
			if(attributes.getValue(TAG_REVISION) != null) {
				currentTags.revision = Long.parseLong(attributes.getValue(TAG_REVISION));
			}
		} else if (localName.equals(TAG_PATH)) {
			lastAction = attributes.getValue(TAG_PATH_ACTION);
		}
	}
1251485
public void closeElement() throws XMLException, IOException {
		if (!Type.START_ELEMENT.equals(event.type))
			throw new IOException("Invalid call of closeElement: it must be called on a start element");
		if (event.isClosed) return;
		ElementContext ctx = event.context.getFirst();
		do {
			try { next(); }
			catch (EOFException e) {
				throw new XMLException(getPosition(), "Unexpected end", "closeElement(" + ctx.text.asString() + ")");
			}
			if (Type.END_ELEMENT.equals(event.type)) {
				if (event.context.getFirst() == ctx)
					return;
			}
		} while (true);
	}
541521
@SuppressWarnings("unchecked")
    public <T> T processElement(Element element) throws ConfigurationException
    {
        String namespace = $(element).namespaceURI();
        String tagName = $(element).tag();
        ElementHandler<?> handler = handlers.get(new HandlerId(namespace, tagName));
        if (handler != null)
        {
            Object o = handler.processElement(this, element);
            return (T) o;
        }
        throw new ConfigurationException("No Handler registered for element named [" + tagName
                    + "] in namespace: [" + namespace + "]");
    }
1363100
public void startElement(String uri, String name, String qName, Attributes atts)
    {
        boolean isDebug = logger.isDebugEnabled();

        m_CurrentString = null;
        try
        {
            switch (getLiteralId(qName))
            {
                case MAPPING_REPOSITORY:
                    {
                        if (isDebug) logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY));
                        this.m_CurrentAttrContainer = m_repository;

                        String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
                        this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso));
                        if (isDebug) logger.debug("     " + tags.getTagById(ISOLATION_LEVEL) + ": " + defIso);


                        String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
                        if (proxyPrefetchingLimit != null)
                        {
                            defProxyPrefetchingLimit = Integer.parseInt(proxyPrefetchingLimit);
                        }

                        // check repository version:
                        String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION));
                        if (DescriptorRepository.getVersion().equals(version))
                        {
                            if (isDebug) logger.debug("     " + tags.getTagById(REPOSITORY_VERSION) + ": " + version);
                        }
                        else
                        {
                            throw new MetadataException("Repository version does not match. expected " +
                                    DescriptorRepository.getVersion() + " but found: " +
                                    version+". Please update your repository.dtd and your repository.xml"+
                                    " version attribute entry");
                        }
                        break;
                    }
                case CLASS_DESCRIPTOR:
                    {
                        if (isDebug) logger.debug("  > " + tags.getTagById(CLASS_DESCRIPTOR));
                        m_CurrentCLD = new ClassDescriptor(m_repository);

                        // prepare for custom attributes
                        this.m_CurrentAttrContainer = this.m_CurrentCLD;

                        // set isolation-level attribute
                        String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
                        if (isDebug) logger.debug("     " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel);
                        /*
                        arminw:
                        only when an isolation-level is set in CLD, set it.
                        Else the CLD use the default iso-level defined in the repository
                        */
                        if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel));

                        // set class attribute
                        String classname = atts.getValue(tags.getTagById(CLASS_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(CLASS_NAME) + ": " + classname);
                        try
                        {
                            m_CurrentCLD.setClassOfObject(ClassHelper.getClass(classname));
                        }
                        catch (ClassNotFoundException e)
                        {
                            m_CurrentCLD = null;
                            throw new MetadataException("Class "+classname+" could not be found"
                                    +" in the classpath. This could cause unexpected behaviour of OJB,"+
                                    " please remove or comment out this class descriptor" +
                                    " in the repository.xml file.", e);
                        }

                        // set schema attribute
                        String schema = atts.getValue(tags.getTagById(SCHEMA_NAME));
                        if (schema != null)
                        {
                            if (isDebug) logger.debug("     " + tags.getTagById(SCHEMA_NAME) + ": " + schema);
                            m_CurrentCLD.setSchema(schema);
                        }

                        // set proxy attribute
                        String proxy = atts.getValue(tags.getTagById(CLASS_PROXY));
                        if (isDebug) logger.debug("     " + tags.getTagById(CLASS_PROXY) + ": " + proxy);
                        if (checkString(proxy))
                        {
                            if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR))
                            {
                                m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR);
                            }
                            else
                            {
                                m_CurrentCLD.setProxyClassName(proxy);
                            }
                        }

                        // set proxyPrefetchingLimit attribute
                        String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
                        if (proxyPrefetchingLimit == null)
                        {
                            m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
                        }
                        else
                        {
                            m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                        }

                        // set table attribute:
                        String table = atts.getValue(tags.getTagById(TABLE_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(TABLE_NAME) + ": " + table);
                        m_CurrentCLD.setTableName(table);
                        if (table == null)
                        {
                            m_CurrentCLD.setIsInterface(true);
                        }

                        // set row-reader attribute
                        String rowreader = atts.getValue(tags.getTagById(ROW_READER));
                        if (isDebug) logger.debug("     " + tags.getTagById(ROW_READER) + ": " + rowreader);
                        if (rowreader != null)
                        {
                            m_CurrentCLD.setRowReader(rowreader);
                        }

                        // set if extends
// arminw: TODO: this feature doesn't work, remove this stuff?
                        String extendsAtt = atts.getValue(tags.getTagById(EXTENDS));
                        if (isDebug) logger.debug("     " + tags.getTagById(EXTENDS) + ": " + extendsAtt);
                        if (checkString(extendsAtt))
                        {
                            m_CurrentCLD.setSuperClass(extendsAtt);
                        }

                        //set accept-locks attribute
                        String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS));
                        if (acceptLocks==null)
                            acceptLocks="true"; // default is true
                        logger.debug("     " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
                        if (isDebug) logger.debug("     " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
                        boolean b = (Boolean.valueOf(acceptLocks)).booleanValue();
                        m_CurrentCLD.setAcceptLocks(b);

                        //set initializationMethod attribute
                        String initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD));
                        if (isDebug) logger.debug("     " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod);
                        if (initializationMethod != null)
                        {
                            m_CurrentCLD.setInitializationMethod(initializationMethod);
                        }

                        // set factoryClass attribute
                        String factoryClass = atts.getValue(tags.getTagById(FACTORY_CLASS));
                        if (isDebug)
                            logger.debug("     " + tags.getTagById(FACTORY_CLASS) + ": " + factoryClass);
                        if (factoryClass != null)
                        {
                            m_CurrentCLD.setFactoryClass(factoryClass);
                        }

                        //set factoryMethod attribute
                        String factoryMethod = atts.getValue(tags.getTagById(FACTORY_METHOD));
                        if (isDebug)
                            logger.debug("     " + tags.getTagById(FACTORY_METHOD) + ": " + factoryMethod);
                        if (factoryMethod != null)
                        {
                            m_CurrentCLD.setFactoryMethod(factoryMethod);
                        }

                        // set refresh attribute
                        String refresh = atts.getValue(tags.getTagById(REFRESH));
                        if (isDebug) logger.debug("     " + tags.getTagById(REFRESH) + ": " + refresh);
                        b = (Boolean.valueOf(refresh)).booleanValue();
                        m_CurrentCLD.setAlwaysRefresh(b);

                        // TODO: remove this or make offical feature
                        // persistent field
						String pfClassName = atts.getValue("persistent-field-class");
						if (isDebug) logger.debug("     persistent-field-class: " + pfClassName);
						m_CurrentCLD.setPersistentFieldClassName(pfClassName);

                        // put cld to the metadata repository
                        m_repository.put(classname, m_CurrentCLD);
                        break;
                    }
                case OBJECT_CACHE:
                    {
                        // we only interessted in object-cache tags declared within
                        // an class-descriptor
                        if(m_CurrentCLD != null)
                        {
                            String className = atts.getValue(tags.getTagById(CLASS_NAME));
                            if(checkString(className))
                            {
                                if (isDebug) logger.debug("     > " + tags.getTagById(OBJECT_CACHE));
                                ObjectCacheDescriptor ocd = new ObjectCacheDescriptor();
                                this.m_CurrentAttrContainer = ocd;
                                ocd.setObjectCache(ClassHelper.getClass(className));
                                if(m_CurrentCLD != null)
                                {
                                    m_CurrentCLD.setObjectCacheDescriptor(ocd);
                                }
                                if (isDebug) logger.debug("     " + tags.getTagById(CLASS_NAME) + ": " + className);
                            }
                        }
                        break;
                    }
                case CLASS_EXTENT:
                    {
                        String classname = atts.getValue("class-ref");
                        if (isDebug) logger.debug("     " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
                        m_CurrentCLD.addExtentClass(classname);
                        break;
                    }

                case FIELD_DESCRIPTOR:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(FIELD_DESCRIPTOR));

                        String strId = atts.getValue(tags.getTagById(ID));
                        m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));

                        String strAccess = atts.getValue(tags.getTagById(ACCESS));

                        if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
                        {
                            m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId);
                        }
                        else
                        {
                            m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
                        }
                        m_CurrentFLD.setAccess(strAccess);
                        m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);

                        // prepare for custom attributes
                        this.m_CurrentAttrContainer = this.m_CurrentFLD;

                        String fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME) + ": " + fieldName);

                        if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
                        {
							AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD;
                            anonymous.setPersistentField(null,fieldName);
                        }
                        else
                        {
                            String classname = m_CurrentCLD.getClassNameOfObject();
							PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName);
                            m_CurrentFLD.setPersistentField(pf);
                        }

                        String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(COLUMN_NAME) + ": " + columnName);
                        m_CurrentFLD.setColumnName(columnName);

                        String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE));
                        if (isDebug) logger.debug("     " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType);
                        m_CurrentFLD.setColumnType(jdbcType);

                        String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY));
                        if (isDebug) logger.debug("     " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey);
                        boolean b = (Boolean.valueOf(primaryKey)).booleanValue();
                        m_CurrentFLD.setPrimaryKey(b);

                        String nullable = atts.getValue(tags.getTagById(NULLABLE));
                        if (nullable != null)
                        {
                            if (isDebug) logger.debug("     " + tags.getTagById(NULLABLE) + ": " + nullable);
                            b = !(Boolean.valueOf(nullable)).booleanValue();
                            m_CurrentFLD.setRequired(b);
                        }

                        String indexed = atts.getValue(tags.getTagById(INDEXED));
                        if (isDebug) logger.debug("     " + tags.getTagById(INDEXED) + ": " + indexed);
                        b = (Boolean.valueOf(indexed)).booleanValue();
                        m_CurrentFLD.setIndexed(b);

                        String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement);
                        b = (Boolean.valueOf(autoincrement)).booleanValue();
                        m_CurrentFLD.setAutoIncrement(b);

                        String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName);
                        m_CurrentFLD.setSequenceName(sequenceName);

                        String locking = atts.getValue(tags.getTagById(LOCKING));
                        if (isDebug) logger.debug("     " + tags.getTagById(LOCKING) + ": " + locking);
                        b = (Boolean.valueOf(locking)).booleanValue();
                        m_CurrentFLD.setLocking(b);

                        String updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK));
                        if (isDebug) logger.debug("     " + tags.getTagById(UPDATE_LOCK) + ": " + updateLock);
                        if(checkString(updateLock))
                        {
                            b = (Boolean.valueOf(updateLock)).booleanValue();
                            m_CurrentFLD.setUpdateLock(b);
                        }

                        String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion);
                        if (fieldConversion != null)
                        {
                            m_CurrentFLD.setFieldConversionClassName(fieldConversion);
                        }

                        // set length attribute
                        String length = atts.getValue(tags.getTagById(LENGTH));
                        if (length != null)
                        {
                            int i = Integer.parseInt(length);
                            if (isDebug) logger.debug("     " + tags.getTagById(LENGTH) + ": " + i);
                            m_CurrentFLD.setLength(i);
                            m_CurrentFLD.setLengthSpecified(true);
                        }

                        // set precision attribute
                        String precision = atts.getValue(tags.getTagById(PRECISION));
                        if (precision != null)
                        {
                            int i = Integer.parseInt(precision);
                            if (isDebug) logger.debug("     " + tags.getTagById(PRECISION) + ": " + i);
                            m_CurrentFLD.setPrecision(i);
                            m_CurrentFLD.setPrecisionSpecified(true);
                        }

                        // set scale attribute
                        String scale = atts.getValue(tags.getTagById(SCALE));
                        if (scale != null)
                        {
                            int i = Integer.parseInt(scale);
                            if (isDebug) logger.debug("     " + tags.getTagById(SCALE) + ": " + i);
                            m_CurrentFLD.setScale(i);
                            m_CurrentFLD.setScaleSpecified(true);
                        }

                        break;
                    }

                case REFERENCE_DESCRIPTOR:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(REFERENCE_DESCRIPTOR));
                        // set name attribute
                        name = atts.getValue(tags.getTagById(FIELD_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME) + ": " + name);

                        // set class-ref attribute
                        String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
                        if (isDebug) logger.debug("     " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef);

                        ObjectReferenceDescriptor ord;
                        if (name.equals(TAG_SUPER))
                        {
                            // no longer needed sine SuperReferenceDescriptor was used
//                            checkThis(classRef);
//                            AnonymousObjectReferenceDescriptor aord =
//                                new AnonymousObjectReferenceDescriptor(m_CurrentCLD);
//                            aord.setPersistentField(null, TAG_SUPER);
//                            ord = aord;

                            ord = new SuperReferenceDescriptor(m_CurrentCLD);
                        }
                        else
                        {
                            ord = new ObjectReferenceDescriptor(m_CurrentCLD);
                            PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name);
                            ord.setPersistentField(pf);
                        }
                        m_CurrentORD = ord;

                        // now we add the new descriptor
                        m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
                        m_CurrentORD.setItemClass(ClassHelper.getClass(classRef));

                        // prepare for custom attributes
                        this.m_CurrentAttrContainer = m_CurrentORD;

                        // set proxy attribute
                        String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
                        boolean b = (Boolean.valueOf(proxy)).booleanValue();
                        m_CurrentORD.setLazy(b);

                        // set proxyPrefetchingLimit attribute
                        String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
                        if (proxyPrefetchingLimit == null)
                        {
                            m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
                        }
                        else
                        {
                            m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                        }

                        // set refresh attribute
                        String refresh = atts.getValue(tags.getTagById(REFRESH));
                        if (isDebug) logger.debug("     " + tags.getTagById(REFRESH) + ": " + refresh);
                        b = (Boolean.valueOf(refresh)).booleanValue();
                        m_CurrentORD.setRefresh(b);

                        // set auto-retrieve attribute
                        String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
                        b = (Boolean.valueOf(autoRetrieve)).booleanValue();
                        m_CurrentORD.setCascadeRetrieve(b);

                        // set auto-update attribute
                        String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
                        if(autoUpdate != null)
                        {
                            m_CurrentORD.setCascadingStore(autoUpdate);
                        }

                        //set auto-delete attribute
                        String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);

                        if(autoDelete != null)
                        {
                            m_CurrentORD.setCascadingDelete(autoDelete);
                        }

                        //set otm-dependent attribute
                        String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT));
                        if (isDebug) logger.debug("     " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent);
                        b = (Boolean.valueOf(otmDependent)).booleanValue();
                        m_CurrentORD.setOtmDependent(b);

                        break;
                    }

                case FOREIGN_KEY:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(FOREIGN_KEY));
                        String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));

                        if (fieldIdRef != null)
                        {
                            if (isDebug) logger.debug("      " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);

                            try
                            {
                                int fieldId;
                                fieldId = Integer.parseInt(fieldIdRef);
                                m_CurrentORD.addForeignKeyField(fieldId);
                            }
                            catch (NumberFormatException rex)
                            {
                                throw new MetadataException(tags.getTagById(FIELD_ID_REF)
                                        + " attribute must be an int. Found: "
                                        + fieldIdRef + ". Please check your repository file.", rex);
                            }
                        }
                        else
                        {
                            String fieldRef = atts.getValue(tags.getTagById(FIELD_REF));
                            if (isDebug) logger.debug("      " + tags.getTagById(FIELD_REF) + ": " + fieldRef);
                            m_CurrentORD.addForeignKeyField(fieldRef);
                        }
                        break;
                    }

                case COLLECTION_DESCRIPTOR:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(COLLECTION_DESCRIPTOR));
                        m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD);


                        // prepare for custom attributes
                        this.m_CurrentAttrContainer = m_CurrentCOD;

                        // set name attribute
                        name = atts.getValue(tags.getTagById(FIELD_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME) + ": " + name);
						PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name);
                        m_CurrentCOD.setPersistentField(pf);

                        // set collection-class attribute
                        String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS));
                        if (collectionClassName != null)
                        {
                            if (isDebug) logger.debug("     " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName);
                            m_CurrentCOD.setCollectionClass(ClassHelper.getClass(collectionClassName));
                        }
                        // set element-class-ref attribute
                        String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
                        if (isDebug) logger.debug("     " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef);
                        if (elementClassRef != null)
                        {
                            m_CurrentCOD.setItemClass(ClassHelper.getClass(elementClassRef));
                        }

                        //set orderby and sort attributes:
                        String orderby = atts.getValue(tags.getTagById(ORDERBY));
                        String sort = atts.getValue(tags.getTagById(SORT));
                        if (isDebug) logger.debug("     " + tags.getTagById(SORT) + ": " + orderby + ", " + sort);
                        if (orderby != null)
                        {
                            m_CurrentCOD.addOrderBy(orderby, "ASC".equalsIgnoreCase(sort));
                        }

                        // set indirection-table attribute
                        String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE));
                        if (isDebug) logger.debug("     " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable);
                        m_CurrentCOD.setIndirectionTable(indirectionTable);

                        // set proxy attribute
                        String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
                        boolean b = (Boolean.valueOf(proxy)).booleanValue();
                        m_CurrentCOD.setLazy(b);

                        // set proxyPrefetchingLimit attribute
                        String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                        if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
                        if (proxyPrefetchingLimit == null)
                        {
                            m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
                        }
                        else
                        {
                            m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                        }

                        // set refresh attribute
                        String refresh = atts.getValue(tags.getTagById(REFRESH));
                        if (isDebug) logger.debug("     " + tags.getTagById(REFRESH) + ": " + refresh);
                        b = (Boolean.valueOf(refresh)).booleanValue();
                        m_CurrentCOD.setRefresh(b);

                        // set auto-retrieve attribute
                        String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
                        b = (Boolean.valueOf(autoRetrieve)).booleanValue();
                        m_CurrentCOD.setCascadeRetrieve(b);

                        // set auto-update attribute
                        String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
                        if(autoUpdate != null)
                        {
                            m_CurrentCOD.setCascadingStore(autoUpdate);
                        }

                        //set auto-delete attribute
                        String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
                        if (isDebug) logger.debug("     " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
                        if(autoDelete != null)
                        {
                            m_CurrentCOD.setCascadingDelete(autoDelete);
                        }

                        //set otm-dependent attribute
                        String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT));
                        if (isDebug) logger.debug("     " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent);
                        b = (Boolean.valueOf(otmDependent)).booleanValue();
                        m_CurrentCOD.setOtmDependent(b);

                        m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);

                        break;
                    }
                case ORDERBY :
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(ORDERBY));
                        name = atts.getValue(tags.getTagById(FIELD_NAME));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_NAME) + ": " + name);
                        String sort = atts.getValue(tags.getTagById(SORT));
                        if (isDebug) logger.debug("     " + tags.getTagById(SORT) + ": " + name + ", " + sort);

                        m_CurrentCOD.addOrderBy(name, "ASC".equalsIgnoreCase(sort));
                        break;
                    }
                case INVERSE_FK:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(INVERSE_FK));
                        String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));

                        if (fieldIdRef != null)
                        {
                            if (isDebug) logger.debug("      " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);

                            try
                            {
                                int fieldId;
                                fieldId = Integer.parseInt(fieldIdRef);
                                m_CurrentCOD.addForeignKeyField(fieldId);
                            }
                            catch (NumberFormatException rex)
                            {
                                throw new MetadataException(tags.getTagById(FIELD_ID_REF)
                                        + " attribute must be an int. Found: "
                                        + fieldIdRef + " Please check your repository file.", rex);
                            }
                        }
                        else
                        {
                            String fieldRef = atts.getValue(tags.getTagById(FIELD_REF));
                            if (isDebug) logger.debug("      " + tags.getTagById(FIELD_REF) + ": " + fieldRef);
                            m_CurrentCOD.addForeignKeyField(fieldRef);
                        }
                        break;
                    }

                case FK_POINTING_TO_THIS_CLASS:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
                        String column = atts.getValue("column");
                        if (isDebug) logger.debug("      " + "column" + ": " + column);
                        m_CurrentCOD.addFkToThisClass(column);
                        break;
                    }

                case FK_POINTING_TO_ITEMS_CLASS:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
                        String column = atts.getValue("column");
                        if (isDebug) logger.debug("      " + "column" + ": " + column);
                        m_CurrentCOD.addFkToItemClass(column);
                        break;
                    }
                case ATTRIBUTE:
                    {
                        //handle custom attributes
                        String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
                        String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
                        // If we have a container to store this attribute in, then do so.
                        if (this.m_CurrentAttrContainer != null)
                        {
                            if (isDebug) logger.debug("      > " + tags.getTagById(ATTRIBUTE));
                            if (isDebug) logger.debug("       " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName);
                            if (isDebug) logger.debug("       " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue);
                            this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue);
                        }
                        else
                        {
//                            logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+
//                                    ") but I can not assign them to a descriptor");
                        }
                        break;
                    }
//                    case SEQUENCE_MANAGER:
//                    {
//                        if (isDebug) logger.debug("    > " + tags.getTagById(SEQUENCE_MANAGER));
//                        // currently it's not possible to specify SM on class-descriptor level
//                        // thus we use a dummy object to prevent ATTRIBUTE container report
//                        // unassigned attributes
//                        this.m_CurrentAttrContainer = new SequenceDescriptor(null);
//                        break;
//                    }
                    case QUERY_CUSTOMIZER:
                        {
                            // set collection-class attribute
                            String className = atts.getValue("class");
                            QueryCustomizer queryCust;

                            if (className != null)
                            {
                                if (isDebug) logger.debug("     " + "class" + ": " + className);
                                queryCust = (QueryCustomizer)ClassHelper.newInstance(className);
                                m_CurrentAttrContainer = queryCust;
                                m_CurrentCOD.setQueryCustomizer(queryCust);
                            }
                            break;
                        }
                    case INDEX_DESCRIPTOR:
                        {
                            m_CurrentIndexDescriptor = new IndexDescriptor();
                            m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME)));
                            m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(atts.getValue(tags.getTagById(UNIQUE))).booleanValue());
                            break;
                        }
                    case INDEX_COLUMN:
                        {
                            m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME)));
                            break;
                        }
                    case INSERT_PROCEDURE:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(INSERT_PROCEDURE));

                        // Get the proc name and the 'include all fields' setting
                        String procName = atts.getValue(tags.getTagById(NAME));
                        String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS));
                        if (isDebug) logger.debug("     " + tags.getTagById(NAME) +
                                                  ": " + procName);
                        if (isDebug) logger.debug("     " + tags.getTagById(INCLUDE_ALL_FIELDS) +
                                                  ": " + includeAllFields);

                        // create the procedure descriptor
                        InsertProcedureDescriptor proc =
                            new InsertProcedureDescriptor(m_CurrentCLD,
                                                          procName,
                                                          Boolean.valueOf(includeAllFields).booleanValue());
                        m_CurrentProcedure = proc;

                        // Get the name of the field ref that will receive the
                        // return value.
                        String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
                        if (isDebug) logger.debug("     " + tags.getTagById(RETURN_FIELD_REF) +
                                                  ": " + returnFieldRefName);
                        proc.setReturnValueFieldRef(returnFieldRefName);

                        break;
                    }
                case UPDATE_PROCEDURE:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(UPDATE_PROCEDURE));

                        // Get the proc name and the 'include all fields' setting
                        String procName = atts.getValue(tags.getTagById(NAME));
                        String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS));
                        if (isDebug) logger.debug("     " + tags.getTagById(NAME) +
                                                  ": " + procName);
                        if (isDebug) logger.debug("     " + tags.getTagById(INCLUDE_ALL_FIELDS) +
                                                  ": " + includeAllFields);

                        // create the procedure descriptor
                        UpdateProcedureDescriptor proc =
                            new UpdateProcedureDescriptor(m_CurrentCLD,
                                                          procName,
                                                          Boolean.valueOf(includeAllFields).booleanValue());
                        m_CurrentProcedure = proc;

                        // Get the name of the field ref that will receive the
                        // return value.
                        String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
                        if (isDebug) logger.debug("     " + tags.getTagById(RETURN_FIELD_REF) +
                                                  ": " + returnFieldRefName);
                        proc.setReturnValueFieldRef(returnFieldRefName);

                        break;
                    }
                case DELETE_PROCEDURE:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(DELETE_PROCEDURE));

                        // Get the proc name and the 'include all fields' setting
                        String procName = atts.getValue(tags.getTagById(NAME));
                        String includeAllPkFields = atts.getValue(tags.getTagById(INCLUDE_PK_FIELDS_ONLY));
                        if (isDebug) logger.debug("     " + tags.getTagById(NAME) +
                                                  ": " + procName);
                        if (isDebug) logger.debug("     " + tags.getTagById(INCLUDE_PK_FIELDS_ONLY) +
                                                  ": " + includeAllPkFields);

                        // create the procedure descriptor
                        DeleteProcedureDescriptor proc =
                            new DeleteProcedureDescriptor(m_CurrentCLD,
                                                          procName,
                                                          Boolean.valueOf(includeAllPkFields).booleanValue());
                        m_CurrentProcedure = proc;

                        // Get the name of the field ref that will receive the
                        // return value.
                        String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
                        if (isDebug) logger.debug("     " + tags.getTagById(RETURN_FIELD_REF) +
                                                  ": " + returnFieldRefName);
                        proc.setReturnValueFieldRef(returnFieldRefName);

                        break;

                    }
                case CONSTANT_ARGUMENT:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(CONSTANT_ARGUMENT));
                        ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure);

                        // Get the value
                        String value = atts.getValue(tags.getTagById(VALUE));
                        if (isDebug) logger.debug("     " + tags.getTagById(VALUE) + ": " + value);

                        // Set the value for the argument
                        arg.setValue(value);

                        // Add the argument to the procedure.
                        m_CurrentProcedure.addArgument(arg);
                        break;
                    }
                case RUNTIME_ARGUMENT:
                    {
                        if (isDebug) logger.debug("    > " + tags.getTagById(RUNTIME_ARGUMENT));
                        ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure);

                        // Get the name of the field ref
                        String fieldRefName = atts.getValue(tags.getTagById(FIELD_REF));
                        if (isDebug) logger.debug("     " + tags.getTagById(FIELD_REF) +
                                                  ": " + fieldRefName);

                        // Get the 'return' value.
                        String returnValue = atts.getValue(tags.getTagById(RETURN));
                        if (isDebug) logger.debug("     " + tags.getTagById(RETURN) +
                                                  ": " + returnValue);

                        // Set the value for the argument.
                        if ((fieldRefName != null) && (fieldRefName.trim().length() != 0)) {
                            arg.setValue(fieldRefName,
                                         Boolean.valueOf(returnValue).booleanValue());
                        }

                        // Add the argument to the procedure.
                        m_CurrentProcedure.addArgument(arg);
                        break;
                    }

                default :
                    {
                        // nop
                    }
            }
        }
        catch (Exception ex)
        {
            logger.error("Exception while read metadata", ex);
            if(ex instanceof MetadataException) throw (MetadataException)ex;
            else throw new MetadataException("Exception when reading metadata information,"+
                    " please check your repository.xml file", ex);
        }
    }
233950
def _start_element (self, tag, attrs, end):
        
        tag = tag.encode(self.encoding, "ignore")
        self.fd.write("<%s" % tag.replace("/", ""))
        for key, val in attrs.items():
            key = key.encode(self.encoding, "ignore")
            if val is None:
                self.fd.write(" %s" % key)
            else:
                val = val.encode(self.encoding, "ignore")
                self.fd.write(' %s="%s"' % (key, quote_attrval(val)))
        self.fd.write(end)
1014819
public void startElement(
          StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
            throws SAXException
  {
    //System.out.println("ProcessorFunction.startElement()");
    String msg = "";
    if (!(handler.getElemTemplateElement() instanceof Stylesheet))
    {
      msg = "func:function element must be top level.";
      handler.error(msg, new SAXException(msg));
    }
    super.startElement(handler, uri, localName, rawName, attributes);
       
    String val = attributes.getValue("name");
    int indexOfColon = val.indexOf(":");
    if (indexOfColon > 0)
    {
      //String prefix = val.substring(0, indexOfColon);
      //String localVal = val.substring(indexOfColon + 1);
      //String ns = handler.getNamespaceSupport().getURI(prefix);
      //if (ns.length() > 0)
      //  System.out.println("fullfuncname " + ns + localVal);
    }
    else
    {
      msg = "func:function name must have namespace";
      handler.error(msg, new SAXException(msg));
    }
  }
980790
@Override
  public void startElement(String namespaceURI, String lName,
      String qName, Attributes attrs) throws SAXException {
    switch (qName) {
      case RULES:
        String languageStr = attrs.getValue("targetLang");
        language = Languages.getLanguageForShortCode(languageStr);
        break;
      case RULE:
        super.startElement(namespaceURI, lName, qName, attrs);
        correctExamples = new ArrayList<>();
        incorrectExamples = new ArrayList<>();
        break;
      case TARGET:
        startPattern(attrs);
        break;
      case SOURCE:
        srcLang = Languages.getLanguageForShortCode(attrs.getValue("lang"));
        break;
      default:
        super.startElement(namespaceURI, lName, qName, attrs);
        break;
    }
  }
128970
def startElement(self, name, attrs):
        
        self.stack.append((self.current, self.chardata))
        self.current = {}
        self.chardata = []
219518
public void setRootElement(java.lang.String rootElement) {
        getStateHelper().put(PropertyKeys.rootElement, rootElement);
        handleAttribute("rootElement", rootElement);
    }
1005022
public XMLWriter startElement(String element) {
        append("<" + element);
        if (rootElement && xmlns != null) {
            append(" xmlns=\"" + xmlns + "\"");
            rootElement = false;
        }
        append(">");
        elementStack.push(element);
        return this;
    }
927169
private void startElementRootNode(final Attributes attributes) {

        LOG.debug("Found rootNode");
        try {
            this.rootNode = this.newNode(null, attributes);
            this.nodeStack.push(this.rootNode);
        } catch (final RepositoryException e) {
            throw new AssertionError("Could not create node", e);
        }
    }
342003
@Override
   public void startElement(String namespaceURI, String localName, String name, Map<String, String> atts)
      throws RepositoryException
   {
      InternalQName elementName = locationFactory.parseJCRName(name).getInternalName();

      if (Constants.SV_NODE_NAME.equals(elementName))
      {
         // sv:node element

         // node name (value of sv:name attribute)
         String svName = getAttribute(atts, Constants.SV_NAME_NAME);
         if (svName == null)
         {
            throw new RepositoryException("Missing mandatory sv:name attribute of element sv:node");
         }
         String svId = getAttribute(atts, Constants.EXO_ID_NAME);
         if (svId == null)
         {
            throw new RepositoryException("Missing mandatory exo:id attribute of element sv:node");
         }

         ImportNodeData newNodeData;
         InternalQName currentNodeName;
         int nodeIndex = 1;
         NodeData parentData = getParent();
         if (!isFirstElementChecked)
         {
            if (!ROOT_NODE_NAME.equals(svName))
            {
               throw new RepositoryException("The first element must be root. But found '" + svName + "'");
            }

            isFirstElementChecked = true;
         }

         if (ROOT_NODE_NAME.equals(svName))
         {
            // remove the wrong root from the stack
            tree.pop();

            newNodeData = addChangesForRootNodeInitialization(parentData);
         }
         else
         {
            currentNodeName = locationFactory.parseJCRName(svName).getInternalName();
            nodeIndex = getNodeIndex(parentData, currentNodeName, null);
            newNodeData = new ImportNodeData(parentData, currentNodeName, nodeIndex);
            newNodeData.setOrderNumber(getNextChildOrderNum(parentData));
            newNodeData.setIdentifier(svId);
            changesLog.add(new ItemState(newNodeData, ItemState.ADDED, true, parentData.getQPath()));
         }
         tree.push(newNodeData);

         mapNodePropertiesInfo.put(newNodeData.getIdentifier(), new NodePropertiesInfo(newNodeData));
      }
      else
      {
         super.startElement(namespaceURI, localName, name, atts);
         if (Constants.SV_PROPERTY_NAME.equals(elementName))
         {
            String svId = getAttribute(atts, Constants.EXO_ID_NAME);
            if (svId == null)
            {
               throw new RepositoryException("Missing mandatory exo:id attribute of element sv:property");
            }
            propertyInfo.setIndentifer(svId);
         }
      }
   }
20762
public void readWriteUpToStartElement(String startTag) throws XMLStreamException {
        boolean startTagIsNext = false;
        while (xmlEventReader.hasNext() && !startTagIsNext) {
            XMLEvent peekedEvent = xmlEventReader.peek();
            switch (peekedEvent.getEventType()) {
                case XMLStreamConstants.START_ELEMENT:
                    String elementName = peekedEvent.asStartElement().getName().getLocalPart();
                    if (elementName.equals(startTag)) {
                        startTagIsNext = true;
                    } else {
                        XMLEvent readEvent = xmlEventReader.nextEvent();
                        add(readEvent);
                    }
                    break;
                default:
                    XMLEvent readEvent = xmlEventReader.nextEvent();
                    add(readEvent);
                    break;
            }
        }
    }
30252
function getStartToken(elementNode) {
                if (!elementNode) {
                    return null
                }
                if (elementNode.type !== "HTMLElement") {
                    return null
                }
                if (isDummyElement(elementNode)) {
                    return null
                }
                return elementNode.startTag || elementNode
            }