helma.objectmodel.INode worknode = node.getNode( helmaKey, false ); if ( worknode==null ) {  worknode = helmaNode.createNode( helmaKey );
INode worknode = null; if ("_children".equals (helmaKey)) { worknode = node; } else { node.getNode( helmaKey, false ); if ( worknode==null ) {  worknode = helmaNode.createNode( helmaKey ); }
    private INode children( Element element, helma.objectmodel.INode helmaNode, Map nodeCache ) {	NodeList list = element.getChildNodes();	int len = list.getLength();	boolean nodeHasPrototype = helmaNode.getPrototype() != null;	StringBuffer textcontent = new StringBuffer();	String domKey, helmaKey;	for ( int i=0; i<len; i++ ) {	    // loop through the list of children	    org.w3c.dom.Node childNode = list.item(i);	    // if the current node hasn't been initialized yet, try if it can 	    // be initialized and converted from one of the child elements.	    if (!nodeHasPrototype) {	        if (childNode.getNodeType() == Node.ELEMENT_NODE) {	            convert ((Element) childNode, helmaNode, nodeCache);	            if (helmaNode.getPrototype() != null)	                return helmaNode;	        }	        continue;	    }	    // if it's text content of this element -> append to StringBuffer	    if ( childNode.getNodeType() == Node.TEXT_NODE ||	         childNode.getNodeType() == Node.CDATA_SECTION_NODE ) {	        textcontent.append( childNode.getNodeValue().trim() );	        continue;	    }	    // it's some kind of element (property or child)	    if ( childNode.getNodeType() == Node.ELEMENT_NODE ) {	        Element childElement = (Element)childNode;	        // get the basic key we have to look for in the properties-table	        domKey = element.getNodeName()+"."+childElement.getNodeName();	        // is there a childtext-2-property mapping?	        if ( props!=null && props.containsKey(domKey+"._text") ) {	            helmaKey = props.getProperty(domKey+"._text");	            if( helmaKey.equals("") )	                // if property is set but without value, read elementname for this mapping	                helmaKey = childElement.getNodeName().replace(':',defaultSeparator);	            if (DEBUG)	                debug("childtext-2-property mapping, helmaKey " + helmaKey + " for domKey " + domKey );	            // check if helmaKey contains an explicit prototype name in which to	            // set the property.	            int dot = helmaKey.indexOf(".");	            if (dot > -1) {	                String prototype = helmaKey.substring (0, dot);	                INode node = (INode) nodeCache.get (prototype);	                if (node != null)	                    node.setString (helmaKey.substring (dot+1), XmlUtil.getTextContent (childNode));	            }	            if ( helmaNode.getPrototype() != null && helmaNode.getString(helmaKey,false)==null ) {	                helmaNode.setString( helmaKey, XmlUtil.getTextContent(childNode) );	                if (DEBUG)	                    debug("childtext-2-property mapping, setting " + helmaKey + " as string" );	            }	            continue;	        }	        // is there a simple child-2-property mapping?	        // (lets the user define to use only one element and make this a property	        // and simply ignore other elements of the same name)	        if ( props!=null && props.containsKey(domKey+"._property") ) {	            helmaKey = props.getProperty(domKey+"._property");	            // if property is set but without value, read elementname for this mapping:	            if ( helmaKey.equals("") )	                helmaKey = childElement.getNodeName().replace(':',defaultSeparator);	            if (DEBUG)	                debug("child-2-property mapping, helmaKey " + helmaKey + " for domKey " + domKey);	            // get the node on which to opererate, depending on the helmaKey	            // value from the properties file.	            INode node = helmaNode;	            int dot = helmaKey.indexOf(".");	            if (dot > -1) {	                String prototype = helmaKey.substring (0, dot);	                if (!prototype.equalsIgnoreCase (node.getPrototype()))	                    node = (INode) nodeCache.get (prototype);	                helmaKey = helmaKey.substring (dot+1);	            }	            if (node == null)	                continue;	            if ( node.getNode(helmaKey,false)==null ) {	                convert( childElement, node.createNode(helmaKey), nodeCache );	                if (DEBUG)	                    debug( "read " + childElement.toString() + node.getNode(helmaKey,false).toString() );	            }	            continue;	        }	        // map it to one of the children-lists	        helma.objectmodel.INode newHelmaNode = null;	        String childrenMapping = props.getProperty(element.getNodeName()+"._children");	        // do we need a mapping directly among _children of helmaNode?	        // can either be through property elname._children=_all or elname._children=childname	        if( childrenMapping!=null && ( childrenMapping.equals("_all") || childrenMapping.equals(childElement.getNodeName()) ) ) {	            newHelmaNode = convert(childElement, helmaNode.createNode(null), nodeCache );	        }	        // in which virtual subnode collection should objects of this type be stored?	        helmaKey = props.getProperty(domKey);	        if ( helmaKey==null && !sparse ) {	            helmaKey = childElement.getNodeName().replace(':',defaultSeparator);	        }	        // get the node on which to opererate, depending on the helmaKey	        // value from the properties file.	        INode node = helmaNode;	        int dot = helmaKey.indexOf(".");	        if (dot > -1) {	            String prototype = helmaKey.substring (0, dot);	            if (!prototype.equalsIgnoreCase (node.getPrototype()))	                node = (INode) nodeCache.get (prototype);	            helmaKey = helmaKey.substring (dot+1);	        }	        if (node == null)	            continue;	        // try to get the virtual node	        helma.objectmodel.INode worknode = node.getNode( helmaKey, false );	        if ( worknode==null ) {	            // if virtual node doesn't exist, create it	            worknode = helmaNode.createNode( helmaKey );	        }	        if (DEBUG)	            debug( "mounting child "+ childElement.getNodeName() + " at worknode " + worknode.toString() );	        // now mount it, possibly re-using the helmaNode that's been created before	        if ( newHelmaNode!=null ) {	            worknode.addNode(newHelmaNode);	        } else {	            convert( childElement, worknode.createNode( null ), nodeCache );	        }	    }	    // forget about other types (comments etc)	    continue;	}	// if there's some text content for this element, map it:	if ( textcontent.length()>0 ) {	    helmaKey = props.getProperty(element.getNodeName()+"._text");	    if ( helmaKey==null )	        helmaKey = "text";	    if (DEBUG)	        debug ("setting text "+textcontent+" to property "+helmaKey+" of object "+helmaNode);	    helmaNode.setString(helmaKey, textcontent.toString().trim() );	}	return helmaNode;    }