【发布时间】:2010-09-09 21:01:02
【问题描述】:
我创建了一个 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) ));
【问题讨论】:
-
@Henk Holterman:如果 OP 想要为 XSLT 样式表或 CSS 样式表添加 PI,这没有区别。此外,将 XSLT 样式表引用到 XML 文档中也不是 XSLT 规范的一部分。最后,OP 想用 LINQ 做到这一点,而不是 XSLT 本身。所以,请回滚您的标题和标签版本。
-
@Alejandro:不,处理指令是答案的一部分,而不是问题的一部分。我发现 PI 很神秘。
-
@Henk Holterman:我认为这个
<?xml-stylesheet type="text/xsl" href="OBReport.xslt"?>(来自问题的文字)是 PI...。但这与我之前的论点无关 -
@Alejandro:问题标题也是 SEO 的一种形式。知道这是 ProcessingInstruction 的人不会搜索此问题。
-
@Henk Holterman:很公平!这就是我重新定义为“样式表参考”的原因。
标签: .net xml linq-to-xml