Ejemplo n.º 1
0
        public XmlDocument GetXmlDocument()
        {
            WXMLModelWriterSettings settings = new WXMLModelWriterSettings();
            WXMLDocumentSet         set      = GetWXMLDocumentSet(settings);

            return(set[0].Document);
        }
Ejemplo n.º 2
0
        internal static WXMLDocumentSet Generate(WXMLModel schema, WXMLModelWriterSettings settings)
        {
            WXMLModelWriter generator = new WXMLModelWriter(schema, settings);

            generator.GenerateXmlDocumentInternal();

            return(generator._wxmlDocumentSet);
        }
Ejemplo n.º 3
0
 internal WXMLModelWriter(WXMLModel model, WXMLModelWriterSettings settings)
 {
     _model     = model;
     _nametable = new NameTable();
     _nsMgr     = new XmlNamespaceManager(_nametable);
     _nsMgr.AddNamespace(WXMLModel.NS_PREFIX, WXMLModel.NS_URI);
     _wxmlDocumentSet = new WXMLDocumentSet();
     _settings        = settings;
 }
Ejemplo n.º 4
0
        private void FillImports()
        {
            if (_model.Includes.Count == 0)
            {
                return;
            }
            XmlNode importsNode = CreateElement("Includes");

            _ormXmlDocumentMain.DocumentElement.AppendChild(importsNode);
            foreach (WXMLModel objectsDef in _model.Includes)
            {
                WXMLModelWriterSettings settings = (WXMLModelWriterSettings)_settings.Clone();
                //settings.DefaultMainFileName = _settings.DefaultIncludeFileName + _ormObjectsDef.Includes.IndexOf(objectsDef);
                WXMLDocumentSet set = Generate(objectsDef, _settings);
                _wxmlDocumentSet.AddRange(set);
                foreach (WXMLDocument ormXmlDocument in set)
                {
                    if ((_settings.IncludeBehaviour & IncludeGenerationBehaviour.Inline) ==
                        IncludeGenerationBehaviour.Inline)
                    {
                        XmlNode importedSchemaNode =
                            _ormXmlDocumentMain.ImportNode(ormXmlDocument.Document.DocumentElement, true);
                        importsNode.AppendChild(importedSchemaNode);
                    }
                    else
                    {
                        XmlElement includeElement =
                            _ormXmlDocumentMain.CreateElement("xi", "include", "http://www.w3.org/2001/XInclude");
                        includeElement.SetAttribute("parse", "xml");

                        string fileName = GetIncludeFileName(_model, objectsDef, settings);

                        includeElement.SetAttribute("href", fileName);
                        importsNode.AppendChild(includeElement);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private static string GetIncludeFileName(WXMLModel model, WXMLModel model2include, WXMLModelWriterSettings settings)
 {
     if (string.IsNullOrEmpty(model2include.FileName))
     {
         string filename =
             settings.IncludeFileNamePattern.Replace("%MAIN_FILENAME%", GetFilename(model, settings)).
             Replace(
                 "%INCLUDE_NAME%", GetFilename(model2include, settings)) +
             model.Includes.IndexOf(model2include);
         return
             ((((settings.IncludeBehaviour & IncludeGenerationBehaviour.PlaceInFolder) ==
                IncludeGenerationBehaviour.PlaceInFolder)
                  ? settings.IncludeFolderName + System.IO.Path.DirectorySeparatorChar
                  : string.Empty) + filename);
     }
     else
     {
         return(model2include.FileName);
     }
 }
Ejemplo n.º 6
0
 private static string GetFilename(WXMLModel model, WXMLModelWriterSettings settings)
 {
     return(string.IsNullOrEmpty(model.FileName)
                ? settings.DefaultMainFileName
                : model.FileName);
 }
Ejemplo n.º 7
0
        public WXMLDocumentSet GetWXMLDocumentSet(WXMLModelWriterSettings settings)
        {
            CreateSystemComments();

            return(WXMLModelWriter.Generate(this, settings));
        }