コード例 #1
0
        public XsltElement GetTemplateElement(IGroup group)
        {
            var templateElement =
                xslt.Template(group.TemplateMatch, GetTemplateElementMode(group));

            XsltElement groupElement;

            if (group is IRootGroup rootGroup)
            {
                groupElement = templateElement.GetPathEndpoint(GetPathPartElements(rootGroup.OutputData))
                               .AddAndReturnChild(xslt.Element(rootGroup.OutputData.Name));
            }
            else
            {
                groupElement = templateElement.AddAndReturnChild(xslt.Element(group.OutputData.Name));
            }

            foreach (var field in group.Fields.Where(f => f.OutputData != null).OrderBy(f => f.OutputData.ContentType))
            {
                groupElement.GetPathEndpoint(GetPathPartElements(field.OutputData))
                .AddOrUpdateOutputElements(GetOutputTransformElement(field));
            }

            foreach (var subgroup in group.SubGroups)
            {
                groupElement.GetPathEndpoint(GetPathPartElements(subgroup.OutputData))
                .AddOrUpdateOutputElements(GetApplyTemplatesElement(group.GetContext(), subgroup));
            }

            return(templateElement);
        }
コード例 #2
0
        public void Element_String_CreatesElement()
        {
            var xslt    = new XsltFactory();
            var name    = "testName";
            var element = xslt.Element(name);

            Assert.Equal("element", element.Name.LocalName);
            Assert.Contains(element.Attributes(), a => a.Name == "name" && a.Value == name);
        }