當前位置: 首頁>>代碼示例>>C#>>正文


C# XElement.GetPrefixOfNamespace方法代碼示例

本文整理匯總了C#中System.Xml.Linq.XElement.GetPrefixOfNamespace方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.GetPrefixOfNamespace方法的具體用法?C# XElement.GetPrefixOfNamespace怎麽用?C# XElement.GetPrefixOfNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.GetPrefixOfNamespace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AtomException

 /// <summary>
 /// Creates a new atom exception instance.
 /// </summary>
 /// <param name="message">The exception message.</param>
 /// <param name="xml">The XML element that cannot be parsed.</param>
 /// <param name="innerException">The inner exception.</param>
 public AtomException(string message, XElement xml, Exception innerException)
     : base(message, innerException)
 {
     this.elementPrefixName = xml.GetPrefixOfNamespace(xml.Name.NamespaceName);
     this.elementLocalName = xml.Name.LocalName;
     this.xml = xml.ToString(SaveOptions.None);
 }
開發者ID:alexbikfalvi,項目名稱:InetAnalytics,代碼行數:13,代碼來源:AtomException.cs

示例2: Atom

 /// <summary>
 /// Creates a new atom instance.
 /// </summary>
 /// <param name="xmlPrefix">The XML prefix.</param>
 /// <param name="xmlName">The XML name.</param>
 /// <param name="element">The XML element.</param>
 protected Atom(string xmlPrefix, string xmlName, XElement element)
 {
     // Check the XML element name.
     if (!element.HasName(xmlPrefix, xmlName))
     {
         bool b = element.HasName(xmlPrefix, xmlName);
         throw new AtomException("XML element name mismatch. Current name is \'{0}:{1}\'. Expected name is \'{2}:{3}\'".FormatWith(
             element.GetPrefixOfNamespace(element.Name.Namespace), element.Name.LocalName, xmlPrefix, xmlName), element);
     }
 }
開發者ID:alexbikfalvi,項目名稱:InetAnalytics,代碼行數:16,代碼來源:Atom.cs

示例3: ToString

		public static string ToString(this XamlContext ctx, XElement elem, XName name) {
			var sb = new StringBuilder();
			if (name.Namespace != elem.GetDefaultNamespace() &&
			    name.Namespace != elem.Name.Namespace &&
			    !string.IsNullOrEmpty(name.Namespace.NamespaceName)) {
				sb.Append(elem.GetPrefixOfNamespace(name.Namespace));
				sb.Append(':');
			}
			sb.Append(name.LocalName);
			return sb.ToString();
		}
開發者ID:manojdjoshi,項目名稱:dnSpy,代碼行數:11,代碼來源:XamlUtils.cs

示例4: AnalyzeElement

        void AnalyzeElement(XamlContext txt, XElement elem)
        {
            foreach (var i in elem.Attributes())
                if (i.Name.NamespaceName == "http://www.w3.org/2000/xmlns/")
                    txt.namespaces[i.Name.LocalName] = ParseXmlNs(i.Value, txt);
                else if (i.Name.LocalName == "xmlns")
                    txt.namespaces[""] = ParseXmlNs(i.Value, txt);

            XamlName name = XamlName.Parse(elem.Name, txt);
            name.Xmlns = elem.GetPrefixOfNamespace(name.Xmlns);
            if (name.TypeDef == null)
                Logger._Log("> Could not resolve '" + elem.Name.ToString() + "'!");
            else if (Assemblies.Contains(name.TypeDef.Module.Assembly))
            {
                IXmlLineInfo li = elem as IXmlLineInfo;
                string line = txt.lines[li.LineNumber - 1];
                int end = line.IndexOf(' ', li.LinePosition - 1);
                if (end == -1)
                    end = line.IndexOf('>', li.LinePosition - 1);
                string str = line.Substring(li.LinePosition - 1, end - li.LinePosition + 1);
                var r = new XamlNameReference() { Name = name };
                txt.refers.Add(new XamlRef()
                {
                    lineNum = li.LineNumber - 1,
                    index = li.LinePosition - 1,
                    length = end - li.LinePosition + 1,
                    name = name,
                    refer = r
                });
                ((name.TypeDef as IAnnotationProvider).Annotations[RenRef] as List<IReference>).Add(r);
            }

            foreach (var i in elem.Attributes())
                if (i.Name.NamespaceName != "http://www.w3.org/2000/xmlns/" &&
                    i.Name.LocalName != "xmlns")
                    AnalyzePropertyAttr(name.TypeDef, txt, i);

            foreach (var i in elem.Elements())
            {
                if (i.Name.LocalName.Contains("."))
                    AnalyzePropertyElem(name.TypeDef, txt, i);
                else
                    AnalyzeElement(txt, i);
            }
        }
