Пример #1
0
 /// <summary>
 /// Constructor with content
 /// </summary>
 /// <param name="_root">Content root node</param>
 public MeiDocument(MeiElement _root) : base(_root)
 {
     if (_root.Attribute("meiversion") != null)
     {
         this.MeiVersion = _root.Attribute("meiversion").Value;
     }
 }
Пример #2
0
 /// <summary>
 /// Constructor with xml declaration and content
 /// Use to create an MeiDocument from an existing parsed XDocument
 /// </summary>
 /// <param name="_xmldecl">Xml declaration</param>
 /// <param name="_root">Content root node</param>
 public MeiDocument(XDeclaration _xmldecl, MeiElement _root) : base(_xmldecl, _root)
 {
     if (_root.Attribute("meiversion") != null)
     {
         this.MeiVersion = _root.Attribute("meiversion").Value;
     }
 }
Пример #3
0
        /// <summary>
        /// Creates an MeiDocument with content, declarations, and processing instructions
        /// </summary>
        /// <param name="_xmlDecl">Xml declaration of imported document</param>
        /// <param name="_root">Transfomed Mei tree</param>
        /// <param name="_schemaLoc">Schema location</param>
        /// <param name="_pIs">Other processing instructions</param>
        private static MeiDocument CreateMeiDocument(XDeclaration _xmlDecl, MeiElement _root, string _schemaLoc, IEnumerable <XProcessingInstruction> _pIs, string _baseUri)
        {
            MeiDocument meiDoc = new MeiDocument(_xmlDecl, _root, _schemaLoc, _baseUri);

            meiDoc.Root.AddBeforeSelf(_pIs);

            return(meiDoc);
        }
Пример #4
0
        /// <summary>
        /// Constructor with xml declaration, content, and schema location
        /// Use to create an MeiDocument from an existing parsed XDocument
        /// </summary>
        /// <param name="_xmldecl">Xml declaration</param>
        /// <param name="_root">Content root node</param>
        /// <param name="_schemaLocation">Location of MEI schema to link</param>
        public MeiDocument(XDeclaration _xmldecl, MeiElement _root, string _schemaLocation) : base(_xmldecl, _root)
        {
            this.SchemaLocation = _schemaLocation;
            WriteSchemaProcessingInstructions();

            if (_root.Attribute("meiversion") != null)
            {
                this.MeiVersion = _root.Attribute("meiversion").Value;
            }
        }
Пример #5
0
        /// <summary>
        /// Imports an Xml file and loads the content into Mei
        /// </summary>
        /// <param name="_filePath">Path of Xml file to import</param>
        public static MeiDocument ImportDocument(string _filePath)
        {
            XDocument    doc      = XDocument.Load(_filePath, LoadOptions.SetBaseUri);
            XDeclaration xml_decl = doc.Declaration;

            //Enum for processing instructions
            IEnumerable <XProcessingInstruction> pIs = Enumerable.Empty <XProcessingInstruction>();

            //ReadProcessingInstructions()
            string schemaLocation = ReadProcessingInstructions(doc, out pIs);

            XElement   root          = doc.Root;
            MeiElement convertedRoot = XmlToMei(root);

            return(CreateMeiDocument(xml_decl, convertedRoot, schemaLocation, pIs, doc.BaseUri));
        }
Пример #6
0
 /// <summary>
 /// Remove the specified element as a child from this element.
 /// Elements are compared by memory address. It is the responsibility
 /// of the caller to free elements after they have been removed.
 /// </summary>
 /// <param name="_child">Child to be removed</param>
 public void RemoveChild(MeiElement _child)
 {
     _child.Remove();
 }