本文整理汇总了C#中System.Xml.XmlNode.IsPropertyElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.IsPropertyElement方法的具体用法?C# XmlNode.IsPropertyElement怎么用?C# XmlNode.IsPropertyElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.IsPropertyElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseEmptyPropertyElement
// 7.2.21 emptyPropertyElt
// start-element ( URI == propertyElementURIs,
// attributes == set ( idAttr?, ( resourceAttr | nodeIdAttr )?, propertyAttr* ) )
// end-element()
private void ParseEmptyPropertyElement (XmpNode parent, XmlNode node)
{
if (!node.IsPropertyElement ())
throw new CorruptFileException ("Invalid property");
if (node.HasChildNodes)
throw new CorruptFileException (String.Format ("Can't have content in this node! Node: {0}", node.OuterXml));
var rdf_value = node.Attributes.GetNamedItem (VALUE_URI, RDF_NS) as XmlAttribute;
var rdf_resource = node.Attributes.GetNamedItem (RESOURCE_URI, RDF_NS) as XmlAttribute;
// Options 1 and 2
var simple_prop_val = rdf_value ?? rdf_resource ?? null;
if (simple_prop_val != null) {
string value = simple_prop_val.InnerText;
parent.AddChild (CreateTextPropertyWithQualifiers (node, value));
return;
}
// Options 3 & 4
var new_node = new XmpNode (node.NamespaceURI, node.LocalName);
foreach (XmlAttribute a in node.Attributes) {
if (a.Is(RDF_NS, ID_URI) || a.Is(RDF_NS, NODE_ID_URI)) {
continue;
} else if (a.In (XMLNS_NS)) {
continue;
} else if (a.Is (XML_NS, LANG_URI)) {
new_node.AddQualifier (new XmpNode (XML_NS, LANG_URI, a.InnerText));
}
new_node.AddChild (new XmpNode (a.NamespaceURI, a.LocalName, a.InnerText));
}
parent.AddChild (new_node);
}
示例2: ParseLiteralPropertyElement
// 7.2.16 literalPropertyElt
// start-element ( URI == propertyElementURIs, attributes == set ( idAttr?, datatypeAttr?) )
// text()
// end-element()
private void ParseLiteralPropertyElement (XmpNode parent, XmlNode node)
{
if (!node.IsPropertyElement ())
throw new CorruptFileException ("Invalid property");
parent.AddChild (CreateTextPropertyWithQualifiers (node, node.InnerText));
}
示例3: ParseTypeResourcePropertyElement
// 7.2.18 parseTypeResourcePropertyElt
// start-element ( URI == propertyElementURIs, attributes == set ( idAttr?, parseResource ) )
// propertyEltList
// end-element()
private void ParseTypeResourcePropertyElement (XmpNode parent, XmlNode node)
{
if (!node.IsPropertyElement ())
throw new CorruptFileException ("Invalid property");
XmpNode new_node = new XmpNode (node.NamespaceURI, node.LocalName);
new_node.Type = XmpNodeType.Struct;
foreach (XmlNode attr in node.Attributes) {
if (attr.Is (XML_NS, LANG_URI))
new_node.AddQualifier (new XmpNode (XML_NS, LANG_URI, attr.InnerText));
}
foreach (XmlNode child in node.ChildNodes) {
if (child is XmlWhitespace || child is XmlComment)
continue;
ParsePropertyElement (new_node, child);
}
parent.AddChild (new_node);
}
示例4: ParseResourcePropertyElement
// 7.2.15 resourcePropertyElt
// start-element ( URI == propertyElementURIs, attributes == set ( idAttr? ) )
// ws* nodeElement ws*
// end-element()
private void ParseResourcePropertyElement (XmpNode parent, XmlNode node)
{
if (!node.IsPropertyElement ())
throw new CorruptFileException ("Invalid property");
XmpNode new_node = new XmpNode (node.NamespaceURI, node.LocalName);
foreach (XmlAttribute attr in node.Attributes) {
if (attr.Is (XML_NS, LANG_URI)) {
new_node.AddQualifier (new XmpNode (XML_NS, LANG_URI, attr.InnerText));
} else if (attr.Is (RDF_NS, ID_URI) || attr.In (XMLNS_NS)) {
continue;
}
throw new CorruptFileException (String.Format ("Invalid attribute: {0}", attr.OuterXml));
}
bool has_xml_children = false;
foreach (XmlNode child in node.ChildNodes) {
if (child is XmlWhitespace)
continue;
if (child is XmlText)
throw new CorruptFileException ("Can't have text here!");
has_xml_children = true;
ParseNodeElement (new_node, child);
}
if (!has_xml_children)
throw new CorruptFileException ("Missing children for resource property element");
parent.AddChild (new_node);
}