 import mx.rpc.xml.SchemaDatatypes;
 import mx.rpc.xml.TypeIterator;
 import mx.rpc.xml.XMLDecoder;
-import mx.utils.ObjectProxy;
-import mx.utils.object_proxy;
 import mx.utils.StringUtil;
 import mx.utils.XMLUtil;
+import mx.utils.object_proxy;
 
 use namespace object_proxy;
 

     */
    private function resolveReferences(root:XML, cleanupElementsWithIdCache:Boolean=true):void
    {
        if (_referencesResolved) return;
        
        var index:uint = 0;
        if (_elementsWithId == null)
            _elementsWithId = document..*.(attribute("id").length() > 0);
    
        // Note that we must consider all child nodes here, not just elements
        // as we need the accurate index in terms of child XML nodes to replace
        // a node with the referent.

        {
            if (child.nodeKind() == "element")
            {
                var href:String = getAttributeFromNode("href", child);
                if (href != null)
                {
                    var hashPosition:int = href.indexOf("#");
                    if (hashPosition >= 0)
                        href = href.substring(hashPosition + 1);

                    // Find the first element with a matching id attribute 
                    var matches:XMLList = _elementsWithId.(@id == href);
                    var referent:XML;

                    if (matches.length() > 0)
                        referent = matches[0];
                    else
                        throw new Error("The element referenced by id '" + href + "' was not found.");

                    referent.setName(child.name());

                    if (referent.hasComplexContent())
                        resolveReferences(referent, false);

                    // Replace the reference with the referent
                    root.replace(index, referent);

                    // Then remove the id attribute from replaced value
                    referent = root.child(index)[0];
                    delete referent.@id;
                }
                else if (child.hasComplexContent())
                {
                    resolveReferences(child, false);
                }
            }

            index++;
        }

        if (cleanupElementsWithIdCache)
        {
            _elementsWithId = null;
