开发者

Omitting all namespaces from XslCompiledTransform.Transform output

How can I omit all XML-Namespaces from the xslt in the html-output?

My XSL starts with:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">

and my code to transform the XML is as follows

StringBuilder sb = new StringBuilder(600);
XslCompiledTransform xslTrans = new XslCompiledTransform();

xslTrans.Load(XslDoc);//loads the XSL

XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.OmitXmlDeclaration = true;
writerSettings.ConformanceLevel = ConformanceLevel.Auto;
writerSettings.NamespaceHandling = NamespaceHandling.OmitDuplicates;


using (XmlWriter stringWriter = XmlWriter.Create(sb, writerSettings))
{
    xslTrans.Transform(XmlDoc, xslArguments, stringWriter);
}
return sb.ToString();

But in the generated html output appear the namespaces as follows:

<div class="newsFeed" xmlnsxs="http://www.w3.org/2001/XMLSchema" xmlnsfn="http://www.w3.org/2005/xpath-functions" >

How can I omit all namespaces in the generated output? It was cool, if I could do this by modifying the XSL, so user开发者_开发问答 can change their XSL to embed their namespaces but default it would be clean HTML-Code without xmlns.


You're probably looking for the exclude-result-prefixes attribute on your xsl:stylesheet element.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