如何通过 ASP.NET 从 xsl 文件中检索 xsl:output 媒体类型值

发布于 2024-08-24 01:23:04 字数 72 浏览 3 评论 0原文

有没有办法检索媒体类型值?例如,像 OutputSettings.OutputMethod 用于获取 xsl:output 方法。

Is there a way to retrieve the media-type value? e.g. like OutputSettings.OutputMethod used to get xsl:output method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作妖 2024-08-31 01:23:04
XPathNavigator objArgXPathNavigator = objArgXsltDocument.CreateNavigator();
XPathExpression objXPathExpression = objArgXPathNavigator.Compile("/*/xsl:output/@media-type");
XmlNamespaceManager objXmlNamespaceManager = new XmlNamespaceManager(objArgXPathNavigator.NameTable);
objXmlNamespaceManager.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
objXPathExpression.SetContext(objXmlNamespaceManager);

XPathNodeIterator nodes = objArgXPathNavigator.Select(objXPathExpression);
while (nodes.MoveNext())
{
  objArgHttpContext.Response.Write(nodes.Current.ToString());
}
XPathNavigator objArgXPathNavigator = objArgXsltDocument.CreateNavigator();
XPathExpression objXPathExpression = objArgXPathNavigator.Compile("/*/xsl:output/@media-type");
XmlNamespaceManager objXmlNamespaceManager = new XmlNamespaceManager(objArgXPathNavigator.NameTable);
objXmlNamespaceManager.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
objXPathExpression.SetContext(objXmlNamespaceManager);

XPathNodeIterator nodes = objArgXPathNavigator.Select(objXPathExpression);
while (nodes.MoveNext())
{
  objArgHttpContext.Response.Write(nodes.Current.ToString());
}
离笑几人歌 2024-08-31 01:23:04

您可以通过处理 XML 的首选方法查询 XSL 样式表(例如作为 XmlDocument)并发出以下 XPath 查询(不要忘记使用 NamespaceManager 预先使 xsl 命名空间可供 XPath 使用):

/*/xsl:output/@media-type

.aspx 也可以通过LINQ来实现。

You could query the XSL stylesheet via your preferred method of handling XML (for example as an XmlDocument) and issue the following XPath query (don't forget to make the xsl namespace available to XPath beforehand with a NamespaceManager):

/*/xsl:output/@media-type

The equivalent could be also achieved with LINQ.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文