開發者ID:n017,項目名稱:Confuser,代碼行數:45,代碼來源:NameAnalyzer.Xaml.cs

示例5: FillXmlns

		// unlike other XmlWriters the callers must set xmlns
		// attribute to overwrite prefix.
		void FillXmlns (XElement el, string prefix, XNamespace xns)
		{
			if (xns == XNamespace.Xmlns)
				// do nothing for xmlns attributes
				return;

			if (xns == XNamespace.None)
				if (el.GetPrefixOfNamespace (xns) != prefix)
					el.SetAttributeValue (prefix == String.Empty ? XNamespace.None.GetName ("xmlns") : XNamespace.Xmlns.GetName (prefix), xns.NamespaceName);
			else if (el.GetDefaultNamespace () != XNamespace.None)
				el.SetAttributeValue (XNamespace.None.GetName ("xmlns"), xns.NamespaceName);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:14,代碼來源:XNodeWriter.cs

示例6: AnalyzePropertyElem

        void AnalyzePropertyElem(TypeDefinition typeDef, XamlContext txt, XElement elem)
        {
            XamlPropertyName name = XamlPropertyName.Parse(typeDef, elem.Name, txt);
            name.Xmlns = elem.GetPrefixOfNamespace(name.Xmlns);
            var prop = ResolveProperty(name.TypeDef, name.PropertyName);
            if (prop != null && Assemblies.Contains(prop.DeclaringType.Module.Assembly))
            {
                IXmlLineInfo li = elem as IXmlLineInfo;
                string line = txt.lines[li.LineNumber - 1];
                int end = line.IndexOf('>', li.LinePosition - 1);
                string str = line.Substring(li.LinePosition - 1, end - li.LinePosition + 1);
                var r = new XamlPropertyNameReference() { Name = name };
                txt.refers.Add(new XamlRef()
                {
                    lineNum = li.LineNumber - 1,
                    index = li.LinePosition - 1,
                    length = end - li.LinePosition + 1,
                    name = name,
                    refer = r
                });
                ((prop as IAnnotationProvider).Annotations[RenRef] as List<IReference>).Add(r);
            }

            foreach (var i in elem.Elements())
            {
                if (i.Name.LocalName.Contains("."))
                    AnalyzePropertyElem(name.TypeDef, txt, i);
                else
                    AnalyzeElement(txt, i);
            }
        }
開發者ID:n017,項目名稱:Confuser,代碼行數:31,代碼來源:NameAnalyzer.Xaml.cs

示例7: CopyExtendedPropertiesToSsdlElement

        internal static void CopyExtendedPropertiesToSsdlElement(MetadataItem metadataItem, XContainer xContainer)
        {
            foreach (var extendedProperty in metadataItem.MetadataProperties.Where(mp => mp.PropertyKind == PropertyKind.Extended))
            {
                var exPropertyElement = extendedProperty.Value as XElement;
                if (exPropertyElement != null)
                {
                    // find the CopyToSSDL attribute - if it exists it can be in any EDMX namespace
                    var copyToSSDLAttribute = exPropertyElement.Attributes().FirstOrDefault(
                        attr => attr.Name.LocalName.Equals("CopyToSSDL", StringComparison.Ordinal)
                                && SchemaManager.GetEDMXNamespaceNames().Contains(attr.Name.NamespaceName));
                    if (copyToSSDLAttribute != null)
                    {
                        if ((bool?)copyToSSDLAttribute == true)
                        {
                            // CopyToSsdl is true, so let's copy this extended property
                            var exAttributeNamespace = copyToSSDLAttribute.Name.Namespace;
                            var newExPropertyElement = new XElement(exPropertyElement);
                            var newCopyToSsdlAttribute = newExPropertyElement.Attribute(exAttributeNamespace + "CopyToSSDL");
                            newCopyToSsdlAttribute.Remove();

                            var namespacePrefix = newExPropertyElement.GetPrefixOfNamespace(exAttributeNamespace);
                            if (namespacePrefix != null)
                            {
                                var xmlnsEdmxAttr = newExPropertyElement.Attribute(XNamespace.Xmlns + namespacePrefix);
                                if (xmlnsEdmxAttr != null)
                                {
                                    xmlnsEdmxAttr.Remove();
                                }
                            }
                            xContainer.Add(newExPropertyElement);
                        }
                    }
                }
            }
        }
開發者ID:Cireson,項目名稱:EntityFramework6,代碼行數:36,代碼來源:OutputGeneratorHelpers.cs

示例8: Rdf_NodeElementAttrs

        /// <summary>
        /// 7.2.7 propertyAttributeURIs
        /// anyURI - ( coreSyntaxTerms | rdf:Description | rdf:li | oldTerms )
        /// 7.2.11 nodeElement
        /// start-element ( URI == nodeElementURIs,
        /// attributes == set ( ( idAttr | nodeIdAttr | aboutAttr )?, propertyAttr* ) )
        /// propertyEltList
        /// end-element()
        /// Process the attribute list for an RDF node element.
        /// </summary>
        /// <remarks>
        /// 7.2.7 propertyAttributeURIs
        /// anyURI - ( coreSyntaxTerms | rdf:Description | rdf:li | oldTerms )
        /// 7.2.11 nodeElement
        /// start-element ( URI == nodeElementURIs,
        /// attributes == set ( ( idAttr | nodeIdAttr | aboutAttr )?, propertyAttr* ) )
        /// propertyEltList
        /// end-element()
        /// Process the attribute list for an RDF node element. A property attribute URI is
        /// anything other than an RDF term. The rdf:ID and rdf:nodeID attributes are simply ignored,
        /// as are rdf:about attributes on inner nodes.
        /// </remarks>
        /// <param name="xmp">the xmp metadata object that is generated</param>
        /// <param name="xmpParent">the parent xmp node</param>
        /// <param name="xmlNode">the currently processed XML node</param>
        /// <param name="isTopLevel">Flag if the node is a top-level node</param>
        /// <exception cref="XmpException">thrown on parsing errors</exception>
        private static void Rdf_NodeElementAttrs(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, bool isTopLevel)
        {
            // Used to detect attributes that are mutually exclusive.
            var exclusiveAttrs = 0;
            foreach(var attribute in xmlNode.Attributes())
            {
                // quick hack, ns declarations do not appear in C++
                // ignore "ID" without namespace
                var prefix = xmlNode.GetPrefixOfNamespace(attribute.Name.Namespace);
                if ("xmlns".Equals(prefix) || (prefix == null && "xmlns".Equals(attribute.Name)))
                {
                    continue;
                }
                var attrTerm = GetRdfTermKind(attribute);
                switch (attrTerm)
                {
                    case RdfTerm.Id:
                    case RdfTerm.NodeId:
                    case RdfTerm.About:
                    {
                        if (exclusiveAttrs > 0)
                        {
                            throw new XmpException("Mutally exclusive about, ID, nodeID attributes", XmpErrorCode.BadRdf);
                        }
                        exclusiveAttrs++;
                        if (isTopLevel && (attrTerm == RdfTerm.About))
                        {
                            // This is the rdf:about attribute on a top level node. Set
                            // the XMP tree name if
                            // it doesn't have a name yet. Make sure this name matches
                            // the XMP tree name.
                            if (!string.IsNullOrEmpty(xmpParent.Name))
                            {
                                if (!xmpParent.Name.Equals(attribute.Value))
                                {
                                    throw new XmpException("Mismatched top level rdf:about values", XmpErrorCode.BadXmp);
                                }
                            }
                            else
                            {
                                xmpParent.Name = attribute.Value;
                            }
                        }
                        break;
                    }

                    case RdfTerm.Other:
                    {
                        AddChildNode(xmp, xmpParent, attribute, attribute.Value, isTopLevel);
                        break;
                    }

                    default:
                    {
                        throw new XmpException("Invalid nodeElement attribute", XmpErrorCode.BadRdf);
                    }
                }
            }
        }
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:86,代碼來源:ParseRdf.cs

示例9: AcceptMoveFromRanges

        private static XElement AcceptMoveFromRanges(XElement document)
        {
            string wordProcessingNamespacePrefix = document.GetPrefixOfNamespace(W.w);

            // The following lists contain the elements that are between start/end elements.
            List<XElement> startElementTagsInMoveFromRange = new List<XElement>();
            List<XElement> endElementTagsInMoveFromRange = new List<XElement>();

            // Following are the elements that *may* be in a range that has both start and end
            // elements.
            Dictionary<string, PotentialInRangeElements> potentialDeletedElements =
                new Dictionary<string, PotentialInRangeElements>();

            foreach (var tag in DescendantAndSelfTags(document))
            {
                if (tag.Element.Name == W.moveFromRangeStart)
                {
                    string id = tag.Element.Attribute(W.id).Value;
                    potentialDeletedElements.Add(id, new PotentialInRangeElements());
                    continue;
                }
                if (tag.Element.Name == W.moveFromRangeEnd)
                {
                    string id = tag.Element.Attribute(W.id).Value;
                    if (potentialDeletedElements.ContainsKey(id))
                    {
                        startElementTagsInMoveFromRange.AddRange(
                            potentialDeletedElements[id].PotentialStartElementTagsInRange);
                        endElementTagsInMoveFromRange.AddRange(
                            potentialDeletedElements[id].PotentialEndElementTagsInRange);
                        potentialDeletedElements.Remove(id);
                    }
                    continue;
                }
                if (potentialDeletedElements.Count > 0)
                {
                    if (tag.TagType == TagTypeEnum.Element &&
                        (tag.Element.Name != W.moveFromRangeStart &&
                         tag.Element.Name != W.moveFromRangeEnd))
                    {
                        foreach (var id in potentialDeletedElements)
                            id.Value.PotentialStartElementTagsInRange.Add(tag.Element);
                        continue;
                    }
                    if (tag.TagType == TagTypeEnum.EmptyElement &&
                        (tag.Element.Name != W.moveFromRangeStart &&
                         tag.Element.Name != W.moveFromRangeEnd))
                    {
                        foreach (var id in potentialDeletedElements)
                        {
                            id.Value.PotentialStartElementTagsInRange.Add(tag.Element);
                            id.Value.PotentialEndElementTagsInRange.Add(tag.Element);
                        }
                        continue;
                    }
                    if (tag.TagType == TagTypeEnum.EndElement &&
                        (tag.Element.Name != W.moveFromRangeStart &&
                        tag.Element.Name != W.moveFromRangeEnd))
                    {
                        foreach (var id in potentialDeletedElements)
                            id.Value.PotentialEndElementTagsInRange.Add(tag.Element);
                        continue;
                    }
                }
            }
            var moveFromElementsToDelete = startElementTagsInMoveFromRange
                .Intersect(endElementTagsInMoveFromRange)
                .ToArray();
            if (moveFromElementsToDelete.Count() > 0)
                return (XElement)AcceptMoveFromRangesTransform(
                    document, moveFromElementsToDelete);
            return document;
        }
開發者ID:tamerboncooglu,項目名稱:ProjectCms,代碼行數:73,代碼來源:RevisionAccepter.cs

示例10: ElementGetPrefixOfNamespace

                /// <summary>
                /// Tests XElement.GetPrefixOfNamespace().
                /// </summary>
                /// <param name="contextValue"></param>
                /// <returns></returns>
                //[Variation(Desc = "ElementGetPrefixOfNamespace")]
                public void ElementGetPrefixOfNamespace()
                {
                    try
                    {
                        new XElement("foo").GetPrefixOfNamespace(null);
                        Validate.ExpectedThrow(typeof(ArgumentNullException));
                    }
                    catch (Exception ex)
                    {
                        Validate.Catch(ex, typeof(ArgumentNullException));
                    }

                    XNamespace ns = XNamespace.Get("http://test");
                    XElement e = new XElement(ns + "foo");

                    string prefix = e.GetPrefixOfNamespace(ns);
                    Validate.IsNull(prefix);

                    prefix = e.GetPrefixOfNamespace(XNamespace.Xmlns);
                    Validate.String(prefix, "xmlns");

                    prefix = e.GetPrefixOfNamespace(XNamespace.Xml);
                    Validate.String(prefix, "xml");

                    XElement parent = new XElement("parent", e);
                    parent.SetAttributeValue("{http://www.w3.org/2000/xmlns/}myns", ns);
                    prefix = e.GetPrefixOfNamespace(ns);
                    Validate.String(prefix, "myns");

                    e = XElement.Parse("<foo:element xmlns:foo='http://xxx'></foo:element>");
                    prefix = e.GetPrefixOfNamespace("http://xxx");
                    Validate.String(prefix, "foo");

                    e = XElement.Parse("<foo:element xmlns:foo='http://foo' xmlns:bar='http://bar'><bar:element /></foo:element>");
                    prefix = e.GetPrefixOfNamespace("http://foo");
                    Validate.String(prefix, "foo");
                    prefix = e.Element(XName.Get("{http://bar}element")).GetPrefixOfNamespace("http://foo");
                    Validate.String(prefix, "foo");
                    prefix = e.Element(XName.Get("{http://bar}element")).GetPrefixOfNamespace("http://bar");
                    Validate.String(prefix, "bar");
                }
開發者ID:johnhhm,項目名稱:corefx,代碼行數:47,代碼來源:SDMElement.cs

示例11: AddChildNode

 /// <summary>Adds a child node.</summary>
 /// <param name="xmp">the xmp metadata object that is generated</param>
 /// <param name="xmpParent">the parent xmp node</param>
 /// <param name="xmlNode">the currently processed XML node</param>
 /// <param name="value">Node value</param>
 /// <param name="isTopLevel">Flag if the node is a top-level node</param>
 /// <returns>Returns the newly created child node.</returns>
 /// <exception cref="XmpException">thrown on parsing errors</exception>
 private static XmpNode AddChildNode(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, string value, bool isTopLevel)
 {
     return AddChildNode(xmp, xmpParent, xmlNode.Name, xmlNode.GetPrefixOfNamespace(xmlNode.Name.Namespace), value, isTopLevel);
 }
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:12,代碼來源:ParseRdf.cs

示例12: Rdf_EmptyPropertyElement

        /// <summary>
        /// 7.2.21 emptyPropertyElt
        /// start-element ( URI == propertyElementURIs,
        /// attributes == set (
        /// idAttr?, ( resourceAttr | nodeIdAttr )?, propertyAttr* ) )
        /// end-element()
        /// <ns:Prop1/>  <!-- a simple property with an empty value -->
        /// <ns:Prop2 rdf:resource="http: *www.adobe.com/"/> <!-- a URI value -->
        /// <ns:Prop3 rdf:value="..." ns:Qual="..."/> <!-- a simple qualified property -->
        /// <ns:Prop4 ns:Field1="..." ns:Field2="..."/> <!-- a struct with simple fields -->
        /// An emptyPropertyElt is an element with no contained content, just a possibly empty set of
        /// attributes.
        /// </summary>
        /// <remarks>
        /// 7.2.21 emptyPropertyElt
        /// start-element ( URI == propertyElementURIs,
        /// attributes == set (
        /// idAttr?, ( resourceAttr | nodeIdAttr )?, propertyAttr* ) )
        /// end-element()
        /// <ns:Prop1/>  <!-- a simple property with an empty value -->
        /// <ns:Prop2 rdf:resource="http: *www.adobe.com/"/> <!-- a URI value -->
        /// <ns:Prop3 rdf:value="..." ns:Qual="..."/> <!-- a simple qualified property -->
        /// <ns:Prop4 ns:Field1="..." ns:Field2="..."/> <!-- a struct with simple fields -->
        /// An emptyPropertyElt is an element with no contained content, just a possibly empty set of
        /// attributes. An emptyPropertyElt can represent three special cases of simple XMP properties: a
        /// simple property with an empty value (ns:Prop1), a simple property whose value is a URI
        /// (ns:Prop2), or a simple property with simple qualifiers (ns:Prop3).
        /// An emptyPropertyElt can also represent an XMP struct whose fields are all simple and
        /// unqualified (ns:Prop4).
        /// It is an error to use both rdf:value and rdf:resource - that can lead to invalid  RDF in the
        /// verbose form written using a literalPropertyElt.
        /// The XMP mapping for an emptyPropertyElt is a bit different from generic RDF, partly for
        /// design reasons and partly for historical reasons. The XMP mapping rules are:
        /// <list type="bullet">
        /// <item> If there is an rdf:value attribute then this is a simple property
        /// with a text value.
        /// All other attributes are qualifiers.</item>
        /// <item> If there is an rdf:resource attribute then this is a simple property
        /// with a URI value.
        /// All other attributes are qualifiers.</item>
        /// <item> If there are no attributes other than xml:lang, rdf:ID, or rdf:nodeID
        /// then this is a simple
        /// property with an empty value.</item>
        /// <item> Otherwise this is a struct, the attributes other than xml:lang, rdf:ID,
        /// or rdf:nodeID are fields.</item>
        /// </list>
        /// </remarks>
        /// <param name="xmp">the xmp metadata object that is generated</param>
        /// <param name="xmpParent">the parent xmp node</param>
        /// <param name="xmlNode">the currently processed XML node</param>
        /// <param name="isTopLevel">Flag if the node is a top-level node</param>
        /// <exception cref="XmpException">thrown on parsing errors</exception>
        private static void Rdf_EmptyPropertyElement(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, bool isTopLevel)
        {
            var hasPropertyAttrs = false;
            var hasResourceAttr = false;
            var hasNodeIdAttr = false;
            var hasValueAttr = false;
            XAttribute valueNode = null;
            // ! Can come from rdf:value or rdf:resource.
            if (!(xmlNode.FirstNode == null))
            {
                throw new XmpException("Nested content not allowed with rdf:resource or property attributes", XmpErrorCode.BadRdf);
            }
            // First figure out what XMP this maps to and remember the XML node for a simple value.
            foreach (var attribute in xmlNode.Attributes())
            {
                var prefix = xmlNode.GetPrefixOfNamespace(attribute.Name.Namespace);
                if ("xmlns".Equals(prefix) || (prefix == null && "xmlns".Equals(attribute.Name)))
                {
                    continue;
                }
                var attrTerm = GetRdfTermKind(attribute);
                switch (attrTerm)
                {
                    case RdfTerm.Id:
                    {
                        // Nothing to do.
                        break;
                    }

                    case RdfTerm.Resource:
                    {
                        if (hasNodeIdAttr)
                        {
                            throw new XmpException("Empty property element can't have both rdf:resource and rdf:nodeID", XmpErrorCode.BadRdf);
                        }
                        if (hasValueAttr)
                        {
                            throw new XmpException("Empty property element can't have both rdf:value and rdf:resource", XmpErrorCode.BadXmp);
                        }
                        hasResourceAttr = true;
                        if (!hasValueAttr)
                        {
                            valueNode = attribute;
                        }
                        break;
                    }

                    case RdfTerm.NodeId:
//.........這裏部分代碼省略.........
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:101,代碼來源:ParseRdf.cs

示例13: Rdf_ParseTypeResourcePropertyElement

 /// <summary>
 /// 7.2.18 parseTypeResourcePropertyElt
 /// start-element ( URI == propertyElementURIs,
 /// attributes == set ( idAttr?, parseResource ) )
 /// propertyEltList
 /// end-element()
 /// Add a new struct node with a qualifier for the possible rdf:ID attribute.
 /// </summary>
 /// <remarks>
 /// 7.2.18 parseTypeResourcePropertyElt
 /// start-element ( URI == propertyElementURIs,
 /// attributes == set ( idAttr?, parseResource ) )
 /// propertyEltList
 /// end-element()
 /// Add a new struct node with a qualifier for the possible rdf:ID attribute.
 /// Then process the XML child nodes to get the struct fields.
 /// </remarks>
 /// <param name="xmp">the xmp metadata object that is generated</param>
 /// <param name="xmpParent">the parent xmp node</param>
 /// <param name="xmlNode">the currently processed XML node</param>
 /// <param name="isTopLevel">Flag if the node is a top-level node</param>
 /// <exception cref="XmpException">thrown on parsing errors</exception>
 private static void Rdf_ParseTypeResourcePropertyElement(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, bool isTopLevel)
 {
     var newStruct = AddChildNode(xmp, xmpParent, xmlNode, string.Empty, isTopLevel);
     newStruct.Options.IsStruct = true;
     foreach (var attribute in xmlNode.Attributes())
     {
         var prefix = xmlNode.GetPrefixOfNamespace(attribute.Name.Namespace);
         if ("xmlns".Equals(prefix) || (prefix == null && "xmlns".Equals(attribute.Name)))
         {
             continue;
         }
         var attrLocal = attribute.Name.LocalName;
         var attrNs = attribute.Name.NamespaceName;
         if (XmpConstants.XmlLang.Equals("xml:" + attribute.Name.LocalName))
         {
             AddQualifierNode(newStruct, XmpConstants.XmlLang, attribute.Value);
         }
         else
         {
             if (XmpConstants.NsRdf.Equals(attrNs) && ("ID".Equals(attrLocal) || "parseType".Equals(attrLocal)))
             {
                 continue;
             }
             // The caller ensured the value is "Resource".
             // Ignore all rdf:ID attributes.
             throw new XmpException("Invalid attribute for ParseTypeResource property element", XmpErrorCode.BadRdf);
         }
     }
     Rdf_PropertyElementList(xmp, newStruct, xmlNode, false);
     if (newStruct.HasValueChild)
     {
         FixupQualifiedNode(newStruct);
     }
 }
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:56,代碼來源:ParseRdf.cs

示例14: Rdf_LiteralPropertyElement

 /// <summary>
 /// 7.2.16 literalPropertyElt
 /// start-element ( URI == propertyElementURIs,
 /// attributes == set ( idAttr?, datatypeAttr?) )
 /// text()
 /// end-element()
 /// Add a leaf node with the text value and qualifiers for the attributes.
 /// </summary>
 /// <param name="xmp">the xmp metadata object that is generated</param>
 /// <param name="xmpParent">the parent xmp node</param>
 /// <param name="xmlNode">the currently processed XML node</param>
 /// <param name="isTopLevel">Flag if the node is a top-level node</param>
 /// <exception cref="XmpException">thrown on parsing errors</exception>
 private static void Rdf_LiteralPropertyElement(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, bool isTopLevel)
 {
     var newChild = AddChildNode(xmp, xmpParent, xmlNode, null, isTopLevel);
     foreach (var attribute in xmlNode.Attributes())
     {
         var prefix = xmlNode.GetPrefixOfNamespace(attribute.Name.Namespace);
         if ("xmlns".Equals(prefix) || (prefix == null && "xmlns".Equals(attribute.Name)))
         {
             continue;
         }
         var attrNs = attribute.Name.NamespaceName;
         var attrLocal = attribute.Name.LocalName;
         if (XmpConstants.XmlLang.Equals("xml:" + attribute.Name.LocalName))
         {
             AddQualifierNode(newChild, XmpConstants.XmlLang, attribute.Value);
         }
         else
         {
             if (XmpConstants.NsRdf.Equals(attrNs) && ("ID".Equals(attrLocal) || "datatype".Equals(attrLocal)))
             {
                 continue;
             }
             // Ignore all rdf:ID and rdf:datatype attributes.
             throw new XmpException("Invalid attribute for literal property element", XmpErrorCode.BadRdf);
         }
     }
     var textValue = string.Empty;
     foreach(var child in xmlNode.Nodes())
     {
         if (child.NodeType == System.Xml.XmlNodeType.Text)
         {
             textValue += ((XText)child).Value;
         }
         else
         {
             throw new XmpException("Invalid child of literal property element", XmpErrorCode.BadRdf);
         }
     }
     newChild.Value = textValue;
 }
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:53,代碼來源:ParseRdf.cs

示例15: Rdf_ResourcePropertyElement

        /// <summary>
        /// 7.2.15 resourcePropertyElt
        /// start-element ( URI == propertyElementURIs, attributes == set ( idAttr? ) )
        /// ws* nodeElement ws
        /// end-element()
        /// This handles structs using an rdf:Description node,
        /// arrays using rdf:Bag/Seq/Alt, and typedNodes.
        /// </summary>
        /// <remarks>
        /// 7.2.15 resourcePropertyElt
        /// start-element ( URI == propertyElementURIs, attributes == set ( idAttr? ) )
        /// ws* nodeElement ws
        /// end-element()
        /// This handles structs using an rdf:Description node,
        /// arrays using rdf:Bag/Seq/Alt, and typedNodes. It also catches and cleans up qualified
        /// properties written with rdf:Description and rdf:value.
        /// </remarks>
        /// <param name="xmp">the xmp metadata object that is generated</param>
        /// <param name="xmpParent">the parent xmp node</param>
        /// <param name="xmlNode">the currently processed XML node</param>
        /// <param name="isTopLevel">Flag if the node is a top-level node</param>
        /// <exception cref="XmpException">thrown on parsing errors</exception>
        private static void Rdf_ResourcePropertyElement(XmpMeta xmp, XmpNode xmpParent, XElement xmlNode, bool isTopLevel)
        {
            if (isTopLevel && "iX:changes".Equals(xmlNode.Name))
            {
                // Strip old "punchcard" chaff which has on the prefix "iX:".
                return;
            }
            var newCompound = AddChildNode(xmp, xmpParent, xmlNode, string.Empty, isTopLevel);
            // walk through the attributes
            foreach(var attribute in xmlNode.Attributes())
            {
                var prefix = xmlNode.GetPrefixOfNamespace(attribute.Name.Namespace);
                if ("xmlns".Equals(prefix) || (prefix == null && "xmlns".Equals(attribute.Name)))
                {
                    continue;
                }

                var attrLocal = attribute.Name.LocalName;
                var attrNs = attribute.Name.NamespaceName;
                if (XmpConstants.XmlLang.Equals("xml:" + attribute.Name.LocalName))
                {
                    AddQualifierNode(newCompound, XmpConstants.XmlLang, attribute.Value);
                }
                else
                {
                    if ("ID".Equals(attrLocal) && XmpConstants.NsRdf.Equals(attrNs))
                    {
                        continue;
                    }
                    // Ignore all rdf:ID attributes.
                    throw new XmpException("Invalid attribute for resource property element", XmpErrorCode.BadRdf);
                }
            }
            // walk through the children
            var found = false;
            foreach(var currChild in xmlNode.Nodes())
            {
                if (!IsWhitespaceNode(currChild))
                {
                    if (currChild.NodeType == System.Xml.XmlNodeType.Element && !found)
                    {
                        var currChildElem = (XElement)currChild;
                        var isRdf = XmpConstants.NsRdf.Equals(currChildElem.Name.NamespaceName);
                        var childLocal = currChildElem.Name.LocalName;
                        if (isRdf && "Bag".Equals(childLocal))
                        {
                            newCompound.Options.IsArray = true;
                        }
                        else if (isRdf && "Seq".Equals(childLocal))
                        {
                            newCompound.Options.IsArray = true;
                            newCompound.Options.IsArrayOrdered = true;
                        }
                        else if (isRdf && "Alt".Equals(childLocal))
                        {
                            newCompound.Options.IsArray = true;
                            newCompound.Options.IsArrayOrdered = true;
                            newCompound.Options.IsArrayAlternate = true;
                        }
                        else
                        {
                            newCompound.Options.IsStruct = true;
                            if (!isRdf && !"Description".Equals(childLocal))
                            {
                                var typeName = currChildElem.Name.NamespaceName;
                                if (typeName == null)
                                {
                                    throw new XmpException("All XML elements must be in a namespace", XmpErrorCode.BadXmp);
                                }
                                typeName += ':' + childLocal;
                                AddQualifierNode(newCompound, "rdf:type", typeName);
                            }
                        }
                        Rdf_NodeElement(xmp, newCompound, currChildElem, false);
                        if (newCompound.HasValueChild)
                            FixupQualifiedNode(newCompound);
                        else if (newCompound.Options.IsArrayAlternate)
                            XmpNodeUtils.DetectAltText(newCompound);
//.........這裏部分代碼省略.........
開發者ID:tehkyle,項目名稱:xmp-core-dotnet,代碼行數:101,代碼來源:ParseRdf.cs


注:本文中的System.Xml.Linq.XElement.GetPrefixOfNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。