Is there a way to retrieve the media-type value? e.g. like OutputSettings.OutputMethod used to get xsl:output method.
A:
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.
Tomalak
2010-03-09 15:29:27
Thanks Tomalak. It works. I never thought XSLT is similar structure as XML. Cool.
HH
2010-03-10 14:16:56
@HH: XSLT ist not a "similar structure", XSLT *is* XML - simple as that. ;)
Tomalak
2010-03-10 14:28:24
+1
A:
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());
}
HH
2010-03-10 14:19:53