Использование http://msdn.microsoft.com/en-us/library/c22k3d47.aspx например xDoc.createElement("xsl", "value-of", "http://www.w3.org/1999/XSL/Transform")
, если вы хотите создать узел элемента XSLT xsl:value-of
.
[edit] Для меня эта перегрузка работает нормально, приведу более полный пример, когда XMLFile1.xml равен
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*/*">
<Row/>
</xsl:template>
</xsl:stylesheet>
затем следующий код C #
XmlDocument sheet = new XmlDocument();
sheet.Load(@"..\..\XMLFile1.xml");
sheet.Save(Console.Out);
Console.WriteLine();
const string ss = "urn:schemas-microsoft-com:office:spreadsheet";
const string xsl = "http://www.w3.org/1999/XSL/Transform";
XmlNamespaceManager mgr = new XmlNamespaceManager(sheet.NameTable);
mgr.AddNamespace("ss", ss);
mgr.AddNamespace("xsl", xsl);
XmlNode row = sheet.SelectSingleNode("/xsl:stylesheet/xsl:template[@match = '/*/*']/ss:Row", mgr);
Console.WriteLine(row.OuterXml);
XmlNode cell = row.AppendChild(sheet.CreateElement("Cell", ss));
XmlNode data = cell.AppendChild(sheet.CreateElement("Data", ss));
XmlAttribute type = sheet.CreateAttribute("ss", "Type", ss);
type.Value = "String";
data.Attributes.Append(type);
XmlElement valueOf = data.AppendChild(sheet.CreateElement("xsl", "value-of", xsl)) as XmlElement;
valueOf.SetAttribute("select", "local-name()");
sheet.Save(Console.Out);
Console.WriteLine();
XslCompiledTransform proc = new XslCompiledTransform();
proc.Load(sheet);
прекрасно компилируется и работает и выдает
<?xml version="1.0" encoding="ibm850"?>
<xsl:stylesheet version="1.0" xmlns="urn:schemas-microsoft-com:office:spreadshee
t" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*/*">
<Row />
</xsl:template>
</xsl:stylesheet>
<Row xmlns="urn:schemas-microsoft-com:office:spreadsheet" />
<?xml version="1.0" encoding="ibm850"?>
<xsl:stylesheet version="1.0" xmlns="urn:schemas-microsoft-com:office:spreadshee
t" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/*/*">
<Row>
<Cell>
<Data ss:Type="String">
<xsl:value-of select="local-name()" />
</Data>
</Cell>
</Row>
</xsl:template>
</xsl:stylesheet>