static Vertex AddSomeProperties(Vertex v) { for (int i = 0, n = _random.Next(0, 5); i < n; i++) { var prop = new Property { Name = "Prop " + i, Value = "Value " + i }; v.Properties.Add(prop.Name, prop); } return v; }
public XPathNodeIterator Load(XPathNodeIterator o, string couldBeXPath) { var refVertex = (Vertex) ((ObjectNavigator)o.Current).For; var vertex = new Vertex { Name = "Vertex for " + couldBeXPath }; for (int i = 0; i < 10; i++) { var child = new Vertex { Name = "Child " + i + " for " + couldBeXPath }; vertex.Children.Add(child); child.Properties.Add("Reference", new Property { Name = "Reference", Value = refVertex.Name }); } return new ObjectNavigator(vertex.GetElementDescriptor()).Select("Vertex"); }
Vertex GetTestData() { var r = new Random(1337); var root = new Vertex(); root.Name = "Root"; for (int i = 0; i < 10; i++) { var child = new Vertex(); child.Name = "Child #" + i; for (int j = 0, n = r.Next(0, 10); j < n; j++) { var prop = new Property { Name = "Property #" + j, Value = "Value #" + j }; child.Properties[prop.Name] = prop; } root.Children.Add(child); } return root; }
static void Main(string[] args) { var v1 = new Vertex(); AddSomeProperties(v1); for (int i = 0; i < 5; i++) { v1.Children.Add( AddSomeProperties(new Vertex { Name = "Child " + i, ID = "10" })); } var xslt = new XslCompiledTransform(); //You need to change the path xslt.Load("Test.xslt"); var nav = new ObjectNavigator(v1.GetElementDescriptor()); var xsltOld = new XslTransform(); xsltOld.Load("Test.xslt"); /*xslt.Transform(nav, new XsltArgumentList(), Console.Out);*/ var xsltArgs = new XsltArgumentList(); xsltArgs.AddExtensionObject("urn:test", new Loader()); xsltOld.Transform(nav, xsltArgs, Console.Out); Console.In.ReadLine(); }