public WritingSystemLdmlVersionGetter() { // Can't use XPathVersion to parse Sil namespace version, so using SilLdmlVersion var versionNodeVersionLdml = new SilLdmlVersion(); _versionGetters.Add(versionNodeVersionLdml); var versionNodeVersion = new XPathVersion(1, "/ldml/special/palaso:version/@value"); versionNodeVersion.NamespaceManager.AddNamespace("palaso", "urn://palaso.org/ldmlExtensions/v1"); _versionGetters.Add(versionNodeVersion); }
public PolicySetDefaults(Node node) { NodeList children = node.ChildNodes; for (int i = 0; i < children.Length; i++) { Node child = children.Item(i); if (child.NodeName.Equals(XPathVersion.Identifer)) { this._xPathVersion = (XPathVersion)PolicyElementFactory.GetInstance(child); } } }
public void GetFileVersion_NoVersion_ReturnsMinus1() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <configuration noversion='x'> <blah /> </configuration> ".Replace("'", "\""); using (var file = new TempFile(xml)) { var xPathVersion = new XPathVersion(10, "/configuration/@version"); int result = xPathVersion.GetFileVersion(file.Path); Assert.That(result, Is.EqualTo(-1)); } }
public void GetFileVersion_WithVersionAttribute_CorrectVersion() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <configuration version='3'> <blah /> </configuration> ".Replace("'", "\""); using (var file = new TempFile(xml)) { var xPathVersion = new XPathVersion(10, "/configuration/@version"); int result = xPathVersion.GetFileVersion(file.Path); Assert.That(result, Is.EqualTo(3)); } }
public WritingSystemLdmlVersionGetter(WritingSystemCompatibility compatibilityMode) { var versionNodeVersion = new XPathVersion(1, "/ldml/special/palaso:version/@value"); versionNodeVersion.NamespaceManager.AddNamespace("palaso", "urn://palaso.org/ldmlExtensions/v1"); if (compatibilityMode == WritingSystemCompatibility.Flex7V0Compatible) { var flexPrivateUseVersionGetter = new XPathVersion(1, "/ldml/identity/language/@type"); flexPrivateUseVersionGetter.VersionParser = str => { return((str.StartsWith("x-", StringComparison.OrdinalIgnoreCase) || str.Equals("x")) ? 2 : -1); }; _versionGetters.Add(flexPrivateUseVersionGetter); } _versionGetters.Add(versionNodeVersion); }
public void GetFileVersion_WithNameSpace_CorrectVersion() { string xml = @"<?xml version='1.0' encoding='utf-8'?> <ldml> <special xmlns:palaso='urn://palaso.org/ldmlExtensions/v1'> <palaso:version value='3' /> </special> </ldml> ".Replace("'", "\""); using (var file = new TempFile(xml)) { var xPathVersion = new XPathVersion(10, "/ldml/special/palaso:version/@value"); xPathVersion.NamespaceManager.AddNamespace("palaso", "urn://palaso.org/ldmlExtensions/v1"); int result = xPathVersion.GetFileVersion(file.Path); Assert.That(result, Is.EqualTo(3)); } }
public void GetFileVersion_WithVersionAsDoubleUsingDelegate_CorrectVersion() { string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <configuration version='3.0'> <blah /> </configuration> ".Replace("'", "\""); using (var file = new TempFile(xml)) { var xPathVersion = new XPathVersion(10, "/configuration/@version"); xPathVersion.VersionParser = delegate(string version) { double v = double.Parse(version); return((int)v); }; int result = xPathVersion.GetFileVersion(file.Path); Assert.That(result, Is.EqualTo(3)); } }
public IElement GetInstance(Node node) { return(XPathVersion.GetInstance(node)); }
public IElement GetInstance(string value) { return(XPathVersion.GetInstance(value)); }