I create an XML Doc and wanted have a reference to the XSLT file.
我创建了一个XML Doc,并希望引用XSLT文件。
//<?xml-stylesheet type="text/xsl" href="OBReport.xslt"?>
to this XML generation:
这个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) ));
1 个解决方案
#1
11
Add an XProcessingInstruction element.
添加XProcessingInstruction元素。
And not to your XElement (which can be used as a document but with limitations) but to an enveloping XDocument. So, after your code:
而不是你的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);
#1
11
Add an XProcessingInstruction element.
添加XProcessingInstruction元素。
And not to your XElement (which can be used as a document but with limitations) but to an enveloping XDocument. So, after your code:
而不是你的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);