/// /// <summary> * set the default values specified in this in element /// * </summary> /// * <param name="element"> /// * the element to set the defaults on </param> /// * <returns> true if successful </returns> /// public virtual bool setDefaultsFromCaps(KElement element, bool bAll) { string def = getAttribute(AttributeName.DEFAULTVALUE, null, null); if (!bAll && def == null) { return(false); } if (def == null) { def = getAttribute(AttributeName.CURRENTVALUE, null, null); } if (def == null) { def = getAttribute(AttributeName.ALLOWEDVALUELIST, null, null); if (def != null && (def.IndexOf("~") >= 0 || def.IndexOf(" ") >= 0)) // allowedvaluelist // is // a // list // or // range { string lt = getListType().getName(); if (!lt.EndsWith("List") && def.IndexOf(" ") >= 0) { def = StringUtil.token(def, 0, " "); } else if (lt.IndexOf("Range") < 0 && def.IndexOf("~") >= 0) { def = null; } } if (def == null) { def = getXPathAttribute("Value/@AllowedValue", null); } } if (def == null) { if ((this is JDFIntegerState) || (this is JDFNumberState)) { def = "1"; } else if (this is JDFXYPairState) { def = "1 1"; } else if (this is JDFBooleanState) { def = "true"; } else if (this is JDFMatrixState) { def = JDFMatrix.unitMatrix.ToString(); } else if (this is JDFShapeState) { def = "1 2 3"; } else if (this is JDFDateTimeState) { def = new JDFDate().DateTimeISO; } else if (this is JDFDurationState) { def = new JDFDuration(42).getDurationISO(); } else { def = "some_value"; // TODO add better type dependent value // generator } } object theValue = getMatchingObjectInNode(element); if (theValue != null) { return(false); } string nam = getName(); string nsURI = getDevNS(); if (nsURI.Equals(JDFElement.getSchemaURL())) { nsURI = null; } if (nsURI != null) { string prefix = KElement.xmlnsPrefix(nam); if (prefix == null) { nam = StringUtil.token(nsURI, -1, "/") + ":" + nam; } } if (getListType().Equals(EnumListType.Span)) { JDFIntentResource ir = (JDFIntentResource)element; JDFSpanBase span = ir.appendSpan(nam, null); span.setAttribute(AttributeName.PREFERRED, def); } else // some attribute... { element.setAttribute(nam, def, nsURI); } return(true); }