コード例 #1
0
 public static void SetXsiTypeAttr(InternalPrintTicket pt,
                                   XmlElement valueElement,
                                   string xsiType)
 {
     // the attribute is in the format like: xsi:type="xsd:integer"
     valueElement.SetAttribute("type",
                               PrintSchemaNamespaces.xsi,
                               XmlDocQName.GetQName(pt.XmlDoc, PrintSchemaNamespaces.xsd, xsiType));
 }
コード例 #2
0
        /// <summary>
        /// Gets the feature XML element in the PrintTicket for the specified feature name.
        /// Null is returned if the feature XML element can't be found.
        /// </summary>
        public static XmlElement GetSchemaElementWithNameAttr(InternalPrintTicket pt,
                                                              XmlElement parent,
                                                              string schemaTag,
                                                              string nameAttrWanted)
        {
            XmlElement elementMatched = null;
            bool       foundMatch     = false;

            // Now go through each child element to find the matching schema element
            XmlNode child = parent.FirstChild;

            // It's recommended that traversing the node in forward-only movement by using NextSibling
            // is best for XmlDocument performance. This is because the list is not double-linked.
            while (child != null)
            {
                // We are looking for a standard namespace schema element node
                if ((child.NodeType != XmlNodeType.Element) ||
                    (child.LocalName != schemaTag) ||
                    (child.NamespaceURI != PrintSchemaNamespaces.Framework))
                {
                    child = child.NextSibling;
                    continue;
                }

                if (nameAttrWanted == null)
                {
                    // Caller is not looking for a "name" attribute value match, so we already
                    // found the wanted schema element.
                    foundMatch = true;
                }
                else
                {
                    // We need to match the "name" attribute value.
                    string childName = ((XmlElement)child).GetAttribute(
                        PrintSchemaTags.Framework.NameAttr,
                        PrintSchemaNamespaces.FrameworkAttrForXmlDOM);

                    if ((childName != null) &&
                        (childName.Length != 0) &&
                        (XmlDocQName.GetURI(pt.XmlDoc, childName) == PrintSchemaNamespaces.StandardKeywordSet) &&
                        (XmlDocQName.GetLocalName(childName) == nameAttrWanted))
                    {
                        foundMatch = true;
                    }
                }

                if (foundMatch)
                {
                    elementMatched = (XmlElement)child;
                    break;
                }

                child = child.NextSibling;
            }

            return(elementMatched);
        }
コード例 #3
0
        public static XmlElement AddSchemaElementWithNameAttr(InternalPrintTicket pt,
                                                              XmlElement parent,
                                                              string schemaTag,
                                                              string nameAttr)
        {
            string prefix = pt.XmlDoc.DocumentElement.GetPrefixOfNamespace(PrintSchemaNamespaces.Framework);

            XmlElement newNode = pt.XmlDoc.CreateElement(prefix, schemaTag, PrintSchemaNamespaces.Framework);

            if (nameAttr != null)
            {
                newNode.SetAttribute(PrintSchemaTags.Framework.NameAttr,
                                     PrintSchemaNamespaces.FrameworkAttrForXmlDOM,
                                     XmlDocQName.GetQName(pt.XmlDoc, PrintSchemaNamespaces.StandardKeywordSet, nameAttr));
            }

            return((XmlElement)parent.AppendChild(newNode));
        }