我创建了一个
XML Doc,并希望引用XSLT文件.
//<?xml-stylesheet type="text/xsl" href="OBReport.xslt"?>
这个XML生成:
XElement xml = new XElement("ReportedOn",from dl in EL.DocumentLog.ToList() join o in EL.Organization on dl.OrganizationID equals o.OrganizationId where dl.ActionDate >= stDate & dl.ActionDate <= enDate orderby dl.DefendantName,dl.DocumentName select new XElement("persons",new XAttribute("documentName",dl.DocumentName),new XElement("defendantName",dl.DefendantName),new XElement("actionDate",dl.ActionDate.ToString()),new XElement("startDate",dl.StartDate.ToString()),new XElement("endDate",dl.EndDate.ToString()),new XElement("organizationName",o.OrganizationName) ));
添加
XProcessingInstruction元素.
原文链接:https://www.f2er.com/xml/292644.html而不是你的XElement(可以用作文档,但有限制),而不是包围XDocument.所以,在您的代码之后:
XElement body = ...; // root XElement from your Linq statement XDocument doc = new XDocument( new XProcessingInstruction("xml-stylesheet","type='text/xsl' ref='hello.xsl'"),body);