static int cellSize = 10;//网格大小 10m /// <summary> /// 打开并加载参数xml文档 /// 将参数值存储到参数list中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void openFileButton_Click(object sender, EventArgs e) { try { XmlDocument paraxml = new XmlDocument(); OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "(*.xml;)|*.xml"; fd.InitialDirectory = Application.StartupPath + @""; fd.ShowReadOnly = true; DialogResult result = fd.ShowDialog(); if (result == DialogResult.OK) { paraxml.Load(fd.FileName); } openFileButton.Enabled = false; NameTable xmt = new NameTable(); XmlNamespaceManager xnm = new XmlNamespaceManager(xmt); xnm.AddNamespace(string.Empty, ""); XmlNodeList xnlist = paraxml.SelectNodes("/ParameterML/ParameterList/Parameter/value"); foreach (XmlNode xn in xnlist) { paraList.Add(Convert.ToDouble(xn.InnerText)); } calculateButton.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//[Variation(Desc = "v3 - XmlDataSourceResolver(XmlNameTable = valid) check back")] public void v3() { NameTable NT = new NameTable(); XmlSchemaSet sc = new XmlSchemaSet(NT); Assert.Equal(sc.NameTable, NT); return; }
static Schema() { NameTable nt = new NameTable(); nt.Add(Namespace.Xs.NamespaceName); NamespaceManager = new XmlNamespaceManager(nt); Swidtag = XDocument.Load(XmlReader.Create(new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("FearTheCowboy.Iso19770.Properties.Swidtag.xsd.xml")), new XmlReaderSettings())); NamespaceManager.AddNamespace("xs", Namespace.Xs.NamespaceName); }
public string RenderComponentFieldAsBBCode(string fieldExpression, int fieldIndex, bool outputImages) { BuiltInFunctions functions = new BuiltInFunctions(_engine, _package); string output = functions.RenderComponentField(fieldExpression, fieldIndex); StringReader sr = new StringReader(output); NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("tcdl", Tridion.ContentManager.Templating.TcdlTags.TcdlNamespace); XmlParserContext parserContext = new XmlParserContext(null, nsmgr, null, XmlSpace.None); XmlReader xmlReader = XmlReader.Create(sr, new XmlReaderSettings(), parserContext); XslCompiledTransform transform = new XslCompiledTransform(true); using (Stream xsltStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Tridion.ContentManager.Templating.Expression.NetbiscuitsFunctions.XhtmlToBBCode.xslt")) { using (XmlReader xsltReader = XmlReader.Create(xsltStream)) { transform.Load(xsltReader); } } StringWriter resultWriter = new StringWriter(); XsltArgumentList argumentList = new XsltArgumentList(); argumentList.AddParam("IncludeImages", String.Empty, outputImages); transform.Transform(xmlReader, argumentList, resultWriter); return resultWriter.ToString(); }
private void Init() { try { string basepath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "").Replace("/", @"\"); basepath = System.IO.Path.GetDirectoryName(basepath) + @"\"; GameCatalogSerializer gcs = new GameCatalogSerializer(); XmlDocument doc = gcs.Serialize(games); System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator(); System.Xml.Xsl.XslTransform xt = new System.Xml.Xsl.XslTransform(); System.Xml.XmlResolver res = new System.Xml.XmlUrlResolver(); System.IO.StringWriter writer = new System.IO.StringWriter(); System.Xml.Xsl.XsltArgumentList args = new System.Xml.Xsl.XsltArgumentList(); System.Xml.XmlNameTable xnt = new System.Xml.NameTable(); System.Xml.XmlReader xslt = new System.Xml.XmlTextReader(new System.IO.StreamReader(basepath + "GameList.xslt"), xnt); xt.Load(xslt, res, new System.Security.Policy.Evidence()); xt.Transform(nav, args, writer, res); string html = writer.ToString(); WriteHTML(html); } catch (Exception ex) { string error = "There was an error generating HTML"; Exception xe = ex; while (xe != null) { error += "<p><b>" + xe.Message + "</b><br><pre>" + xe.StackTrace + "</pre></p>\r\n"; } WriteHTML(error); } }
public TestRunSummary Execute() { string vsFolder = Environment.Is64BitProcess ? @"%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE" : @"%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE"; var nunitConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), Environment.ExpandEnvironmentVariables(vsFolder + @"\MsTest.exe")); string resultsFilePath = Path.Combine(inputProjectDriver.DeploymentFolder, "mstest-result.trx"); var provessHelper = new ProcessHelper(); provessHelper.RunProcess(nunitConsolePath, "\"/testcontainer:{0}\" \"/resultsfile:{1}\"", inputProjectDriver.CompiledAssemblyPath, resultsFilePath); XDocument logFile = XDocument.Load(resultsFilePath); TestRunSummary summary = new TestRunSummary(); XmlNameTable nameTable = new NameTable(); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable); namespaceManager.AddNamespace("mstest", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"); var summaryElement = logFile.XPathSelectElement("//mstest:ResultSummary/mstest:Counters", namespaceManager); if (summaryElement != null) { summary.Total = int.Parse(summaryElement.Attribute("total").Value); summary.Succeeded = int.Parse(summaryElement.Attribute("passed").Value); summary.Failed = int.Parse(summaryElement.Attribute("failed").Value); summary.Pending = int.Parse(summaryElement.Attribute("inconclusive").Value); summary.Ignored = 0; // mstest does not support ignored in the report } testExecutionResult.LastExecutionSummary = summary; return summary; }
public void FortifyStrings_ContainsCorrectStrings() { var nameTable = new NameTable(); var uut = new FortifyStrings(nameTable); Assert.AreSame(nameTable.Add("Issue"), uut.Issue); Assert.AreSame(nameTable.Add("iid"), uut.Iid); Assert.AreSame(nameTable.Add("ruleID"), uut.RuleId); Assert.AreSame(nameTable.Add("Category"), uut.Category); Assert.AreSame(nameTable.Add("Folder"), uut.Folder); Assert.AreSame(nameTable.Add("Kingdom"), uut.Kingdom); Assert.AreSame(nameTable.Add("Abstract"), uut.Abstract); Assert.AreSame(nameTable.Add("AbstractCustom"), uut.AbstractCustom); Assert.AreSame(nameTable.Add("Friority"), uut.Friority); Assert.AreSame(nameTable.Add("Tag"), uut.Tag); Assert.AreSame(nameTable.Add("Comment"), uut.Comment); Assert.AreSame(nameTable.Add("Primary"), uut.Primary); Assert.AreSame(nameTable.Add("Source"), uut.Source); Assert.AreSame(nameTable.Add("TraceDiagramPath"), uut.TraceDiagramPath); Assert.AreSame(nameTable.Add("ExternalCategory"), uut.ExternalCategory); Assert.AreSame(nameTable.Add("type"), uut.Type); Assert.AreSame(nameTable.Add("FileName"), uut.FileName); Assert.AreSame(nameTable.Add("FilePath"), uut.FilePath); Assert.AreSame(nameTable.Add("LineStart"), uut.LineStart); Assert.AreSame(nameTable.Add("Snippet"), uut.Snippet); Assert.AreSame(nameTable.Add("SnippetLine"), uut.SnippetLine); Assert.AreSame(nameTable.Add("TargetFunction"), uut.TargetFunction); }
/// <include file='doc\XmlPatch.uex' path='docs/doc[@for="XmlPatch.Patch3"]/*' /> /// <summary> /// Reads the XDL diffgram from the diffgramFileName and modifies the original XML document /// sourceDoc according to the changes described in the diffgram. /// </summary> /// <param name="sourceDoc">The original xml document</param> /// <param name="diffgramFileName">XmlReader for the XDL diffgram.</param> public void Patch( string sourceFile, Stream outputStream, XmlReader diffgram ) { if ( sourceFile == null ) throw new ArgumentNullException( "sourceFile" ); if ( outputStream == null ) throw new ArgumentNullException( "outputStream" ); if ( diffgram == null ) throw new ArgumentException( "diffgram" ); XmlDocument diffDoc = new XmlDocument(); diffDoc.Load( diffgram ); // patch fragment if ( diffDoc.DocumentElement.GetAttribute( "fragments" ) == "yes" ) { NameTable nt = new NameTable(); XmlTextReader tr = new XmlTextReader( new FileStream( sourceFile, FileMode.Open, FileAccess.Read ), XmlNodeType.Element, new XmlParserContext( nt, new XmlNamespaceManager( nt ), string.Empty, XmlSpace.Default ) ); Patch( tr, outputStream, diffDoc ); } // patch document else { Patch ( new XmlTextReader( sourceFile ), outputStream, diffDoc ); } }
public XmlEditorNavigator(XmlEditorNavigator navigator ) { //StreamUtil.WriteText("I:\\debug.txt","进到 构造函数XmlEditorNavigator(navigator)里\r\n"); this.m_navigatorState = new NavigatorState(navigator.m_navigatorState); this.m_nametable = (NameTable)navigator.NameTable; }
private XmlNamespaceManager AddNameSpaceTable(string parametersetname, XmlDocument xDoc, Hashtable namespacetable) { XmlNamespaceManager manager; if (parametersetname.Equals("Xml")) { XmlNameTable nameTable = new NameTable(); manager = new XmlNamespaceManager(nameTable); } else { manager = new XmlNamespaceManager(xDoc.NameTable); } foreach (DictionaryEntry entry in namespacetable) { try { string prefix = entry.Key.ToString(); manager.AddNamespace(prefix, entry.Value.ToString()); } catch (NullReferenceException) { InvalidOperationException exception = new InvalidOperationException(StringUtil.Format(UtilityCommonStrings.SearchXMLPrefixNullError, new object[0])); ErrorRecord errorRecord = new ErrorRecord(exception, "PrefixError", ErrorCategory.InvalidOperation, namespacetable); base.WriteError(errorRecord); } catch (ArgumentNullException) { InvalidOperationException exception2 = new InvalidOperationException(StringUtil.Format(UtilityCommonStrings.SearchXMLPrefixNullError, new object[0])); ErrorRecord record2 = new ErrorRecord(exception2, "PrefixError", ErrorCategory.InvalidOperation, namespacetable); base.WriteError(record2); } } return manager; }
/// <summary> /// Validates XML definition against given XSD schema. /// </summary> /// <param name="xmlFileName">Full path to the XML file on file system.</param> /// <param name="schemaContent">XSD schema.</param> /// <param name="schemaName">XSD schema name.</param> public void Validate(string xmlFileName, string schemaContent, string schemaName) { _xmlFileName = xmlFileName; var xmlDoc = GetUpdatedXml(xmlFileName, schemaName); var xmlSchemaSet = GetXmlSchema(schemaContent, schemaName); var nt = new NameTable(); var nsmgr = new XmlNamespaceManager(nt); var context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); var settings = new XmlReaderSettings(); settings.ValidationType = ValidationType.Schema; settings.Schemas.Add(xmlSchemaSet); settings.ValidationEventHandler += ValidationCallbackOne; using (var xmlr = new XmlTextReader(xmlDoc.OuterXml, XmlNodeType.Document, context)) { using (var reader = XmlReader.Create(xmlr, settings)) { while (reader.Read()) { var val = reader.Value; } } } }
public static void WDDeleteHiddenText(string docName) { // Given a document name, delete all the hidden text. const string wordmlNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; using (WordprocessingDocument wdDoc = WordprocessingDocument.Open(docName, true)) { // Manage namespaces to perform XPath queries. NameTable nt = new NameTable(); XmlNamespaceManager nsManager = new XmlNamespaceManager(nt); nsManager.AddNamespace("w", wordmlNamespace); // Get the document part from the package. // Load the XML in the document part into an XmlDocument instance. XmlDocument xdoc = new XmlDocument(nt); xdoc.Load(wdDoc.MainDocumentPart.GetStream()); XmlNodeList hiddenNodes = xdoc.SelectNodes("//w:vanish", nsManager); foreach (System.Xml.XmlNode hiddenNode in hiddenNodes) { XmlNode topNode = hiddenNode.ParentNode.ParentNode; XmlNode topParentNode = topNode.ParentNode; topParentNode.RemoveChild(topNode); if (!(topParentNode.HasChildNodes)) { topParentNode.ParentNode.RemoveChild(topParentNode); } } // Save the document XML back to its document part. xdoc.Save(wdDoc.MainDocumentPart.GetStream(FileMode.Create, FileAccess.Write)); } }
void Initialize () { var nt = new NameTable (); initial_reader = new NonInteractiveStateXmlReader (String.Empty, nt, ReadState.Initial); eof_reader = new NonInteractiveStateXmlReader (String.Empty, nt, ReadState.EndOfFile); xml_reader = initial_reader; }
private static string ParseWordDoc(Stream file) { const string wordmlNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; System.Text.StringBuilder textBuilder = new System.Text.StringBuilder(); using (WordprocessingDocument wdDoc = WordprocessingDocument.Open(file, false)) { NameTable nt = new NameTable(); XmlNamespaceManager nsManager = new XmlNamespaceManager(nt); nsManager.AddNamespace("w", wordmlNamespace); XmlDocument xdoc = new XmlDocument(nt); xdoc.Load(wdDoc.MainDocumentPart.GetStream()); XmlNodeList paragraphNodes = xdoc.SelectNodes("//w:p", nsManager); foreach (XmlNode paragraphNode in paragraphNodes) { XmlNodeList textNodes = paragraphNode.SelectNodes(".//w:t", nsManager); foreach (System.Xml.XmlNode textNode in textNodes) { textBuilder.Append(textNode.InnerText); } textBuilder.Append(Environment.NewLine); } } file.Close(); return textBuilder.ToString(); }
private XmlNamespaceManager GetNamespaceManager() { NameTable nt = new NameTable(); XmlNamespaceManager mgr = new XmlNamespaceManager(nt); mgr.AddNamespace("sn", "http://www.sensenet.com/2010"); return mgr; }
private static NameTable CreateAtomNameTable() { NameTable table = new NameTable(); table.Add(XmlConstants.AtomNamespace); table.Add(XmlConstants.DataWebNamespace); table.Add(XmlConstants.DataWebMetadataNamespace); table.Add(XmlConstants.AtomContentElementName); table.Add(XmlConstants.AtomContentSrcAttributeName); table.Add(XmlConstants.AtomEntryElementName); table.Add(XmlConstants.AtomETagAttributeName); table.Add(XmlConstants.AtomFeedElementName); table.Add(XmlConstants.AtomIdElementName); table.Add(XmlConstants.AtomInlineElementName); table.Add(XmlConstants.AtomLinkElementName); table.Add(XmlConstants.AtomLinkRelationAttributeName); table.Add(XmlConstants.AtomNullAttributeName); table.Add(XmlConstants.AtomPropertiesElementName); table.Add(XmlConstants.AtomTitleElementName); table.Add(XmlConstants.AtomTypeAttributeName); table.Add(XmlConstants.XmlErrorCodeElementName); table.Add(XmlConstants.XmlErrorElementName); table.Add(XmlConstants.XmlErrorInnerElementName); table.Add(XmlConstants.XmlErrorMessageElementName); table.Add(XmlConstants.XmlErrorTypeElementName); return table; }
static NuspecDocument() { var nameTable = new NameTable(); _xmlNamespaceManager = new XmlNamespaceManager(nameTable); _xmlNamespaceManager.AddNamespace("nuspec", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"); }
/// <summary> /// Method to parse the vector styles from a <see cref="XmlDocument"/> /// </summary> /// <param name="doc">The xml document</param> /// <returns>A dictionary of vector styles</returns> public static IDictionary<string, VectorStyle> ParseFeatureStyle(XmlDocument doc) { var styles = new Dictionary<string, VectorStyle>(); // Load SLD file var nt = new NameTable(); var nsm = new XmlNamespaceManager(nt); nsm.AddNamespace("sld", "http://www.opengis.net/sld"); nsm.AddNamespace("ogc", "http://www.opengis.net/ogc"); nsm.AddNamespace("xlink", "http://www.w3.org/1999/xlink"); var sldConfig = new XmlDocument(nt); sldConfig.LoadXml(doc.OuterXml); var featureTypeStyleEls = sldConfig.SelectNodes("//sld:FeatureTypeStyle", nsm); if (featureTypeStyleEls == null) return null; foreach (XmlElement featTypeStyle in featureTypeStyleEls) { var el = (XmlElement) featTypeStyle.SelectSingleNode("sld:FeatureTypeName", nsm); var mainName = el != null ? el.InnerText : ""; var rules = featTypeStyle.SelectNodes("sld:Rule", nsm); if (rules != null) { foreach (XmlElement rule in rules) { el = (XmlElement) rule.SelectSingleNode("sld:Name", nsm); var name = el != null ? el.InnerText : ""; var style = new VectorStyle(); SetSymbologyForRule(style, rule, nsm); styles.Add(mainName + ":" + name, style); } } } return styles; //style.AreFeaturesSelectable //style.Enabled //style.EnableOutline //style.Fill //style.HighlightFill //style.HighlightLine //style.HighlightOutline //style.HighlightSymbol //style.Line //style.MaxVisible //style.MinVisible //style.Outline //style.RenderingMode //style.SelectFill //style.SelectLine //style.SelectOutline //style.SelectSymbol }
/// <summary> /// /// </summary> /// /// <param name="soapMessage"></param> /// <param name="actor"></param> /// <param name="description"></param> /// <param name="source"></param> /// /// <returns></returns> /// public static int CreateSoapHeader(XmlDocument soapMessage, string actor, string description, string source, long elapsed) { // Set up a name table so we can query based on namespaces NameTable SoapNameTable = new NameTable(); XmlNamespaceManager soapNamespaceManager = new XmlNamespaceManager(SoapNameTable); soapNamespaceManager.AddNamespace(String.Empty, "urn:none"); soapNamespaceManager.AddNamespace("soap", SoapURN); // Find the header block XmlElement header = (XmlElement)soapMessage.SelectSingleNode("/soap:Envelope/soap:Header", soapNamespaceManager); if (Guard.IsNull(header)) { // If none exists and there is a soap:Envelope, create the header XmlElement envelope = (XmlElement)soapMessage.SelectSingleNode("/soap:Envelope", soapNamespaceManager); if (Guard.IsNull(envelope)) { return -1; } header = soapMessage.CreateElement("soap", "Header", SoapURN); envelope.AppendChild(header); } // Create, populate and add various pieces of data XmlElement action = soapMessage.CreateElement("action"); XmlElement actorElement = soapMessage.CreateElement("actor"); XmlElement from = soapMessage.CreateElement("from"); XmlElement time = soapMessage.CreateElement("timestamp"); XmlElement machine = soapMessage.CreateElement("machine"); XmlElement descriptionElement = soapMessage.CreateElement("description"); XmlElement timeElement = soapMessage.CreateElement("elapsed"); actorElement.AppendChild(soapMessage.CreateTextNode(actor)); from.AppendChild(soapMessage.CreateTextNode(source)); time.AppendChild(soapMessage.CreateTextNode(DateTime.Now.ToString())); machine.AppendChild(soapMessage.CreateTextNode(System.Net.Dns.GetHostName())); descriptionElement.AppendChild(soapMessage.CreateTextNode(description)); timeElement.AppendChild(soapMessage.CreateTextNode(elapsed.ToString())); action.AppendChild(actorElement); action.AppendChild(from); action.AppendChild(time); action.AppendChild(machine); action.AppendChild(descriptionElement); action.AppendChild(timeElement); // Try to set an index up try { action.SetAttribute("index", (header.SelectNodes("action").Count + 1).ToString()); } catch { action.SetAttribute("index", "1"); } // Add this header to the document header.AppendChild(action); return header.SelectNodes("action").Count; }
public NonValidatingReader(string content) : base() { this.content = content; _NameTable = new NameTable(); Namespaces = new Dictionary<string,string>(); Namespaces.Add(_NameTable.Add("xml"),"http://www.w3.org/XML/1998/namespace"); }
static XmlParserContext CreateContext() { var nt = new NameTable(); var nsmanager = new XmlNamespaceManager(nt); nsmanager.AddNamespace("log4j", log4jNamespace); nsmanager.AddNamespace("nlog", nlogNamespace); return new XmlParserContext(nt, nsmanager, "elem", XmlSpace.None, Encoding.UTF8); }
static XmlParserContext CreateContext() { var nt = new NameTable(); var nsmanager = new XmlNamespaceManager(nt); nsmanager.AddNamespace("log4j", "http://jakarta.apache.org/log4j/"); nsmanager.AddNamespace("nlog", "http://nlog-project.org"); return new XmlParserContext(nt, nsmanager, "elem", XmlSpace.None, Encoding.UTF8); }
static CfgXmlHelper() { NameTable nt = new NameTable(); nsMgr = new XmlNamespaceManager(nt); nsMgr.AddNamespace(CfgNamespacePrefix, CfgSchemaXMLNS); SearchFactoryExpression = XPathExpression.Compile(RootPrefixPath + ":search-factory", nsMgr); }
private static XmlNameTable CreateNameTable() { XmlNameTable table = new System.Xml.NameTable(); table.Add(string.Empty); table.Add("http://www.w3.org/2000/xmlns/"); table.Add("http://www.w3.org/XML/1998/namespace"); return table; }
public XPath2Context(NameTable table) : base(table) { _functions.Add(new UpperCaseFunction()); _functions.Add(new LowerCaseFunction()); _functions.Add(new ExistsFunction()); _functions.Add(new DistinctValuesFunction()); }
protected ArrayList GetGroupedProvidersFromXMLFile() { string pathToXMLFile = DataDirectoryName + @"\GroupedProviders.xml"; ArrayList arrayOfGroupedProviders = new ArrayList(); if (!File.Exists(pathToXMLFile)) { return arrayOfGroupedProviders; } XmlTextReader reader = null; try { reader = new XmlTextReader(pathToXMLFile); XmlNameTable nt = new NameTable(); XmlDocument xmlDoc = new XmlDocument(nt); xmlDoc.Load(reader); XmlNode root = xmlDoc.SelectSingleNode("Root"); XmlNode providersNode = root.SelectSingleNode("GroupedProviders"); // loop thru all of the GroupedProviders XmlAttribute nameAttribute = null; for (System.Xml.XmlNode oneXmlNode = providersNode.FirstChild; oneXmlNode != null; oneXmlNode = oneXmlNode.NextSibling) { if (oneXmlNode.Name.ToLower() == "groupedprovider") { GroupedProperty oneGroupedProvider = new GroupedProperty(); nameAttribute = oneXmlNode.Attributes["name"]; oneGroupedProvider.Name = nameAttribute.Value; XmlAttribute descriptionAttribute = null; try { descriptionAttribute = oneXmlNode.Attributes["description"]; oneGroupedProvider.Description = descriptionAttribute.Value; } catch { oneGroupedProvider.Description = String.Empty; } XmlNode membershipNode = oneXmlNode.SelectSingleNode("MembershipProvider"); nameAttribute = membershipNode.Attributes["name"]; oneGroupedProvider.MembershipProvider = nameAttribute.Value; XmlNode roleNode = oneXmlNode.SelectSingleNode("RoleProvider"); nameAttribute = roleNode.Attributes["name"]; oneGroupedProvider.RoleProvider = nameAttribute.Value; // Check if the membership/role provider exists in the web.config arrayOfGroupedProviders.Add(oneGroupedProvider); } } } finally { if (reader != null) { reader.Close(); } } // loop thru the list and print them out. return arrayOfGroupedProviders; }
/// <summary> /// Creates a new instance of the ExcelWorkbook class. For internal use only! /// </summary> /// <param name="xlPackage">The parent package</param> protected internal ExcelWorkbook(ExcelPackage xlPackage) { _xlPackage = xlPackage; // Create a NamespaceManager to handle the default namespace, // and create a prefix for the default namespace: var nt = new NameTable(); _nsManager = new XmlNamespaceManager(nt); _nsManager.AddNamespace("d", ExcelPackage.schemaMain); }
/// <summary>Return the Element corresponding the the XPath</summary> /// <param name="xmlElement"></param> /// <param name="xpathString"></param> /// <returns></returns> /// <exception cref="Javax.Xml.Xpath.XPathExpressionException">Javax.Xml.Xpath.XPathExpressionException /// </exception> public static XmlNodeList GetNodeList(XmlElement xmlElement, string xpathString) { NameTable table = new NameTable(); XmlNamespaceManager manager = new XmlNamespaceManager(table); manager.AddNamespace("xades", GetNamespaceURI("xades")); manager.AddNamespace("ds", GetNamespaceURI("ds")); return xmlElement.SelectNodes(xpathString, manager); }
static XmlHelper() { NameTable nt = new NameTable(); XmlNamespaceManager nsMgr = new XmlNamespaceManager(nt); nsMgr.AddNamespace(NamespacePrefix, SchemaXmlns); PropertiesExpression = XPathExpression.Compile(RootPrefixPath + "properties", nsMgr); PropertiesPropertyExpression = XPathExpression.Compile(RootPrefixPath + "properties/" + ChildPrefixPath + "property", nsMgr); }
private static XmlNameTable CreateNameTable() { XmlNameTable table = new System.Xml.NameTable(); table.Add(string.Empty); table.Add("http://www.w3.org/2000/xmlns/"); table.Add("http://www.w3.org/XML/1998/namespace"); return(table); }
static NuspecDocument() { var nameTable = new NameTable(); _xmlNamespaceManager = new XmlNamespaceManager(nameTable); _xmlNamespaceManager.AddNamespace("nuspec", Schema); _xmlns = Schema; }
internal static XmlDocument GetXmlDoc(ProviderSchemaVersion schemaVersion) { XmlNameTable xnt = new System.Xml.NameTable(); XmlDocument xdoc = new XmlDocument(xnt); XmlNamespaceManager nsm = new XmlNamespaceManager(xdoc.NameTable); nsm.AddNamespace("", GetSchemaUrl(schemaVersion)); xdoc.CreateProcessingInstruction(@"version", @"1.0"); xdoc.CreateProcessingInstruction(@"encoding", @"utf-8"); return(xdoc); }
private static XmlNamespaceManager ConstructEnterpriseLibraryNamespaceManager() { System.Xml.NameTable nameTable = new System.Xml.NameTable(); System.Xml.XmlNamespaceManager namespaceManager = new System.Xml.XmlNamespaceManager(nameTable); string enterpriseLibraryNamespace = "http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration"; namespaceManager.AddNamespace("el", enterpriseLibraryNamespace); return(namespaceManager); }
internal static void Preprocess(System.Xml.Schema.XmlSchema schema) { if (!schema.IsPreprocessed) { try { XmlNameTable nameTable = new System.Xml.NameTable(); new Preprocessor(nameTable, new SchemaNames(nameTable), null) { SchemaLocations = new Hashtable() }.Execute(schema, schema.TargetNamespace, false); } catch (XmlSchemaException exception) { throw CreateValidationException(exception, exception.Message); } } }
protected virtual XmlNamespaceManager GetNamespaceManager(IPDFComponent owner) { System.Xml.NameTable nt = new System.Xml.NameTable(); System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(nt); IPDFRemoteComponent parsed = this.GetParsedParent(owner); IDictionary <string, string> parsedNamespaces = null; //add the namespaces of the last parsed document so we can infer any declarations if (null != parsed) { parsedNamespaces = parsed.GetDeclaredNamespaces(); if (null != parsedNamespaces) { foreach (string prefix in parsedNamespaces.Keys) { mgr.AddNamespace(prefix, parsedNamespaces[prefix]); } } } return(mgr); }
public string LookupPrefix(string ns) { return(context.NamespaceManager.LookupPrefix(NameTable.Get(ns))); }
public void Compile(ValidationEventHandler handler, bool fullCompile) { if (!this.isCompiled) { foreach (System.Xml.Schema.XmlSchema schema in this.delayedSchemas.Values) { this.Merge(schema); } this.delayedSchemas.Clear(); if (fullCompile) { this.schemaSet = new XmlSchemaSet(); this.schemaSet.XmlResolver = null; this.schemaSet.ValidationEventHandler += handler; foreach (System.Xml.Schema.XmlSchema schema2 in this.References.Values) { this.schemaSet.Add(schema2); } int count = this.schemaSet.Count; foreach (System.Xml.Schema.XmlSchema schema3 in base.List) { if (!this.SchemaSet.Contains(schema3)) { this.schemaSet.Add(schema3); count++; } } if (!this.SchemaSet.Contains("http://www.w3.org/2001/XMLSchema")) { this.AddReference(XsdSchema); this.schemaSet.Add(XsdSchema); count++; } if (!this.SchemaSet.Contains("http://www.w3.org/XML/1998/namespace")) { this.AddReference(XmlSchema); this.schemaSet.Add(XmlSchema); count++; } this.schemaSet.Compile(); this.schemaSet.ValidationEventHandler -= handler; this.isCompiled = this.schemaSet.IsCompiled && (count == this.schemaSet.Count); } else { try { XmlNameTable nameTable = new System.Xml.NameTable(); Preprocessor preprocessor = new Preprocessor(nameTable, new SchemaNames(nameTable), null) { XmlResolver = null, SchemaLocations = new Hashtable(), ChameleonSchemas = new Hashtable() }; foreach (System.Xml.Schema.XmlSchema schema4 in this.SchemaSet.Schemas()) { preprocessor.Execute(schema4, schema4.TargetNamespace, true); } } catch (XmlSchemaException exception) { throw CreateValidationException(exception, exception.Message); } } } }
/* ----------------------------------------------- Functions */ #region Functions public static Information Parse(ref LibraryEditor_SpriteStudio6.Import.Setting setting, string nameFile ) { const string messageLogPrefix = "Parse SignaleSetting"; Information informationSignalSetting = null; /* ".ssce" Load */ if (false == System.IO.File.Exists(nameFile)) { LogError(messageLogPrefix, "File Not Found", nameFile); goto Parse_ErrorEnd; } System.Xml.XmlDocument xmlSianalSetting = new System.Xml.XmlDocument(); xmlSianalSetting.Load(nameFile); /* Check Version */ System.Xml.XmlNode nodeRoot = xmlSianalSetting.FirstChild; nodeRoot = nodeRoot.NextSibling; KindVersion version = (KindVersion)(LibraryEditor_SpriteStudio6.Utility.XML.VersionGet(nodeRoot, "SpriteStudioSignal", (int)KindVersion.ERROR, true)); switch (version) { case KindVersion.ERROR: LogError(messageLogPrefix, "Version Invalid", nameFile); goto Parse_ErrorEnd; case KindVersion.CODE_000100: case KindVersion.CODE_010000: break; default: if (KindVersion.TARGET_EARLIEST > version) { version = KindVersion.TARGET_EARLIEST; if (true == setting.CheckVersion.FlagInvalidSSCE) { LogWarning(messageLogPrefix, "Version Too Early", nameFile); } } else { version = KindVersion.TARGET_LATEST; if (true == setting.CheckVersion.FlagInvalidSSCE) { LogWarning(messageLogPrefix, "Version Unknown", nameFile); } } break; } /* Create Information */ informationSignalSetting = new Information(); if (null == informationSignalSetting) { LogError(messageLogPrefix, "Not Enough Memory", nameFile); goto Parse_ErrorEnd; } informationSignalSetting.BootUp(); informationSignalSetting.Version = version; /* Get Base-Directories */ LibraryEditor_SpriteStudio6.Utility.File.PathSplit(out informationSignalSetting.NameDirectory, out informationSignalSetting.NameFileBody, out informationSignalSetting.NameFileExtension, nameFile); /* Decode Tags */ System.Xml.NameTable nodeNameSpace = new System.Xml.NameTable(); System.Xml.XmlNamespaceManager managerNameSpace = new System.Xml.XmlNamespaceManager(nodeNameSpace); string valueText = ""; /* Get Command Setting */ System.Xml.XmlNodeList listNode = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeRoot, "commands/value", managerNameSpace); if (null == listNode) { LogError(messageLogPrefix, "\"command/value\"-Node Not Found", nameFile); goto Parse_ErrorEnd; } Information.Command command = null; foreach (System.Xml.XmlNode nodeCommand in listNode) { command = new Information.Command(); if (null == command) { LogError(messageLogPrefix, "Not Enough Memory (Command WorkArea)", nameFile); goto Parse_ErrorEnd; } command.BootUp(); valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeCommand, "id", managerNameSpace); command.ID = valueText.Trim(); if (true == string.IsNullOrEmpty(command.ID)) { LogError(messageLogPrefix, "Command-ID Invelid (Empty)", nameFile); goto Parse_ErrorEnd; } /* MEMO: "Name" is not decoded because only needed on SS6. */ valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeCommand, "valueId", managerNameSpace); command.IDValue = valueText.Trim(); /* MEMO: "IDValue" allows the empty. (means "No values") */ /* Add Command */ informationSignalSetting.TableCommand.Add(command.ID, command); } /* Get Value Setting */ listNode = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeRoot, "values/value", managerNameSpace); if (null == listNode) { LogError(messageLogPrefix, "\"values/value\"-Node Not Found", nameFile); goto Parse_ErrorEnd; } Information.Value value = null; Information.Value.Parameter parameterValue = null; System.Xml.XmlNodeList listNodeParam = null; foreach (System.Xml.XmlNode nodeValue in listNode) { value = new Information.Value(); if (null == value) { LogError(messageLogPrefix, "Not Enough Memory (Value WorkArea)", nameFile); goto Parse_ErrorEnd; } value.BootUp(); valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeValue, "id", managerNameSpace); value.ID = valueText.Trim(); if (true == string.IsNullOrEmpty(value.ID)) { LogError(messageLogPrefix, "Value-ID Invelid (Empty)", nameFile); goto Parse_ErrorEnd; } listNodeParam = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeValue, "params/value", managerNameSpace); if (null == listNodeParam) { LogError(messageLogPrefix, "\"values/value/params/value\"-Node Not Found", nameFile); goto Parse_ErrorEnd; } foreach (System.Xml.XmlNode nodeParameterValue in listNodeParam) { parameterValue = new Information.Value.Parameter(); if (null == parameterValue) { LogError(messageLogPrefix, "Not Enough Memory (Value's parameter WorkArea)", nameFile); goto Parse_ErrorEnd; } parameterValue.CleanUp(); valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeParameterValue, "id", managerNameSpace); parameterValue.ID = valueText.Trim(); if (true == string.IsNullOrEmpty(parameterValue.ID)) { LogError(messageLogPrefix, "Value's Parameter-ID Invelid (Empty)", nameFile); goto Parse_ErrorEnd; } /* MEMO: "Name" is not decoded because only needed on SS6. */ valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeParameterValue, "type", managerNameSpace); valueText = valueText.Trim(); parameterValue.Type = TypeGetParameterValue(valueText); if (Library_SpriteStudio6.Data.Animation.Attribute.Signal.Command.Parameter.KindType.ERROR == parameterValue.Type) { LogError(messageLogPrefix, "Value's Param Type \"" + valueText + "\" Invelid (Enpty)", nameFile); goto Parse_ErrorEnd; } valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeParameterValue, "listId", managerNameSpace); parameterValue.IDList = valueText.Trim(); /* MEMO: "IDList" allows the empty. (means "No Index-List") */ /* Add Parameter */ value.TableParameter.Add(parameterValue.ID, parameterValue); } /* Add Value */ informationSignalSetting.TableValue.Add(value.ID, value); } /* Get List Setting */ listNode = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeRoot, "lists/value", managerNameSpace); if (null == listNode) { LogError(messageLogPrefix, "\"lists/value\"-Node Not Found", nameFile); goto Parse_ErrorEnd; } Information.ListIndex listIndex = null; Information.ListIndex.Item itemListIndex = null; System.Xml.XmlNodeList listNodeItemList = null; foreach (System.Xml.XmlNode nodeList in listNode) { listIndex = new Information.ListIndex(); if (null == listIndex) { LogError(messageLogPrefix, "Not Enough Memory (ListIndex WorkArea)", nameFile); goto Parse_ErrorEnd; } listIndex.BootUp(); valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeList, "id", managerNameSpace); listIndex.ID = valueText.Trim(); if (true == string.IsNullOrEmpty(listIndex.ID)) { LogError(messageLogPrefix, "ListIndex-ID Invelid (Empty)", nameFile); goto Parse_ErrorEnd; } listNodeItemList = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeList, "items/value", managerNameSpace); if (null == listNodeItemList) { LogError(messageLogPrefix, "\"values/value/params/value\"-Node Not Found", nameFile); goto Parse_ErrorEnd; } foreach (System.Xml.XmlNode nodeItemListIndex in listNodeItemList) { itemListIndex = new Information.ListIndex.Item(); if (null == itemListIndex) { LogError(messageLogPrefix, "Not Enough Memory (ListIndex's item WorkArea)", nameFile); goto Parse_ErrorEnd; } itemListIndex.CleanUp(); valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeItemListIndex, "id", managerNameSpace); itemListIndex.ID = valueText.Trim(); if (true == string.IsNullOrEmpty(itemListIndex.ID)) { LogError(messageLogPrefix, "ListIndex Item-ID Invelid (Empty)", nameFile); goto Parse_ErrorEnd; } /* MEMO: Decode the name in case of "ListIndex" (just in case). */ valueText = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeItemListIndex, "name", managerNameSpace); itemListIndex.Name = valueText.Trim(); /* MEMO: "Name" allows the empty, now. */ /* Add Parameter */ listIndex.TableItem.Add(itemListIndex.ID, itemListIndex); } /* Add List */ informationSignalSetting.TableListIndex.Add(listIndex.ID, listIndex); } /* Check Link(Relational)-ID */ { string idCheck; foreach (KeyValuePair <string, Information.Command> pair in informationSignalSetting.TableCommand) { idCheck = pair.Value.IDValue; if (false == string.IsNullOrEmpty(idCheck)) { if (false == informationSignalSetting.TableValue.ContainsKey(idCheck)) { LogError(messageLogPrefix, "Missing Link Value-ID(" + idCheck + ") in Command-ID(" + pair.Key + ")", nameFile ); goto Parse_ErrorEnd; } } } foreach (KeyValuePair <string, Information.Value> pair in informationSignalSetting.TableValue) { foreach (KeyValuePair <string, Information.Value.Parameter> pairParameter in informationSignalSetting.TableValue[pair.Key].TableParameter) { idCheck = pairParameter.Value.IDList; if (false == string.IsNullOrEmpty(idCheck)) { if (false == informationSignalSetting.TableListIndex.ContainsKey(idCheck)) { LogError(messageLogPrefix, "Missing Link List-ID(" + idCheck + ") in Value-ID(" + pair.Key + ", " + pairParameter.Key + ")", nameFile ); goto Parse_ErrorEnd; } } } } } return(informationSignalSetting); Parse_ErrorEnd: if (null != informationSignalSetting) { informationSignalSetting.CleanUp(); } return(null); }
public string LookupPrefix(string ns) { IXmlNamespaceResolver nsr = reader as IXmlNamespaceResolver; return(nsr.LookupPrefix(NameTable.Get(ns))); }
public static Information Parse(ref LibraryEditor_SpriteStudio6.Import.Setting setting, string nameFile, LibraryEditor_SpriteStudio6.Import.SSPJ.Information informationSSPJ ) { const string messageLogPrefix = "Parse SSQE"; Information informationSSQE = null; /* ".ssee" Load */ if (false == System.IO.File.Exists(nameFile)) { LogError(messageLogPrefix, "File Not Found", nameFile, informationSSPJ); goto Parse_ErrorEnd; } System.Xml.XmlDocument xmlSSQE = new System.Xml.XmlDocument(); xmlSSQE.Load(nameFile); /* Check Version */ System.Xml.XmlNode nodeRoot = xmlSSQE.FirstChild; nodeRoot = nodeRoot.NextSibling; KindVersion version = (KindVersion)(LibraryEditor_SpriteStudio6.Utility.XML.VersionGet(nodeRoot, "SpriteStudioSequencePack", (int)KindVersion.ERROR, true)); /* MEMO: Loose version check */ /* If you check strictly, there are a lot of datas that can not be imported. */ switch (version) { case KindVersion.ERROR: LogError(messageLogPrefix, "Version Invalid", nameFile, informationSSPJ); goto Parse_ErrorEnd; case KindVersion.CODE_010000: /* MEMO: Read all as Ver.1.01.00. */ version = KindVersion.CODE_010000; break; default: if (KindVersion.TARGET_EARLIEST > version) { version = KindVersion.TARGET_EARLIEST; if (true == setting.CheckVersion.FlagInvalidSSQE) { LogWarning(messageLogPrefix, "Version Too Early", nameFile, informationSSPJ); } } else { version = KindVersion.TARGET_LATEST; if (true == setting.CheckVersion.FlagInvalidSSQE) { LogWarning(messageLogPrefix, "Version Unknown", nameFile, informationSSPJ); } } break; } /* Create Information */ informationSSQE = new Information(); if (null == informationSSQE) { LogError(messageLogPrefix, "Not Enough Memory", nameFile, informationSSPJ); goto Parse_ErrorEnd; } informationSSQE.CleanUp(); informationSSQE.Version = version; /* Get Base-Directories */ LibraryEditor_SpriteStudio6.Utility.File.PathSplit(out informationSSQE.NameDirectory, out informationSSQE.NameFileBody, out informationSSQE.NameFileExtension, nameFile); /* Decode Tags */ System.Xml.NameTable nodeNameSpace = new System.Xml.NameTable(); System.Xml.XmlNamespaceManager managerNameSpace = new System.Xml.XmlNamespaceManager(nodeNameSpace); //string valueText = ""; informationSSQE.Name = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeRoot, "name", managerNameSpace); informationSSQE.ExportPath = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeRoot, "exportPath", managerNameSpace); System.Xml.XmlNodeList nodeList = null; nodeList = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeRoot, "sequenceList/sequence", managerNameSpace); if (null == nodeList) { informationSSPJ.TableNameSSQE = new string[0]; } else { /* MEMO: Nothing to do, now. */ } List <Library_SpriteStudio6.Data.Sequence.Data> listSequence = new List <Library_SpriteStudio6.Data.Sequence.Data>(); listSequence.Clear(); foreach (System.Xml.XmlNode nodeSequence in nodeList) { Library_SpriteStudio6.Data.Sequence.Data sequence = new Library_SpriteStudio6.Data.Sequence.Data(); sequence.Name = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeSequence, "name", managerNameSpace); sequence.Index = ValueTextToInt(LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeSequence, "index", managerNameSpace)); sequence.Type = ValueTextToSequenceType(LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeSequence, "type", managerNameSpace)); System.Xml.XmlNodeList nodeListValueSequence = null; nodeListValueSequence = LibraryEditor_SpriteStudio6.Utility.XML.ListGetNode(nodeSequence, "list/value", managerNameSpace); List <Library_SpriteStudio6.Data.Sequence.Data.Step> listDetail = new List <Library_SpriteStudio6.Data.Sequence.Data.Step>(); listDetail.Clear(); foreach (System.Xml.XmlNode nodeValue in nodeListValueSequence) { Library_SpriteStudio6.Data.Sequence.Data.Step dataStep = new Library_SpriteStudio6.Data.Sequence.Data.Step(); dataStep.NamePackAnimation = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeValue, "refAnimePack", managerNameSpace); dataStep.NameAnimation = LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeValue, "refAnime", managerNameSpace); dataStep.PlayCount = ValueTextToInt(LibraryEditor_SpriteStudio6.Utility.XML.TextGetNode(nodeValue, "repeatCount", managerNameSpace)); listDetail.Add(dataStep); } sequence.TableStep = listDetail.ToArray(); listSequence.Add(sequence); } informationSSQE.SequenceList = listSequence.ToArray(); return(informationSSQE); Parse_ErrorEnd :; return(null); }
public override string LookupNamespace(string prefix) { return(context.NamespaceManager.LookupNamespace( NameTable.Get(prefix))); }
public static void Init() { NameTable nt = new NameTable(); XmlNamespaceManager NsMgr = new XmlNamespaceManager(nt); NsMgr.AddNamespace(XmlConstants.Namespace, XmlConstants.SchemaXMLNS); ConfigExpression = XPathExpression.Compile("//" + XmlConstants.Namespace + ":" + XmlConstants.Setting, NsMgr); }