Ejemplo n.º 1
0
        //
        //	boolean nodeset = forceNodeset;
        //	if (!nodeset) {
        //		//is this a nodeset? it is if the ref contains any unbound multiplicities AND the unbound nodes are repeatable
        //		//the way i'm calculating this sucks; there has got to be an easier way to find out if a node is repeatable
        //		TreeReference repeatTestRef = TreeReference.rootRef();
        //		for (int i = 0; i < ref.size(); i++) {
        //			repeatTestRef.add(ref.getName(i), ref.getMultiplicity(i));
        //			if (ref.getMultiplicity(i) == TreeReference.INDEX_UNBOUND) {
        //				if (m.getTemplate(repeatTestRef) != null) {
        //					nodeset = true;
        //					break;
        //				}
        //			}
        //		}
        //	}

        public static System.Object getRefValue(FormInstance model, EvaluationContext ec, TreeReference ref_Renamed)
        {
            if (ec.isConstraint && ref_Renamed.Equals(ec.ContextRef))
            {
                //ITEMSET TODO: need to update this; for itemset/copy constraints, need to simulate a whole xml sub-tree here
                return(unpackValue(ec.candidateValue));
            }
            else
            {
                TreeElement node = model.resolveReference(ref_Renamed);
                if (node == null)
                {
                    //shouldn't happen -- only existent nodes should be in nodeset
                    throw new XPathTypeMismatchException("Node " + ref_Renamed.ToString() + " does not exist!");
                }

                return(unpackValue(node.isRelevant()?node.Value:null));
            }
        }