internal static XmlNode ProcessContextValueNode(SageContext context, XmlNode node)
{
if (node.SelectSingleElement("ancestor::sage:literal", XmlNamespaces.Manager) != null)
return node;
XmlElement valueElem = (XmlElement) node;
string xpath = valueElem.GetAttribute("xpath");
if (!string.IsNullOrWhiteSpace(xpath))
{
XmlNode value = node.SelectSingleNode(xpath, XmlNamespaces.Manager);
node.OwnerDocument.CreateTextNode(value.InnerText);
}
string propName = valueElem.GetAttribute("property");
if (string.IsNullOrWhiteSpace(propName))
return node.OwnerDocument.CreateTextNode(context.textEvaluator.Process(valueElem.InnerText));
string propKey = valueElem.GetAttribute("key");
string propValue = SageContext.GetContextProperty(context, propName, propKey);
if (propValue != null)
return node.OwnerDocument.CreateTextNode(propValue);
// default: return node as is
return node;
}