home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Darbas / kidoz_v1.air / kidoz.swf / scripts / mx / rpc / xml / XMLDecoder.as < prev    next >
Encoding:
Text File  |  2009-05-06  |  61.6 KB  |  1,839 lines

  1. package mx.rpc.xml
  2. {
  3.    import flash.utils.ByteArray;
  4.    import flash.utils.getQualifiedClassName;
  5.    import mx.collections.ArrayCollection;
  6.    import mx.logging.ILogger;
  7.    import mx.logging.Log;
  8.    import mx.utils.DescribeTypeCache;
  9.    import mx.utils.ObjectProxy;
  10.    import mx.utils.URLUtil;
  11.    import mx.utils.XMLUtil;
  12.    import mx.utils.object_proxy;
  13.    
  14.    public class XMLDecoder extends SchemaProcessor implements IXMLDecoder
  15.    {
  16.       public static var listClass:Class = ArrayCollection;
  17.       
  18.       private var _recordXSIType:Boolean;
  19.       
  20.       protected var document:XML;
  21.       
  22.       private var log:ILogger;
  23.       
  24.       private var _makeObjectsBindable:Boolean;
  25.       
  26.       private var _typeRegistry:SchemaTypeRegistry;
  27.       
  28.       public function XMLDecoder()
  29.       {
  30.          super();
  31.          log = Log.getLogger("mx.rpc.xml.XMLDecoder");
  32.          typeRegistry = SchemaTypeRegistry.getInstance();
  33.       }
  34.       
  35.       public function createIterableValue(param1:Object = null) : *
  36.       {
  37.          var value:* = undefined;
  38.          var c:Class = null;
  39.          var type:Object = param1;
  40.          try
  41.          {
  42.             if(type != null)
  43.             {
  44.                c = typeRegistry.getCollectionClass(type);
  45.                if(c != null)
  46.                {
  47.                   value = new c();
  48.                }
  49.             }
  50.          }
  51.          catch(e1:Error)
  52.          {
  53.             log.debug("Error while resolving custom collection type for \'{0}\'.\nError: \'{1}\'.",type,e1);
  54.          }
  55.          try
  56.          {
  57.             if(value == null)
  58.             {
  59.                if(makeObjectsBindable)
  60.                {
  61.                   value = new listClass();
  62.                }
  63.                else
  64.                {
  65.                   value = [];
  66.                }
  67.             }
  68.          }
  69.          catch(e2:Error)
  70.          {
  71.             log.warn("Unable to create instance of \'{0}\'.",listClass);
  72.          }
  73.          return value;
  74.       }
  75.       
  76.       public function get makeObjectsBindable() : Boolean
  77.       {
  78.          return _makeObjectsBindable;
  79.       }
  80.       
  81.       public function decodeAnyElement(param1:XML, param2:*, param3:QName, param4:XMLList, param5:DecodingContext = null, param6:Boolean = true) : Boolean
  82.       {
  83.          var _loc7_:Array = null;
  84.          var _loc9_:String = null;
  85.          var _loc13_:XML = null;
  86.          var _loc14_:String = null;
  87.          var _loc15_:String = null;
  88.          var _loc16_:QName = null;
  89.          var _loc17_:* = undefined;
  90.          var _loc18_:* = undefined;
  91.          if(param5 == null)
  92.          {
  93.             param5 = new DecodingContext();
  94.          }
  95.          var _loc8_:Boolean = true;
  96.          var _loc10_:uint = getMaxOccurs(param1);
  97.          var _loc11_:uint = getMinOccurs(param1);
  98.          if(param1 != null)
  99.          {
  100.             _loc14_ = param1["processContents"];
  101.             _loc15_ = param1["namespace"];
  102.             if(_loc15_ != "" && _loc15_ != "##any")
  103.             {
  104.                if(schemaManager.currentSchema != null && schemaManager.currentSchema.targetNamespace != null)
  105.                {
  106.                   _loc9_ = schemaManager.currentSchema.targetNamespace.uri;
  107.                }
  108.                if(_loc15_ == "##other")
  109.                {
  110.                   _loc8_ = false;
  111.                }
  112.                else
  113.                {
  114.                   if(_loc15_.indexOf("##targetNamespace") >= 0)
  115.                   {
  116.                      _loc15_ = _loc15_.replace("##targetNamespace",_loc9_);
  117.                   }
  118.                   _loc7_ = _loc15_.split(" ");
  119.                }
  120.             }
  121.          }
  122.          var _loc12_:XMLList = getApplicableValues(param2,param4,null,param5,_loc10_);
  123.          for each(_loc13_ in _loc12_)
  124.          {
  125.             _loc16_ = _loc13_.name() as QName;
  126.             if(!_loc8_ && URLUtil.urisEqual(_loc16_.uri,_loc9_))
  127.             {
  128.                break;
  129.             }
  130.             if(includeNamespace(_loc16_.uri,_loc7_))
  131.             {
  132.                if(_loc14_ == "skip")
  133.                {
  134.                   _loc18_ = _loc13_.toXMLString();
  135.                }
  136.                else
  137.                {
  138.                   _loc18_ = _loc13_;
  139.                }
  140.                decodeAnyType(param2,_loc16_,new XMLList(_loc18_));
  141.                if(param5.anyIndex < 0)
  142.                {
  143.                   param5.anyIndex = param5.index + 0;
  144.                }
  145.                ++param5.index;
  146.             }
  147.          }
  148.          return true;
  149.       }
  150.       
  151.       public function decodeComplexRestriction(param1:XML, param2:*, param3:QName, param4:*) : void
  152.       {
  153.          var _loc9_:XML = null;
  154.          var _loc5_:String = getAttributeFromNode("base",param1);
  155.          if(_loc5_ == null)
  156.          {
  157.             throw new Error("A complexContent restriction must declare a base type.");
  158.          }
  159.          var _loc6_:QName = schemaManager.getQNameForPrefixedName(_loc5_,param1);
  160.          var _loc7_:XMLList = param1.elements();
  161.          var _loc8_:XMLList = new XMLList();
  162.          if(param4 is XML)
  163.          {
  164.             _loc8_ = (param4 as XML).elements();
  165.          }
  166.          else if(param4 is XMLList)
  167.          {
  168.             _loc8_ = param4;
  169.          }
  170.          for each(_loc9_ in _loc7_)
  171.          {
  172.             if(_loc9_.name() == constants.sequenceQName)
  173.             {
  174.                decodeSequence(_loc9_,param2,param3,_loc8_);
  175.             }
  176.             else if(_loc9_.name() == constants.groupQName)
  177.             {
  178.                decodeGroupReference(_loc9_,param2,param3,_loc8_);
  179.             }
  180.             else if(_loc9_.name() == constants.allQName)
  181.             {
  182.                decodeAll(_loc9_,param2,param3,_loc8_);
  183.             }
  184.             else if(_loc9_.name() == constants.choiceQName)
  185.             {
  186.                decodeChoice(_loc9_,param2,param3,_loc8_);
  187.             }
  188.             else if(_loc9_.name() == constants.attributeQName)
  189.             {
  190.                decodeAttribute(_loc9_,param2,param4);
  191.             }
  192.             else if(_loc9_.name() == constants.attributeGroupQName)
  193.             {
  194.                decodeAttributeGroup(_loc9_,param2,param4);
  195.             }
  196.             else if(_loc9_.name() == constants.anyAttributeQName)
  197.             {
  198.                decodeAnyAttribute(_loc9_,param2,param4);
  199.             }
  200.          }
  201.       }
  202.       
  203.       public function decodeGroupElement(param1:XML, param2:*, param3:XMLList, param4:DecodingContext = null, param5:Boolean = true, param6:Boolean = true) : Boolean
  204.       {
  205.          var _loc9_:QName = null;
  206.          var _loc13_:* = undefined;
  207.          var _loc14_:String = null;
  208.          var _loc15_:QName = null;
  209.          var _loc16_:* = undefined;
  210.          var _loc17_:uint = 0;
  211.          var _loc18_:XML = null;
  212.          if(param4 == null)
  213.          {
  214.             param4 = new DecodingContext();
  215.          }
  216.          var _loc7_:uint = getMaxOccurs(param1);
  217.          var _loc8_:uint = getMinOccurs(param1);
  218.          if(_loc7_ == 0)
  219.          {
  220.             return true;
  221.          }
  222.          if(param1.attribute("ref").length() == 1)
  223.          {
  224.             _loc9_ = schemaManager.getQNameForPrefixedName(param1.@ref,param1,true);
  225.             param1 = schemaManager.getNamedDefinition(_loc9_,constants.elementTypeQName);
  226.             if(param1 == null)
  227.             {
  228.                throw new Error("Cannot resolve element definition for ref \'" + _loc9_ + "\'");
  229.             }
  230.          }
  231.          var _loc10_:String = param1.@name.toString();
  232.          var _loc11_:QName = schemaManager.getQNameForElement(_loc10_,getAttributeFromNode("form",param1));
  233.          var _loc12_:XMLList = getApplicableValues(param2,param3,_loc11_,param4,_loc7_);
  234.          if(_loc12_.length() == 1 && isXSINil(_loc12_[0]))
  235.          {
  236.             setValue(param2,_loc11_,null);
  237.             ++param4.index;
  238.             if(_loc9_ != null)
  239.             {
  240.                schemaManager.releaseScope();
  241.             }
  242.             return true;
  243.          }
  244.          if(_loc7_ > 1)
  245.          {
  246.             _loc14_ = getAttributeFromNode("type",param1);
  247.             if(_loc14_ != null)
  248.             {
  249.                _loc15_ = schemaManager.getQNameForPrefixedName(_loc14_,param1);
  250.             }
  251.             _loc16_ = createIterableValue(_loc15_);
  252.             if(param6)
  253.             {
  254.                setValue(param2,_loc11_,_loc16_,_loc15_);
  255.             }
  256.             else if(!(param2 is ContentProxy && param2.object_proxy::content != undefined))
  257.             {
  258.                setValue(param2,null,_loc16_,_loc15_);
  259.             }
  260.          }
  261.          if(_loc12_.length() == 0)
  262.          {
  263.             if(_loc9_ != null)
  264.             {
  265.                schemaManager.releaseScope();
  266.             }
  267.             if(_loc8_ == 0)
  268.             {
  269.                return true;
  270.             }
  271.             return false;
  272.          }
  273.          if(_loc7_ == 1)
  274.          {
  275.             _loc13_ = decodeElementTopLevel(param1,_loc11_,parseValue(_loc11_,_loc12_));
  276.             setValue(param2,_loc11_,_loc13_);
  277.             ++param4.index;
  278.          }
  279.          else if(_loc7_ > 1)
  280.          {
  281.             if(_loc12_.length() < _loc8_)
  282.             {
  283.                if(_loc9_ != null)
  284.                {
  285.                   schemaManager.releaseScope();
  286.                }
  287.                if(strictOccurenceBounds)
  288.                {
  289.                   throw new Error("Value supplied for element \'" + _loc11_ + "\' occurs " + _loc12_.length() + " times which falls short of minOccurs " + _loc8_ + ".");
  290.                }
  291.                return false;
  292.             }
  293.             if(_loc12_.length() > _loc7_)
  294.             {
  295.                if(_loc9_ != null)
  296.                {
  297.                   schemaManager.releaseScope();
  298.                }
  299.                if(strictOccurenceBounds)
  300.                {
  301.                   throw new Error("Value supplied for element of type \'" + _loc11_ + "\' occurs " + _loc12_.length() + " times which exceeds maxOccurs " + _loc7_ + ".");
  302.                }
  303.                return false;
  304.             }
  305.             _loc17_ = 0;
  306.             while(_loc17_ < _loc7_ && _loc17_ < _loc12_.length())
  307.             {
  308.                _loc18_ = _loc12_[_loc17_];
  309.                _loc13_ = decodeElementTopLevel(param1,_loc11_,_loc18_);
  310.                setValue(param2,_loc11_,_loc13_);
  311.                ++param4.index;
  312.                _loc17_++;
  313.             }
  314.          }
  315.          if(_loc9_ != null)
  316.          {
  317.             schemaManager.releaseScope();
  318.          }
  319.          return true;
  320.       }
  321.       
  322.       public function decodeElementTopLevel(param1:XML, param2:QName, param3:*) : *
  323.       {
  324.          var _loc4_:* = undefined;
  325.          var _loc8_:* = undefined;
  326.          var _loc10_:QName = null;
  327.          var _loc11_:XML = null;
  328.          var _loc12_:QName = null;
  329.          var _loc5_:Boolean = param1.@nillable.toString() == "true" ? true : false;
  330.          if((_loc5_) && param3 == null)
  331.          {
  332.             return param3;
  333.          }
  334.          var _loc6_:String = getAttributeFromNode("fixed",param1);
  335.          if(_loc6_ != null)
  336.          {
  337.             param3 = _loc6_;
  338.          }
  339.          var _loc7_:String = getAttributeFromNode("default",param1);
  340.          if(!_loc5_ && param3 == null)
  341.          {
  342.             param3 = _loc7_;
  343.          }
  344.          if(param3 == null)
  345.          {
  346.             return param3;
  347.          }
  348.          var _loc9_:String = getAttributeFromNode("type",param1);
  349.          if(_loc9_ != null)
  350.          {
  351.             _loc10_ = schemaManager.getQNameForPrefixedName(_loc9_,param1);
  352.             _loc4_ = createContent(_loc10_);
  353.             decodeType(_loc10_,_loc4_,param2,param3);
  354.             return _loc4_;
  355.          }
  356.          if(param1.hasComplexContent())
  357.          {
  358.             _loc11_ = getSingleElementFromNode(param1,constants.complexTypeQName,constants.simpleTypeQName);
  359.             _loc4_ = createContent();
  360.             if(_loc11_.name() == constants.complexTypeQName)
  361.             {
  362.                decodeComplexType(_loc11_,_loc4_,param2,param3);
  363.             }
  364.             else if(_loc11_.name() == constants.simpleTypeQName)
  365.             {
  366.                decodeSimpleType(_loc11_,_loc4_,param2,param3);
  367.             }
  368.             return _loc4_;
  369.          }
  370.          if(_loc6_ != null || _loc7_ != null)
  371.          {
  372.             _loc12_ = schemaManager.schemaDatatypes.stringQName;
  373.          }
  374.          else
  375.          {
  376.             _loc12_ = constants.anyTypeQName;
  377.          }
  378.          _loc4_ = createContent(_loc12_);
  379.          decodeType(_loc12_,_loc4_,param2,param3);
  380.          return _loc4_;
  381.       }
  382.       
  383.       protected function parseValue(param1:*, param2:XMLList) : *
  384.       {
  385.          var _loc3_:* = param2;
  386.          if(param2.hasSimpleContent())
  387.          {
  388.             if(isXSINil(param2))
  389.             {
  390.                _loc3_ = null;
  391.             }
  392.             else
  393.             {
  394.                _loc3_ = param2.toString();
  395.             }
  396.          }
  397.          else if(param2.length() == 1)
  398.          {
  399.             _loc3_ = param2[0];
  400.          }
  401.          return _loc3_;
  402.       }
  403.       
  404.       protected function includeNamespace(param1:String, param2:Array = null) : Boolean
  405.       {
  406.          var _loc3_:Boolean = false;
  407.          var _loc4_:String = null;
  408.          if(param2 != null)
  409.          {
  410.             _loc3_ = false;
  411.             for each(_loc4_ in param2)
  412.             {
  413.                if(_loc4_ == "##local" && param1 == null)
  414.                {
  415.                   return true;
  416.                }
  417.                if(URLUtil.urisEqual(param1,_loc4_))
  418.                {
  419.                   return true;
  420.                }
  421.             }
  422.             return false;
  423.          }
  424.          return true;
  425.       }
  426.       
  427.       public function get typeRegistry() : SchemaTypeRegistry
  428.       {
  429.          return _typeRegistry;
  430.       }
  431.       
  432.       public function decodeSimpleContent(param1:XML, param2:*, param3:QName, param4:*, param5:XML = null) : void
  433.       {
  434.          var _loc7_:String = null;
  435.          var _loc8_:QName = null;
  436.          var _loc9_:* = undefined;
  437.          var _loc10_:XML = null;
  438.          var _loc11_:XMLList = null;
  439.          var _loc12_:XML = null;
  440.          var _loc13_:* = undefined;
  441.          var _loc6_:XML = getSingleElementFromNode(param1,constants.extensionQName,constants.restrictionQName);
  442.          if(param2 is ContentProxy)
  443.          {
  444.             ContentProxy(param2).object_proxy::isSimple = true;
  445.          }
  446.          if(_loc6_ != null)
  447.          {
  448.             _loc7_ = getAttributeFromNode("base",_loc6_);
  449.             if(_loc7_ == null)
  450.             {
  451.                throw new Error("A simpleContent extension or restriction must declare a base type.");
  452.             }
  453.             _loc8_ = schemaManager.getQNameForPrefixedName(_loc7_,_loc6_);
  454.             if(!isBuiltInType(_loc8_))
  455.             {
  456.                _loc10_ = schemaManager.getNamedDefinition(_loc8_,constants.complexTypeQName,constants.simpleTypeQName);
  457.                if(_loc10_ == null)
  458.                {
  459.                   throw new Error("Cannot find base type definition \'" + _loc8_ + "\'");
  460.                }
  461.                schemaManager.releaseScope();
  462.             }
  463.             if(_loc6_.name() == constants.extensionQName)
  464.             {
  465.                if(isBuiltInType(_loc8_))
  466.                {
  467.                   _loc9_ = getSimpleValue(param4,param3);
  468.                   _loc13_ = marshallBuiltInType(_loc8_,param2,param3,_loc9_,param5);
  469.                   setSimpleValue(param2,param3,_loc13_,_loc8_);
  470.                }
  471.                else
  472.                {
  473.                   decodeType(_loc8_,param2,param3,param4,param5);
  474.                }
  475.                _loc11_ = _loc6_.elements();
  476.                for each(_loc12_ in _loc11_)
  477.                {
  478.                   if(_loc12_.name() == constants.attributeQName)
  479.                   {
  480.                      decodeAttribute(_loc12_,param2,param4,param5);
  481.                   }
  482.                   else if(_loc12_.name() == constants.attributeGroupQName)
  483.                   {
  484.                      decodeAttributeGroup(_loc12_,param2,param4,param5);
  485.                   }
  486.                   else if(_loc12_.name() == constants.anyAttributeQName)
  487.                   {
  488.                      decodeAnyAttribute(_loc12_,param2,param4,param5);
  489.                   }
  490.                }
  491.             }
  492.             else if(_loc6_.name() == constants.restrictionQName)
  493.             {
  494.                _loc9_ = getSimpleValue(param4,param3);
  495.                decodeSimpleRestriction(_loc6_,param2,param3,_loc9_);
  496.             }
  497.          }
  498.       }
  499.       
  500.       public function decodeGroupReference(param1:XML, param2:*, param3:QName, param4:XMLList, param5:DecodingContext = null, param6:Boolean = true) : Boolean
  501.       {
  502.          var _loc7_:QName = null;
  503.          var _loc10_:XML = null;
  504.          if(param1.attribute("ref").length() == 1)
  505.          {
  506.             _loc7_ = schemaManager.getQNameForPrefixedName(param1.@ref,param1,true);
  507.             param1 = schemaManager.getNamedDefinition(_loc7_,constants.groupQName);
  508.             if(param1 == null)
  509.             {
  510.                throw new Error("Cannot resolve group definition for \'" + _loc7_ + "\'");
  511.             }
  512.             var _loc8_:XMLList = param1.elements();
  513.             var _loc9_:Boolean = false;
  514.             for each(_loc10_ in _loc8_)
  515.             {
  516.                if(_loc10_.name() == constants.allQName)
  517.                {
  518.                   _loc9_ = decodeAll(_loc10_,param2,param3,param4,param5,param6);
  519.                }
  520.                else if(_loc10_.name() == constants.choiceQName)
  521.                {
  522.                   _loc9_ = decodeChoice(_loc10_,param2,param3,param4,param5,param6);
  523.                }
  524.                else if(_loc10_.name() == constants.sequenceQName)
  525.                {
  526.                   _loc9_ = decodeSequence(_loc10_,param2,param3,param4,param5,param6);
  527.                }
  528.             }
  529.             schemaManager.releaseScope();
  530.             return _loc9_;
  531.          }
  532.          throw new Error("A group reference element must have the ref attribute.");
  533.       }
  534.       
  535.       public function setSimpleValue(param1:*, param2:*, param3:*, param4:Object = null) : void
  536.       {
  537.          var _loc5_:ContentProxy = null;
  538.          if(param1 is ContentProxy)
  539.          {
  540.             _loc5_ = param1 as ContentProxy;
  541.             if(_loc5_.object_proxy::isSimple)
  542.             {
  543.                _loc5_.object_proxy::content = param3;
  544.                return;
  545.             }
  546.          }
  547.          setValue(param1,param2,param3,param4);
  548.       }
  549.       
  550.       public function decodeAnyAttribute(param1:XML, param2:*, param3:* = undefined, param4:XML = null) : void
  551.       {
  552.          var _loc5_:XML = null;
  553.          var _loc6_:Array = null;
  554.          var _loc7_:Boolean = false;
  555.          var _loc8_:String = null;
  556.          var _loc9_:String = null;
  557.          var _loc10_:XMLList = null;
  558.          var _loc11_:XML = null;
  559.          var _loc12_:QName = null;
  560.          var _loc13_:* = undefined;
  561.          if(param3 !== undefined && param3 is XML)
  562.          {
  563.             _loc5_ = param3 as XML;
  564.             _loc7_ = true;
  565.             _loc9_ = param1["namespace"];
  566.             if(_loc9_ != "" && _loc9_ != "##any")
  567.             {
  568.                if(schemaManager.currentSchema != null && schemaManager.currentSchema.targetNamespace != null)
  569.                {
  570.                   _loc8_ = schemaManager.currentSchema.targetNamespace.uri;
  571.                }
  572.                if(_loc9_ == "##other")
  573.                {
  574.                   _loc7_ = false;
  575.                }
  576.                else
  577.                {
  578.                   if(_loc9_.indexOf("##targetNamespace") >= 0)
  579.                   {
  580.                      _loc9_ = _loc9_.replace("##targetNamespace",_loc8_);
  581.                   }
  582.                   _loc6_ = _loc9_.split(" ");
  583.                }
  584.             }
  585.             _loc10_ = _loc5_.attributes();
  586.             for each(_loc11_ in _loc10_)
  587.             {
  588.                _loc12_ = _loc11_.name() as QName;
  589.                if(!(!_loc7_ && URLUtil.urisEqual(_loc12_.uri,_loc8_)))
  590.                {
  591.                   if(includeNamespace(_loc12_.uri,_loc6_))
  592.                   {
  593.                      _loc13_ = getAttribute(param3,_loc12_);
  594.                      if(_loc13_ != null)
  595.                      {
  596.                         setAttribute(param2,_loc12_,_loc13_);
  597.                      }
  598.                   }
  599.                }
  600.             }
  601.          }
  602.       }
  603.       
  604.       public function decodeSimpleType(param1:XML, param2:*, param3:QName, param4:*, param5:XML = null) : void
  605.       {
  606.          var _loc6_:XML = getSingleElementFromNode(param1,constants.restrictionQName,constants.listQName,constants.unionQName);
  607.          if(_loc6_.name() == constants.restrictionQName)
  608.          {
  609.             decodeSimpleRestriction(_loc6_,param2,param3,param4);
  610.          }
  611.          else if(_loc6_.name() == constants.listQName)
  612.          {
  613.             decodeSimpleList(_loc6_,param2,param3,param4,param5);
  614.          }
  615.          else if(_loc6_.name() == constants.listQName)
  616.          {
  617.             decodeSimpleUnion(_loc6_,param2,param3,param4,param5);
  618.          }
  619.       }
  620.       
  621.       public function hasAttribute(param1:*, param2:*) : Boolean
  622.       {
  623.          return getAttribute(param1,param2) !== undefined;
  624.       }
  625.       
  626.       public function getProperties(param1:*) : Array
  627.       {
  628.          var _loc3_:XMLList = null;
  629.          var _loc4_:XML = null;
  630.          var _loc2_:Array = [];
  631.          if(param1 is XML)
  632.          {
  633.             _loc3_ = XML(param1).elements();
  634.          }
  635.          else if(param1 is XMLList)
  636.          {
  637.             _loc3_ = XMLList(param1).elements();
  638.          }
  639.          if(_loc3_ != null)
  640.          {
  641.             for each(_loc4_ in _loc3_)
  642.             {
  643.                _loc2_.push(_loc4_.name());
  644.             }
  645.          }
  646.          return _loc2_;
  647.       }
  648.       
  649.       protected function preProcessXML(param1:XML) : void
  650.       {
  651.       }
  652.       
  653.       protected function isXSINil(param1:*) : Boolean
  654.       {
  655.          var _loc2_:String = null;
  656.          if(param1 != null)
  657.          {
  658.             _loc2_ = "false";
  659.             if(param1 is XML)
  660.             {
  661.                _loc2_ = XML(param1).attribute(constants.nilQName).toString();
  662.             }
  663.             else if(param1 is XMLList)
  664.             {
  665.                _loc2_ = XMLList(param1).attribute(constants.nilQName).toString();
  666.             }
  667.             if(_loc2_ == "true")
  668.             {
  669.                return true;
  670.             }
  671.          }
  672.          return false;
  673.       }
  674.       
  675.       public function set typeRegistry(param1:SchemaTypeRegistry) : void
  676.       {
  677.          _typeRegistry = param1;
  678.       }
  679.       
  680.       public function marshallBuiltInType(param1:QName, param2:*, param3:QName, param4:*, param5:XML = null) : *
  681.       {
  682.          var _loc6_:* = undefined;
  683.          var _loc7_:XMLList = null;
  684.          if(param1 == constants.anyTypeQName && !isSimpleValue(param4))
  685.          {
  686.             _loc6_ = createContent();
  687.             if(_loc6_ is ContentProxy)
  688.             {
  689.                ContentProxy(_loc6_).object_proxy::isSimple = false;
  690.             }
  691.             if(param4 is XML)
  692.             {
  693.                _loc7_ = param4.elements();
  694.             }
  695.             else
  696.             {
  697.                _loc7_ = new XMLList(param4);
  698.             }
  699.             decodeAnyType(_loc6_,param3,_loc7_);
  700.             return _loc6_;
  701.          }
  702.          return schemaManager.unmarshall(param4,param1,param5);
  703.       }
  704.       
  705.       public function getSimpleValue(param1:*, param2:*) : *
  706.       {
  707.          var _loc3_:XML = null;
  708.          var _loc4_:XMLList = null;
  709.          if(param1 is XML)
  710.          {
  711.             _loc3_ = param1 as XML;
  712.             if(_loc3_.hasSimpleContent())
  713.             {
  714.                return _loc3_.toString();
  715.             }
  716.          }
  717.          else if(param1 is XMLList)
  718.          {
  719.             _loc4_ = param1 as XMLList;
  720.             if(_loc4_.hasSimpleContent())
  721.             {
  722.                return _loc4_.toString();
  723.             }
  724.          }
  725.          return getValue(param1,param2);
  726.       }
  727.       
  728.       public function setValue(param1:*, param2:*, param3:*, param4:Object = null) : void
  729.       {
  730.          var existingValue:* = undefined;
  731.          var propertyName:String = null;
  732.          var proxyParent:ContentProxy = null;
  733.          var parent:* = param1;
  734.          var name:* = param2;
  735.          var value:* = param3;
  736.          var type:Object = param4;
  737.          if(parent != null)
  738.          {
  739.             if(value is ContentProxy)
  740.             {
  741.                value = ContentProxy(value).object_proxy::content;
  742.             }
  743.             if(TypeIterator.isIterable(parent))
  744.             {
  745.                TypeIterator.push(parent,value);
  746.             }
  747.             else if(name != null)
  748.             {
  749.                if(name is ContentProxy)
  750.                {
  751.                   name = ContentProxy(name).object_proxy::content;
  752.                }
  753.                if(name is QName)
  754.                {
  755.                   propertyName = QName(name).localName;
  756.                }
  757.                else
  758.                {
  759.                   propertyName = Object(name).toString();
  760.                }
  761.                if(parent is ContentProxy && Boolean(ContentProxy(parent).object_proxy::isSimple))
  762.                {
  763.                   existingValue = ContentProxy(parent).object_proxy::content;
  764.                }
  765.                else if(Object(parent).hasOwnProperty(propertyName))
  766.                {
  767.                   existingValue = getExistingValue(parent,propertyName);
  768.                }
  769.                else if(Object(parent).hasOwnProperty("_" + propertyName))
  770.                {
  771.                   existingValue = getExistingValue(parent,"_" + propertyName);
  772.                }
  773.                if(existingValue != null)
  774.                {
  775.                   existingValue = promoteValueToArray(existingValue,type);
  776.                   TypeIterator.push(existingValue,value);
  777.                   value = existingValue;
  778.                }
  779.                try
  780.                {
  781.                   if(parent is ContentProxy && Boolean(ContentProxy(parent).object_proxy::isSimple))
  782.                   {
  783.                      ContentProxy(parent).object_proxy::content = value;
  784.                   }
  785.                   else
  786.                   {
  787.                      try
  788.                      {
  789.                         parent[propertyName] = value;
  790.                      }
  791.                      catch(e:Error)
  792.                      {
  793.                         parent["_" + propertyName] = value;
  794.                      }
  795.                   }
  796.                }
  797.                catch(e:Error)
  798.                {
  799.                   log.warn("Unable to set property \'{0}\' on parent.",propertyName);
  800.                }
  801.             }
  802.             else if(parent is ContentProxy)
  803.             {
  804.                proxyParent = parent as ContentProxy;
  805.                existingValue = proxyParent.object_proxy::content;
  806.                if(existingValue !== undefined)
  807.                {
  808.                   existingValue = promoteValueToArray(existingValue,type);
  809.                   proxyParent.object_proxy::content = existingValue;
  810.                   TypeIterator.push(existingValue,value);
  811.                   value = existingValue;
  812.                }
  813.                proxyParent.object_proxy::content = value;
  814.             }
  815.          }
  816.       }
  817.       
  818.       public function decodeComplexContent(param1:XML, param2:*, param3:QName, param4:*, param5:DecodingContext) : void
  819.       {
  820.          var _loc6_:XML = getSingleElementFromNode(param1,constants.extensionQName,constants.restrictionQName);
  821.          if(_loc6_.name() == constants.extensionQName)
  822.          {
  823.             decodeComplexExtension(_loc6_,param2,param3,param4,param5);
  824.          }
  825.          else if(_loc6_.name() == constants.restrictionQName)
  826.          {
  827.             decodeComplexRestriction(_loc6_,param2,param3,param4);
  828.          }
  829.       }
  830.       
  831.       public function getValue(param1:*, param2:*, param3:Number = -1) : *
  832.       {
  833.          var _loc4_:* = undefined;
  834.          var _loc5_:QName = null;
  835.          var _loc6_:XMLList = null;
  836.          if(param2 is QName)
  837.          {
  838.             _loc5_ = param2 as QName;
  839.             if(_loc5_.uri == null || _loc5_.uri == "")
  840.             {
  841.                param2 = _loc5_.localName;
  842.             }
  843.          }
  844.          if(param1 is XML)
  845.          {
  846.             _loc6_ = XML(param1).elements(param2);
  847.             if(_loc6_.length() > 0)
  848.             {
  849.                _loc4_ = parseValue(param2,_loc6_);
  850.             }
  851.          }
  852.          else if(param1 is XMLList)
  853.          {
  854.             _loc6_ = XMLList(param1).elements(param2);
  855.             if(_loc6_.length() > 0)
  856.             {
  857.                _loc4_ = parseValue(param2,_loc6_);
  858.             }
  859.          }
  860.          else if(param1 is ContentProxy)
  861.          {
  862.             if(_loc5_ != null)
  863.             {
  864.                param2 = _loc5_.localName;
  865.             }
  866.             _loc4_ = !!(param1 as ContentProxy).hasOwnProperty(param2) ? param1[param2] : undefined;
  867.          }
  868.          else if(!isSimpleValue(param1))
  869.          {
  870.             _loc4_ = param1[param2];
  871.          }
  872.          return _loc4_;
  873.       }
  874.       
  875.       public function decodeComplexType(param1:XML, param2:*, param3:QName, param4:*, param5:XML = null, param6:DecodingContext = null) : void
  876.       {
  877.          var _loc9_:XML = null;
  878.          if(param2 is ContentProxy)
  879.          {
  880.             ContentProxy(param2).object_proxy::isSimple = false;
  881.          }
  882.          var _loc7_:XMLList = param1.elements();
  883.          var _loc8_:XMLList = new XMLList();
  884.          if(param4 is XML)
  885.          {
  886.             _loc8_ = (param4 as XML).elements();
  887.          }
  888.          else if(param4 is XMLList)
  889.          {
  890.             _loc8_ = param4;
  891.          }
  892.          for each(_loc9_ in _loc7_)
  893.          {
  894.             if(_loc9_.name() == constants.simpleContentQName)
  895.             {
  896.                decodeSimpleContent(_loc9_,param2,param3,param4,param5);
  897.             }
  898.             else if(_loc9_.name() == constants.complexContentQName)
  899.             {
  900.                decodeComplexContent(_loc9_,param2,param3,param4,param6);
  901.             }
  902.             else if(_loc9_.name() == constants.sequenceQName)
  903.             {
  904.                decodeSequence(_loc9_,param2,param3,_loc8_,param6);
  905.             }
  906.             else if(_loc9_.name() == constants.groupQName)
  907.             {
  908.                decodeGroupReference(_loc9_,param2,param3,_loc8_,param6);
  909.             }
  910.             else if(_loc9_.name() == constants.allQName)
  911.             {
  912.                decodeAll(_loc9_,param2,param3,_loc8_,param6);
  913.             }
  914.             else if(_loc9_.name() == constants.choiceQName)
  915.             {
  916.                decodeChoice(_loc9_,param2,param3,_loc8_,param6);
  917.             }
  918.             else if(_loc9_.name() == constants.attributeQName)
  919.             {
  920.                decodeAttribute(_loc9_,param2,param4,param5);
  921.             }
  922.             else if(_loc9_.name() == constants.attributeGroupQName)
  923.             {
  924.                decodeAttributeGroup(_loc9_,param2,param4,param5);
  925.             }
  926.             else if(_loc9_.name() == constants.anyAttributeQName)
  927.             {
  928.                decodeAnyAttribute(_loc9_,param2,param4,param5);
  929.             }
  930.          }
  931.       }
  932.       
  933.       public function decodeChoice(param1:XML, param2:*, param3:QName, param4:XMLList, param5:DecodingContext = null, param6:Boolean = true) : Boolean
  934.       {
  935.          var _loc10_:Boolean = false;
  936.          var _loc11_:uint = 0;
  937.          var _loc12_:uint = 0;
  938.          var _loc13_:XML = null;
  939.          if(param5 == null)
  940.          {
  941.             param5 = new DecodingContext();
  942.          }
  943.          var _loc7_:uint = getMaxOccurs(param1);
  944.          var _loc8_:uint = getMinOccurs(param1);
  945.          if(_loc7_ == 0)
  946.          {
  947.             return false;
  948.          }
  949.          if(param4 == null && _loc8_ == 0)
  950.          {
  951.             return true;
  952.          }
  953.          var _loc9_:XMLList = param1.elements();
  954.          if(_loc9_.length() == 0)
  955.          {
  956.             return true;
  957.          }
  958.          _loc12_ = 0;
  959.          while(_loc12_ < _loc7_)
  960.          {
  961.             _loc11_ = uint(param5.index + 0);
  962.             _loc10_ = false;
  963.             for each(_loc13_ in _loc9_)
  964.             {
  965.                if(_loc13_.name() == constants.elementTypeQName)
  966.                {
  967.                   _loc10_ ||= decodeGroupElement(_loc13_,param2,param4,param5,false);
  968.                   if(param5.index > _loc11_)
  969.                   {
  970.                      break;
  971.                   }
  972.                }
  973.                else if(_loc13_.name() == constants.sequenceQName)
  974.                {
  975.                   _loc10_ ||= decodeSequence(_loc13_,param2,param3,param4,param5,false);
  976.                   if(param5.index > _loc11_)
  977.                   {
  978.                      break;
  979.                   }
  980.                }
  981.                else if(_loc13_.name() == constants.groupQName)
  982.                {
  983.                   _loc10_ ||= decodeGroupReference(_loc13_,param2,param3,param4,param5,false);
  984.                   if(param5.index > _loc11_)
  985.                   {
  986.                      break;
  987.                   }
  988.                }
  989.                else if(_loc13_.name() == constants.choiceQName)
  990.                {
  991.                   _loc10_ ||= decodeChoice(_loc13_,param2,param3,param4,param5,false);
  992.                   if(param5.index > _loc11_)
  993.                   {
  994.                      break;
  995.                   }
  996.                }
  997.                else if(_loc13_.name() == constants.anyQName)
  998.                {
  999.                   _loc10_ ||= decodeAnyElement(_loc13_,param2,param3,param4,param5,false);
  1000.                   if(param5.index > _loc11_)
  1001.                   {
  1002.                      break;
  1003.                   }
  1004.                }
  1005.             }
  1006.             if(!_loc10_)
  1007.             {
  1008.                break;
  1009.             }
  1010.             _loc12_++;
  1011.          }
  1012.          if(_loc12_ < _loc8_)
  1013.          {
  1014.             if(param6 && strictOccurenceBounds)
  1015.             {
  1016.                throw new Error("Value supplied for choice " + param3.toString() + " occurs " + _loc12_ + " times which falls short of minOccurs " + _loc8_ + ".");
  1017.             }
  1018.             return false;
  1019.          }
  1020.          return true;
  1021.       }
  1022.       
  1023.       public function get recordXSIType() : Boolean
  1024.       {
  1025.          return _recordXSIType;
  1026.       }
  1027.       
  1028.       public function set recordXSIType(param1:Boolean) : void
  1029.       {
  1030.          _recordXSIType = param1;
  1031.       }
  1032.       
  1033.       public function decodeType(param1:QName, param2:*, param3:QName, param4:*, param5:XML = null) : void
  1034.       {
  1035.          var _loc6_:* = undefined;
  1036.          var _loc7_:XML = null;
  1037.          var _loc8_:QName = null;
  1038.          if(isBuiltInType(param1))
  1039.          {
  1040.             _loc6_ = marshallBuiltInType(param1,param2,param3,param4,param5);
  1041.             setValue(param2,param3,_loc6_,param1);
  1042.          }
  1043.          else
  1044.          {
  1045.             _loc7_ = schemaManager.getNamedDefinition(param1,constants.complexTypeQName,constants.simpleTypeQName);
  1046.             if(_loc7_ == null)
  1047.             {
  1048.                throw new Error("Cannot find definition for type \'" + param1 + "\'");
  1049.             }
  1050.             if(isXSINil(param4))
  1051.             {
  1052.                setValue(param2,param3,null,param1);
  1053.                return;
  1054.             }
  1055.             _loc8_ = _loc7_.name() as QName;
  1056.             if(_loc8_ == constants.complexTypeQName)
  1057.             {
  1058.                decodeComplexType(_loc7_,param2,param3,param4,param5);
  1059.             }
  1060.             else
  1061.             {
  1062.                if(_loc8_ != constants.simpleTypeQName)
  1063.                {
  1064.                   throw new Error("Invalid type definition " + _loc8_);
  1065.                }
  1066.                decodeSimpleType(_loc7_,param2,param3,param4,param5);
  1067.             }
  1068.             schemaManager.releaseScope();
  1069.          }
  1070.          setXSIType(param2,param1);
  1071.       }
  1072.       
  1073.       protected function promoteValueToArray(param1:*, param2:Object = null) : *
  1074.       {
  1075.          var _loc3_:* = undefined;
  1076.          if(!TypeIterator.isIterable(param1))
  1077.          {
  1078.             _loc3_ = createIterableValue(param2);
  1079.             TypeIterator.push(_loc3_,param1);
  1080.             param1 = _loc3_;
  1081.          }
  1082.          return param1;
  1083.       }
  1084.       
  1085.       public function decodeAttribute(param1:XML, param2:*, param3:* = undefined, param4:XML = null) : void
  1086.       {
  1087.          var _loc5_:QName = null;
  1088.          var _loc8_:QName = null;
  1089.          var _loc9_:String = null;
  1090.          var _loc10_:* = undefined;
  1091.          var _loc11_:String = null;
  1092.          var _loc12_:XML = null;
  1093.          var _loc13_:String = null;
  1094.          var _loc14_:QName = null;
  1095.          var _loc15_:* = undefined;
  1096.          if(param1.attribute("ref").length() == 1)
  1097.          {
  1098.             _loc5_ = schemaManager.getQNameForPrefixedName(param1.@ref,param1,true);
  1099.             param1 = schemaManager.getNamedDefinition(_loc5_,constants.attributeQName);
  1100.             if(param1 == null)
  1101.             {
  1102.                throw new Error("Cannot resolve attribute definition for \'" + _loc5_ + "\'");
  1103.             }
  1104.          }
  1105.          var _loc6_:String = param1.@name.toString();
  1106.          var _loc7_:String = param1.attribute("use").toString();
  1107.          if(_loc7_ != "prohibited")
  1108.          {
  1109.             _loc8_ = schemaManager.getQNameForAttribute(_loc6_,getAttributeFromNode("form",param1));
  1110.             _loc9_ = getAttributeFromNode("fixed",param1);
  1111.             if(_loc9_ != null)
  1112.             {
  1113.                param3 = _loc9_;
  1114.             }
  1115.             else
  1116.             {
  1117.                param3 = getAttribute(param3,_loc8_);
  1118.                if(param3 === undefined)
  1119.                {
  1120.                   _loc11_ = getAttributeFromNode("default",param1);
  1121.                   if(_loc11_ != null)
  1122.                   {
  1123.                      param3 = _loc11_;
  1124.                   }
  1125.                }
  1126.             }
  1127.             if(param3 !== undefined)
  1128.             {
  1129.                _loc10_ = createContent();
  1130.                _loc13_ = getAttributeFromNode("type",param1);
  1131.                if(_loc13_ != null)
  1132.                {
  1133.                   _loc14_ = schemaManager.getQNameForPrefixedName(param1.@type,param1);
  1134.                }
  1135.                else
  1136.                {
  1137.                   _loc14_ = schemaManager.schemaDatatypes.anySimpleTypeQName;
  1138.                }
  1139.                if(_loc14_ != null)
  1140.                {
  1141.                   if(isBuiltInType(_loc14_))
  1142.                   {
  1143.                      _loc15_ = marshallBuiltInType(_loc14_,_loc10_,_loc8_,param3,param4);
  1144.                      setValue(_loc10_,_loc8_,_loc15_);
  1145.                   }
  1146.                   else
  1147.                   {
  1148.                      _loc12_ = schemaManager.getNamedDefinition(_loc14_,constants.simpleTypeQName);
  1149.                      if(_loc12_ == null)
  1150.                      {
  1151.                         throw new Error("Cannot find simpleType " + _loc14_ + " for attribute " + _loc8_);
  1152.                      }
  1153.                      decodeSimpleType(_loc12_,_loc10_,_loc8_,param3,param4);
  1154.                      schemaManager.releaseScope();
  1155.                   }
  1156.                }
  1157.                else
  1158.                {
  1159.                   _loc12_ = getSingleElementFromNode(param1,constants.simpleTypeQName);
  1160.                   if(_loc12_ != null)
  1161.                   {
  1162.                      decodeSimpleType(_loc12_,_loc10_,_loc8_,param3,param4);
  1163.                   }
  1164.                   else if(param3 != null)
  1165.                   {
  1166.                      _loc10_ = param3;
  1167.                   }
  1168.                }
  1169.             }
  1170.             if(_loc10_ != null)
  1171.             {
  1172.                setAttribute(param2,_loc8_,_loc10_);
  1173.             }
  1174.          }
  1175.          if(_loc5_ != null)
  1176.          {
  1177.             schemaManager.releaseScope();
  1178.          }
  1179.       }
  1180.       
  1181.       protected function getApplicableValues(param1:*, param2:XMLList, param3:QName, param4:DecodingContext, param5:uint) : XMLList
  1182.       {
  1183.          var _loc6_:XMLList = new XMLList();
  1184.          var _loc7_:uint = uint(param4.index);
  1185.          var _loc8_:Boolean = false;
  1186.          if(param4.anyIndex > -1 && param3 != null)
  1187.          {
  1188.             _loc7_ = uint(param4.anyIndex);
  1189.             _loc8_ = true;
  1190.          }
  1191.          var _loc9_:uint = _loc7_;
  1192.          while(_loc9_ < param2.length())
  1193.          {
  1194.             if(_loc6_.length() == param5)
  1195.             {
  1196.                break;
  1197.             }
  1198.             if(param3 == null || param2[_loc9_].name() == param3 || (param3.uri == "" || param3.uri == null) && param3.localName == param2[_loc9_].name().localName)
  1199.             {
  1200.                _loc6_ += param2[_loc9_];
  1201.                if(_loc9_ < param4.index)
  1202.                {
  1203.                   param1[param3.localName] = null;
  1204.                }
  1205.                _loc8_ = false;
  1206.             }
  1207.             else if(_loc8_ == false)
  1208.             {
  1209.                break;
  1210.             }
  1211.             _loc9_++;
  1212.          }
  1213.          return _loc6_;
  1214.       }
  1215.       
  1216.       public function decodeAttributeGroup(param1:XML, param2:*, param3:* = undefined, param4:XML = null) : void
  1217.       {
  1218.          var _loc5_:QName = null;
  1219.          var _loc7_:XML = null;
  1220.          var _loc8_:XMLList = null;
  1221.          var _loc9_:XML = null;
  1222.          var _loc10_:XML = null;
  1223.          if(param1.attribute("ref").length() == 1)
  1224.          {
  1225.             _loc5_ = schemaManager.getQNameForPrefixedName(param1.@ref,param1,true);
  1226.             param1 = schemaManager.getNamedDefinition(_loc5_,constants.attributeGroupQName);
  1227.             if(param1 == null)
  1228.             {
  1229.                throw new Error("Cannot resolve attributeGroup definition for \'" + _loc5_ + "\'");
  1230.             }
  1231.          }
  1232.          var _loc6_:XMLList = param1.elements(constants.attributeQName);
  1233.          for each(_loc7_ in _loc6_)
  1234.          {
  1235.             decodeAttribute(_loc7_,param2,param3,param4);
  1236.          }
  1237.          _loc8_ = param1.elements(constants.attributeGroupQName);
  1238.          for each(_loc9_ in _loc8_)
  1239.          {
  1240.             decodeAttributeGroup(_loc9_,param2,param3,param4);
  1241.          }
  1242.          _loc10_ = getSingleElementFromNode(param1,constants.anyAttributeQName);
  1243.          if(_loc10_ != null)
  1244.          {
  1245.             decodeAnyAttribute(_loc10_,param2,param3,param4);
  1246.          }
  1247.          if(_loc5_ != null)
  1248.          {
  1249.             schemaManager.releaseScope();
  1250.          }
  1251.       }
  1252.       
  1253.       public function decodeAll(param1:XML, param2:*, param3:QName, param4:XMLList, param5:DecodingContext = null, param6:Boolean = true) : Boolean
  1254.       {
  1255.          var _loc12_:XML = null;
  1256.          if(param5 == null)
  1257.          {
  1258.             param5 = new DecodingContext();
  1259.          }
  1260.          var _loc7_:uint = getMinOccurs(param1);
  1261.          var _loc8_:XMLList = param1.elements();
  1262.          var _loc9_:Boolean = _loc8_.length() > 1 || param5.hasContextSiblings;
  1263.          var _loc10_:Boolean = param6 && _loc7_ > 0;
  1264.          var _loc11_:* = !_loc10_;
  1265.          for each(_loc12_ in _loc8_)
  1266.          {
  1267.             param5.index = 0;
  1268.             param5.anyIndex = 0;
  1269.             if(_loc12_.name() == constants.annotationQName)
  1270.             {
  1271.                _loc11_ = true;
  1272.             }
  1273.             else if(_loc12_.name() == constants.elementTypeQName)
  1274.             {
  1275.                if(!decodeGroupElement(_loc12_,param2,param4,param5,_loc10_,_loc9_))
  1276.                {
  1277.                   break;
  1278.                }
  1279.             }
  1280.             else if(_loc12_.name() == constants.anyQName)
  1281.             {
  1282.                if(!decodeAnyElement(_loc12_,param2,param3,param4,param5,_loc10_))
  1283.                {
  1284.                   break;
  1285.                }
  1286.             }
  1287.             _loc11_ = true;
  1288.          }
  1289.          return _loc11_;
  1290.       }
  1291.       
  1292.       public function isSimpleValue(param1:*) : Boolean
  1293.       {
  1294.          if(param1 is XML)
  1295.          {
  1296.             return XML(param1).hasSimpleContent();
  1297.          }
  1298.          if(param1 is String || param1 is Number || param1 is Boolean || param1 is Date || param1 is int || param1 is uint || param1 is ByteArray)
  1299.          {
  1300.             return true;
  1301.          }
  1302.          return false;
  1303.       }
  1304.       
  1305.       public function decodeSequence(param1:XML, param2:*, param3:QName, param4:XMLList, param5:DecodingContext = null, param6:Boolean = true) : Boolean
  1306.       {
  1307.          var _loc10_:uint = 0;
  1308.          var _loc12_:Boolean = false;
  1309.          var _loc13_:Boolean = false;
  1310.          var _loc14_:uint = 0;
  1311.          var _loc15_:XML = null;
  1312.          if(param5 == null)
  1313.          {
  1314.             param5 = new DecodingContext();
  1315.          }
  1316.          var _loc7_:uint = getMaxOccurs(param1);
  1317.          var _loc8_:uint = getMinOccurs(param1);
  1318.          if(_loc7_ == 0)
  1319.          {
  1320.             return false;
  1321.          }
  1322.          if((param4 == null || param4.length() == 0) && _loc8_ == 0)
  1323.          {
  1324.             return true;
  1325.          }
  1326.          var _loc9_:XMLList = param1.elements();
  1327.          var _loc11_:Boolean = _loc9_.length() > 1 || param5.hasContextSiblings;
  1328.          if(_loc9_.length() == 0)
  1329.          {
  1330.             return true;
  1331.          }
  1332.          _loc10_ = 0;
  1333.          while(true)
  1334.          {
  1335.             if(_loc10_ < _loc7_)
  1336.             {
  1337.                _loc12_ = param6 && _loc10_ < _loc8_;
  1338.                _loc13_ = true;
  1339.                _loc14_ = uint(param5.index + 0);
  1340.                for each(_loc15_ in _loc9_)
  1341.                {
  1342.                   _loc13_ = false;
  1343.                   if(_loc15_.name() == constants.annotationQName)
  1344.                   {
  1345.                      _loc13_ = true;
  1346.                   }
  1347.                   if(_loc15_.name() == constants.elementTypeQName)
  1348.                   {
  1349.                      if(!decodeGroupElement(_loc15_,param2,param4,param5,_loc12_,_loc11_))
  1350.                      {
  1351.                         break;
  1352.                      }
  1353.                   }
  1354.                   else if(_loc15_.name() == constants.groupQName)
  1355.                   {
  1356.                      if(!decodeGroupReference(_loc15_,param2,param3,param4,param5,_loc12_))
  1357.                      {
  1358.                         break;
  1359.                      }
  1360.                   }
  1361.                   else if(_loc15_.name() == constants.choiceQName)
  1362.                   {
  1363.                      if(!decodeChoice(_loc15_,param2,param3,param4,param5,_loc12_))
  1364.                      {
  1365.                         break;
  1366.                      }
  1367.                   }
  1368.                   else if(_loc15_.name() == constants.sequenceQName)
  1369.                   {
  1370.                      if(!decodeSequence(_loc15_,param2,param3,param4,param5,_loc12_))
  1371.                      {
  1372.                         break;
  1373.                      }
  1374.                   }
  1375.                   else if(_loc15_.name() == constants.anyQName)
  1376.                   {
  1377.                      if(!decodeAnyElement(_loc15_,param2,param3,param4,param5,_loc12_))
  1378.                      {
  1379.                         break;
  1380.                      }
  1381.                   }
  1382.                   _loc13_ = true;
  1383.                }
  1384.                if(!_loc13_ && _loc12_)
  1385.                {
  1386.                   break;
  1387.                }
  1388.                if(_loc14_ != param5.index)
  1389.                {
  1390.                   continue;
  1391.                }
  1392.                if(_loc13_)
  1393.                {
  1394.                   _loc10_ = ++_loc10_ > _loc8_ ? _loc10_ : _loc8_;
  1395.                }
  1396.             }
  1397.             if(_loc10_ < _loc8_)
  1398.             {
  1399.                if(param6 && strictOccurenceBounds)
  1400.                {
  1401.                   throw new Error("Value supplied for sequence " + param3.toString() + " occurs " + _loc10_ + " times which falls short of minOccurs " + _loc8_ + ".");
  1402.                }
  1403.                return false;
  1404.             }
  1405.             return true;
  1406.             _loc10_++;
  1407.          }
  1408.          if(strictOccurenceBounds)
  1409.          {
  1410.             throw new Error("Cannot find value for definition " + _loc15_.toXMLString() + " in sequence.");
  1411.          }
  1412.          return false;
  1413.       }
  1414.       
  1415.       public function setAttribute(param1:*, param2:*, param3:*) : void
  1416.       {
  1417.          var _loc4_:ContentProxy = null;
  1418.          var _loc5_:* = undefined;
  1419.          var _loc6_:SimpleContent = null;
  1420.          if(param1 is ContentProxy)
  1421.          {
  1422.             _loc4_ = param1 as ContentProxy;
  1423.             if(_loc4_.object_proxy::isSimple)
  1424.             {
  1425.                _loc5_ = _loc4_.object_proxy::content;
  1426.                if(!(_loc5_ is SimpleContent))
  1427.                {
  1428.                   _loc6_ = new SimpleContent(_loc5_);
  1429.                   _loc4_.object_proxy::content = _loc6_;
  1430.                }
  1431.                _loc4_.object_proxy::isSimple = false;
  1432.             }
  1433.          }
  1434.          setValue(param1,param2,param3);
  1435.       }
  1436.       
  1437.       public function createContent(param1:QName = null) : *
  1438.       {
  1439.          var c:Class = null;
  1440.          var className:String = null;
  1441.          var type:QName = param1;
  1442.          var content:* = undefined;
  1443.          if(type != null && typeRegistry != null)
  1444.          {
  1445.             c = typeRegistry.getClass(type);
  1446.             if(c == null)
  1447.             {
  1448.                c = typeRegistry.getCollectionClass(type);
  1449.             }
  1450.             if(c != null)
  1451.             {
  1452.                try
  1453.                {
  1454.                   content = new c();
  1455.                }
  1456.                catch(e:Error)
  1457.                {
  1458.                   className = getQualifiedClassName(c);
  1459.                   log.debug("Unable to create new instance of Class \'{0}\' for type \'{1}\'.",className,type);
  1460.                }
  1461.             }
  1462.          }
  1463.          return new ContentProxy(content,makeObjectsBindable);
  1464.       }
  1465.       
  1466.       override public function reset() : void
  1467.       {
  1468.          super.reset();
  1469.          document = null;
  1470.       }
  1471.       
  1472.       public function getAttribute(param1:*, param2:*) : *
  1473.       {
  1474.          var _loc3_:* = undefined;
  1475.          var _loc4_:XMLList = null;
  1476.          if(param1 is XML)
  1477.          {
  1478.             _loc4_ = XML(param1).attribute(param2);
  1479.             _loc3_ = parseValue(param2,_loc4_);
  1480.          }
  1481.          else if(param1 is XMLList)
  1482.          {
  1483.             _loc4_ = XMLList(param1).attribute(param2);
  1484.             _loc3_ = parseValue(param2,_loc4_);
  1485.          }
  1486.          return _loc3_;
  1487.       }
  1488.       
  1489.       public function decodeSimpleRestriction(param1:XML, param2:*, param3:QName, param4:*) : void
  1490.       {
  1491.          var _loc6_:String = null;
  1492.          var _loc7_:QName = null;
  1493.          var _loc5_:XML = getSingleElementFromNode(param1,constants.simpleTypeQName);
  1494.          if(_loc5_ != null)
  1495.          {
  1496.             decodeSimpleType(_loc5_,param2,param3,param4,param1);
  1497.          }
  1498.          else
  1499.          {
  1500.             _loc6_ = getAttributeFromNode("base",param1);
  1501.             _loc7_ = schemaManager.getQNameForPrefixedName(_loc6_,param1);
  1502.             decodeType(_loc7_,param2,param3,param4,param1);
  1503.          }
  1504.       }
  1505.       
  1506.       protected function setXSIType(param1:*, param2:QName) : void
  1507.       {
  1508.          if(param1 != null && recordXSIType)
  1509.          {
  1510.             if(param1 is ContentProxy)
  1511.             {
  1512.                param1 = param1.object_proxy::content;
  1513.             }
  1514.             if(param1 != null)
  1515.             {
  1516.                if(param1 is ObjectProxy)
  1517.                {
  1518.                   ObjectProxy(param1).object_proxy::type = param2;
  1519.                }
  1520.                else if(param1 is IXMLSchemaInstance)
  1521.                {
  1522.                   IXMLSchemaInstance(param1).xsiType = param2;
  1523.                }
  1524.             }
  1525.          }
  1526.       }
  1527.       
  1528.       public function decodeSimpleUnion(param1:XML, param2:*, param3:QName, param4:*, param5:XML = null) : void
  1529.       {
  1530.          var _loc8_:QName = null;
  1531.          var _loc9_:* = undefined;
  1532.          var _loc12_:String = null;
  1533.          var _loc13_:QName = null;
  1534.          var _loc6_:String = getAttributeFromNode("memberTypes",param1);
  1535.          var _loc7_:Array = _loc6_.split(" ");
  1536.          var _loc10_:int = 0;
  1537.          while(_loc10_ < _loc7_.length)
  1538.          {
  1539.             _loc12_ = _loc7_[_loc10_];
  1540.             _loc13_ = schemaManager.getQNameForPrefixedName(_loc12_,param1);
  1541.             if(!isBuiltInType(_loc13_))
  1542.             {
  1543.                _loc9_ = getValue(param4,_loc13_);
  1544.                if(_loc9_ !== undefined)
  1545.                {
  1546.                   _loc8_ = _loc13_;
  1547.                   break;
  1548.                }
  1549.             }
  1550.             _loc10_++;
  1551.          }
  1552.          if(!_loc8_)
  1553.          {
  1554.             _loc8_ = schemaManager.schemaDatatypes.stringQName;
  1555.          }
  1556.          var _loc11_:* = marshallBuiltInType(_loc8_,param2,param3,param4,param5);
  1557.          setValue(param2,param3,_loc11_,_loc8_);
  1558.       }
  1559.       
  1560.       protected function getExistingValue(param1:*, param2:String) : *
  1561.       {
  1562.          var className:String;
  1563.          var existingValue:* = undefined;
  1564.          var classInfo:XML = null;
  1565.          var properties:XMLList = null;
  1566.          var property:XML = null;
  1567.          var propertyType:String = null;
  1568.          var tempValue:* = undefined;
  1569.          var parent:* = param1;
  1570.          var propertyName:String = param2;
  1571.          var object:Object = Object(parent);
  1572.          if(parent is ContentProxy)
  1573.          {
  1574.             object = ContentProxy(parent).object_proxy::content;
  1575.          }
  1576.          if(object is ObjectProxy)
  1577.          {
  1578.             object = ObjectProxy(object).object_proxy::object;
  1579.          }
  1580.          className = getQualifiedClassName(object);
  1581.          if(className == "Object")
  1582.          {
  1583.             existingValue = parent[propertyName];
  1584.          }
  1585.          else
  1586.          {
  1587.             classInfo = DescribeTypeCache.describeType(object).typeDescription;
  1588.             properties = classInfo..accessor.(@access == "readwrite" && @name == propertyName) + classInfo..variable.(@name == propertyName);
  1589.             if(properties.length() > 0)
  1590.             {
  1591.                property = properties[0];
  1592.                propertyType = property.@type;
  1593.                tempValue = parent[propertyName];
  1594.                if(propertyType == "Object" || propertyType == "*" || TypeIterator.isIterable(tempValue))
  1595.                {
  1596.                   existingValue = tempValue;
  1597.                }
  1598.             }
  1599.          }
  1600.          return existingValue;
  1601.       }
  1602.       
  1603.       protected function getXSIType(param1:*) : QName
  1604.       {
  1605.          var _loc2_:QName = null;
  1606.          var _loc3_:XML = null;
  1607.          var _loc4_:String = null;
  1608.          if(param1 is XML)
  1609.          {
  1610.             _loc3_ = param1 as XML;
  1611.          }
  1612.          else if(param1 is XMLList && param1.length() == 1)
  1613.          {
  1614.             _loc3_ = param1[0];
  1615.          }
  1616.          if(_loc3_ != null)
  1617.          {
  1618.             _loc4_ = XMLUtil.getAttributeByQName(_loc3_,constants.typeAttrQName).toString();
  1619.             if(_loc4_ != null && _loc4_ != "")
  1620.             {
  1621.                _loc2_ = schemaManager.getQNameForPrefixedName(_loc4_,_loc3_);
  1622.             }
  1623.          }
  1624.          return _loc2_;
  1625.       }
  1626.       
  1627.       public function decode(param1:*, param2:QName = null, param3:QName = null, param4:XML = null) : *
  1628.       {
  1629.          var content:* = undefined;
  1630.          var elementDefinition:XML = null;
  1631.          var xml:* = param1;
  1632.          var name:QName = param2;
  1633.          var type:QName = param3;
  1634.          var definition:XML = param4;
  1635.          if(!(xml is XML) && !(xml is XMLList) && !(xml is String))
  1636.          {
  1637.             throw new ArgumentError("The xml argument must be of type XML, XMLList or String.");
  1638.          }
  1639.          if(xml is XML)
  1640.          {
  1641.             document = xml;
  1642.          }
  1643.          else if(xml is XMLList)
  1644.          {
  1645.             if(XMLList(xml).length() != 1)
  1646.             {
  1647.                throw new ArgumentError("The xml argument must have a length of 1 when passed as an XMLList.");
  1648.             }
  1649.             document = XMLList(xml)[0];
  1650.          }
  1651.          else if(xml is String)
  1652.          {
  1653.             try
  1654.             {
  1655.                document = new XML(xml);
  1656.             }
  1657.             catch(e:Error)
  1658.             {
  1659.                throw new ArgumentError("The xml argument does not contain valid xml. " + xml);
  1660.             }
  1661.          }
  1662.          preProcessXML(document);
  1663.          if(type != null)
  1664.          {
  1665.             content = createContent(type);
  1666.             decodeType(type,content,name,document);
  1667.          }
  1668.          else
  1669.          {
  1670.             elementDefinition = definition;
  1671.             if(elementDefinition == null)
  1672.             {
  1673.                elementDefinition = schemaManager.getNamedDefinition(name,constants.elementTypeQName);
  1674.             }
  1675.             if(elementDefinition == null)
  1676.             {
  1677.                content = createContent(type);
  1678.                decodeType(constants.anyTypeQName,content,name,document);
  1679.             }
  1680.             else
  1681.             {
  1682.                content = decodeElementTopLevel(elementDefinition,name,document);
  1683.                if(definition == null)
  1684.                {
  1685.                   schemaManager.releaseScope();
  1686.                }
  1687.             }
  1688.          }
  1689.          if(content is ContentProxy)
  1690.          {
  1691.             content = ContentProxy(content).object_proxy::content;
  1692.          }
  1693.          return content;
  1694.       }
  1695.       
  1696.       public function hasValue(param1:*, param2:*) : Boolean
  1697.       {
  1698.          return getValue(param1,param2) !== undefined;
  1699.       }
  1700.       
  1701.       public function decodeAnyType(param1:*, param2:QName, param3:XMLList) : void
  1702.       {
  1703.          var _loc4_:XML = null;
  1704.          var _loc5_:QName = null;
  1705.          var _loc6_:* = undefined;
  1706.          var _loc7_:QName = null;
  1707.          for each(_loc4_ in param3)
  1708.          {
  1709.             _loc5_ = _loc4_.name() as QName;
  1710.             _loc7_ = getXSIType(_loc4_);
  1711.             if(_loc7_ != null)
  1712.             {
  1713.                _loc6_ = createContent();
  1714.                decodeType(schemaManager.schemaDatatypes.anyTypeQName,_loc6_,_loc5_,_loc4_);
  1715.             }
  1716.             else
  1717.             {
  1718.                _loc6_ = marshallBuiltInType(schemaManager.schemaDatatypes.anyTypeQName,param1,_loc5_,_loc4_);
  1719.             }
  1720.             setValue(param1,_loc5_,_loc6_,_loc7_);
  1721.          }
  1722.       }
  1723.       
  1724.       public function set makeObjectsBindable(param1:Boolean) : void
  1725.       {
  1726.          _makeObjectsBindable = param1;
  1727.       }
  1728.       
  1729.       public function decodeComplexExtension(param1:XML, param2:*, param3:QName, param4:*, param5:DecodingContext = null) : void
  1730.       {
  1731.          var _loc11_:XML = null;
  1732.          if(param5 == null)
  1733.          {
  1734.             param5 = new DecodingContext();
  1735.          }
  1736.          param5.hasContextSiblings = true;
  1737.          var _loc6_:String = getAttributeFromNode("base",param1);
  1738.          if(_loc6_ == null)
  1739.          {
  1740.             throw new Error("A complexContent extension must declare a base type.");
  1741.          }
  1742.          var _loc7_:QName = schemaManager.getQNameForPrefixedName(_loc6_,param1);
  1743.          var _loc8_:XML = schemaManager.getNamedDefinition(_loc7_,constants.complexTypeQName);
  1744.          if(_loc8_ == null)
  1745.          {
  1746.             throw new Error("Cannot find base type definition \'" + _loc7_ + "\'");
  1747.          }
  1748.          decodeComplexType(_loc8_,param2,param3,param4,null,param5);
  1749.          schemaManager.releaseScope();
  1750.          var _loc9_:XMLList = param1.elements();
  1751.          var _loc10_:XMLList = new XMLList();
  1752.          if(param4 is XML)
  1753.          {
  1754.             _loc10_ = (param4 as XML).elements();
  1755.          }
  1756.          else if(param4 is XMLList)
  1757.          {
  1758.             _loc10_ = param4;
  1759.          }
  1760.          for each(_loc11_ in _loc9_)
  1761.          {
  1762.             if(_loc11_.name() == constants.sequenceQName)
  1763.             {
  1764.                decodeSequence(_loc11_,param2,param3,_loc10_,param5);
  1765.             }
  1766.             else if(_loc11_.name() == constants.groupQName)
  1767.             {
  1768.                decodeGroupReference(_loc11_,param2,param3,_loc10_,param5);
  1769.             }
  1770.             else if(_loc11_.name() == constants.allQName)
  1771.             {
  1772.                decodeAll(_loc11_,param2,param3,_loc10_,param5);
  1773.             }
  1774.             else if(_loc11_.name() == constants.choiceQName)
  1775.             {
  1776.                decodeChoice(_loc11_,param2,param3,_loc10_,param5);
  1777.             }
  1778.             else if(_loc11_.name() == constants.attributeQName)
  1779.             {
  1780.                decodeAttribute(_loc11_,param2,param4);
  1781.             }
  1782.             else if(_loc11_.name() == constants.attributeGroupQName)
  1783.             {
  1784.                decodeAttributeGroup(_loc11_,param2,param4);
  1785.             }
  1786.             else if(_loc11_.name() == constants.anyAttributeQName)
  1787.             {
  1788.                decodeAnyAttribute(_loc11_,param2,param4);
  1789.             }
  1790.          }
  1791.       }
  1792.       
  1793.       public function decodeSimpleList(param1:XML, param2:*, param3:QName, param4:*, param5:XML = null) : void
  1794.       {
  1795.          var _loc7_:QName = null;
  1796.          var _loc8_:XML = null;
  1797.          var _loc11_:* = undefined;
  1798.          var _loc12_:* = undefined;
  1799.          var _loc13_:String = null;
  1800.          var _loc6_:String = param1.@itemType;
  1801.          if(_loc6_ != "")
  1802.          {
  1803.             _loc7_ = schemaManager.getQNameForPrefixedName(_loc6_,param1);
  1804.          }
  1805.          else
  1806.          {
  1807.             _loc8_ = getSingleElementFromNode(param1,constants.simpleTypeQName);
  1808.          }
  1809.          var _loc9_:String = "";
  1810.          if(!TypeIterator.isIterable(param4))
  1811.          {
  1812.             param4 = [param4];
  1813.          }
  1814.          var _loc10_:TypeIterator = new TypeIterator(param4);
  1815.          while(_loc10_.hasNext())
  1816.          {
  1817.             _loc11_ = _loc10_.next();
  1818.             _loc12_ = createContent();
  1819.             if(_loc7_ != null)
  1820.             {
  1821.                decodeType(_loc7_,_loc12_,param3,_loc11_,param5);
  1822.             }
  1823.             else
  1824.             {
  1825.                decodeSimpleType(_loc8_,_loc12_,param3,_loc11_,param5);
  1826.             }
  1827.             _loc13_ = _loc12_ != null ? _loc12_.toString() : "";
  1828.             _loc9_ = _loc9_.concat(_loc13_);
  1829.             if(_loc10_.hasNext())
  1830.             {
  1831.                _loc9_ = _loc9_.concat(" ");
  1832.             }
  1833.          }
  1834.          setValue(param2,param3,_loc9_,_loc7_);
  1835.       }
  1836.    }
  1837. }
  1838.  
  1839.