示例#1
0
        private string GetSchemaSourceCode(XmlSchema schema, PostProcessingOptions processingOptions)
        {
            XmlDocument schemaSource;

            if (!_schemaSources.TryGetValue(schema, out schemaSource))
            {
                return(String.Empty);
            }

            var namespaceManager = _namespaceManagers[schema];

            return(PostProcess(namespaceManager, schemaSource, processingOptions));
        }
示例#2
0
        private string InternalGetSourceCode(XmlSchemaObject obj, PostProcessingOptions processingOptions)
        {
            var schema = obj as XmlSchema;

            if (schema != null)
            {
                return(GetSchemaSourceCode(schema, processingOptions));
            }

            var annotated = obj as XmlSchemaAnnotated;

            return(annotated == null
                       ? String.Empty
                       : GetObjectSourceCode(annotated, processingOptions));
        }
示例#3
0
        private string GetObjectSourceCode(XmlSchemaAnnotated annotated, PostProcessingOptions processingOptions)
        {
            var schema = annotated.GetSchema();

            if (schema == null)
            {
                return(String.Empty);
            }

            XmlDocument schemaSource;

            if (!_schemaSources.TryGetValue(schema, out schemaSource))
            {
                return(String.Empty);
            }

            var namespaceManager = _namespaceManagers[schema];

            var lookupId = _lookupIds[annotated];
            var source   = GetObjectSourceCode(schemaSource, namespaceManager, lookupId, processingOptions);

            return(source);
        }
        private string InternalGetSourceCode(XmlSchemaObject obj, PostProcessingOptions processingOptions)
        {
            var schema = obj as XmlSchema;
            if (schema != null)
                return GetSchemaSourceCode(schema, processingOptions);

            var annotated = obj as XmlSchemaAnnotated;
            return annotated == null
                       ? string.Empty
                       : GetObjectSourceCode(annotated, processingOptions);
        }
        private string GetSchemaSourceCode(XmlSchema schema, PostProcessingOptions processingOptions)
        {
            XmlDocument schemaSource;
            if (!_schemaSources.TryGetValue(schema, out schemaSource))
                return string.Empty;

            var namespaceManager = _namespaceManagers[schema];

            return PostProcess(namespaceManager, schemaSource, processingOptions);
        }
        private string GetObjectSourceCode(XmlSchemaAnnotated annotated, PostProcessingOptions processingOptions)
        {
            var schema = annotated.GetSchema();
            if (schema == null)
                return string.Empty;

            XmlDocument schemaSource;
            if (!_schemaSources.TryGetValue(schema, out schemaSource))
                return string.Empty;

            var namespaceManager = _namespaceManagers[schema];

            var lookupId = _lookupIds[annotated];
            var source = GetObjectSourceCode(schemaSource, namespaceManager, lookupId, processingOptions);
            return source;
        }
        private static string PostProcess(XmlNamespaceManager namespaceManager, XmlNode node, PostProcessingOptions processingOptions)
        {
            var removeAnnotations = (processingOptions & PostProcessingOptions.RemoveAnnotations) == PostProcessingOptions.RemoveAnnotations;
            var collapseElements = (processingOptions & PostProcessingOptions.CollapseElements) == PostProcessingOptions.CollapseElements;
            var collapseAttributes = (processingOptions & PostProcessingOptions.CollapseAttributes) == PostProcessingOptions.CollapseAttributes;
            var format = (processingOptions & PostProcessingOptions.Format) == PostProcessingOptions.Format;

            // Create new document to perform post processing.
            var objSource = new XmlDocument();
            objSource.LoadXml(node.OuterXml);

            RemoveLookupIds(objSource, namespaceManager);

            if (removeAnnotations)
                RemoveAnnotations(objSource, namespaceManager);

            if (collapseElements)
                CollapseElements(objSource, namespaceManager, "//xs:element|//xs:any");

            if (collapseAttributes)
                CollapseElements(objSource, namespaceManager, "//xs:attribute|//xs:anyAttribute");

            return format
                    ? FormatXml(objSource)
                    : objSource.OuterXml;
        }
 private static string GetObjectSourceCode(XmlNode schemaSource, XmlNamespaceManager namespaceManager, string objLookupId, PostProcessingOptions processingOptions)
 {
     var node = schemaSource.SelectSingleNode(string.Format("//*[@temp:lookupId='{0}']", objLookupId), namespaceManager);
     return PostProcess(namespaceManager, node, processingOptions);
 }
示例#9
0
        private static string PostProcess(XmlNamespaceManager namespaceManager, XmlNode node, PostProcessingOptions processingOptions)
        {
            var removeAnnotations  = (processingOptions & PostProcessingOptions.RemoveAnnotations) == PostProcessingOptions.RemoveAnnotations;
            var collapseElements   = (processingOptions & PostProcessingOptions.CollapseElements) == PostProcessingOptions.CollapseElements;
            var collapseAttributes = (processingOptions & PostProcessingOptions.CollapseAttributes) == PostProcessingOptions.CollapseAttributes;
            var format             = (processingOptions & PostProcessingOptions.Format) == PostProcessingOptions.Format;

            // Create new document to perform post processing.
            var objSource = new XmlDocument();

            objSource.LoadXml(node.OuterXml);

            RemoveLookupIds(objSource, namespaceManager);

            if (removeAnnotations)
            {
                RemoveAnnotations(objSource, namespaceManager);
            }

            if (collapseElements)
            {
                CollapseElements(objSource, namespaceManager, "//xs:element|//xs:any");
            }

            if (collapseAttributes)
            {
                CollapseElements(objSource, namespaceManager, "//xs:attribute|//xs:anyAttribute");
            }

            return(format
                    ? FormatXml(objSource)
                    : objSource.OuterXml);
        }
示例#10
0
        private static string GetObjectSourceCode(XmlNode schemaSource, XmlNamespaceManager namespaceManager, string objLookupId, PostProcessingOptions processingOptions)
        {
            var node = schemaSource.SelectSingleNode(String.Format("//*[@temp:lookupId='{0}']", objLookupId), namespaceManager);

            return(PostProcess(namespaceManager, node, processingOptions));
        }