Код: Выделить всё
Detail Invoice
1
Detail Invoice
2
Detail Invoice
3
< /code>
Используя XSLT, я хочу преобразовать это в текст, определенный вкладками, как это: < /p>
NoticeType\tApplication
Detail Invoice\t1
Detail Invoice\t2
Detail Invoice\t3
< /code>
Вот таблица стилей, которую я использую: < /p>
NoticeType Application
< /code>
Я вызываю преобразование в .net 8.0 с Saxoncs 12.4 Например: < /p>
System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Parse("{xml}");
System.Xml.Linq.XElement stylesheet = System.Xml.Linq.XElement.Parse("{xslt}");
Saxon.Api.Processor processor = new(true);
Saxon.Api.XsltCompiler comp = processor.NewXsltCompiler();
List errs = [];
comp.ErrorReporter = errs.Add;
Saxon.Api.XsltExecutable exe = comp.Compile(stylesheet.CreateReader());
Saxon.Api.Xslt30Transformer xfrm = exe.Load30();
Saxon.Api.XdmValue output = xfrm.ApplyTemplates(xml.CreateReader());
< /code>
Но вывод, который я получаю, выглядит так: < /p>
NoticeType Application
Detail Invoice
\t
1
Detail Invoice
\t
2
Detail Invoice
\t
3
Код: Выделить всё
System.Xml.Linq.XElement xml = System.Xml.Linq.XElement.Parse("{xml}");
System.Xml.Linq.XElement stylesheet = System.Xml.Linq.XElement.Parse("{xslt}");
Saxon.Api.Processor processor = new(true);
Saxon.Api.XsltCompiler comp = processor.NewXsltCompiler();
List errs = [];
comp.ErrorReporter = errs.Add;
Saxon.Api.XsltExecutable exe = comp.Compile(stylesheet.CreateReader());
Saxon.Api.Xslt30Transformer xfrm = exe.Load30();
Saxon.Api.Serializer ser = processor.NewSerializer();
System.Text.StringBuilder sb = new();
using System.IO.StringWriter sw = new(sb);
ser.OutputWriter = sw;
xfrm.ApplyTemplates(xml.CreateReader(), ser);
Подробнее здесь: https://stackoverflow.com/questions/794 ... slt-output