DFB wrote:
XslCompiledTran sform xsltTran = new XslCompiledTran sform();
xsltTran.Transf orm( xmlDoc, xsltArgs, xmlWriter );
<xsl:styleshe et
version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:d="uri:do cumentSchema"
xmlns:s="uri:sh aredSchema">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<xsl:apply-templates select="body"/>
</xsl:template>
<xsl:template match="body">
<document xmlns="uri:docu mentSchema">
<docItems/>
<d:sharedItem s xmlns="uri:shar edSchema">
<sharedItem/>
<xsl:apply-templates/>
</d:sharedItems>
</document>
</xsl:template>
</xsl:stylesheet>
And this input XML document:
<?xml version="1.0" encoding="utf-8"?>
<body/>
I think you have hit a bug in XslCompiledTran sform.
Maybe someone of the XML teams picks this up.
Complete stack trace I get with XslCompiledTran sform and that stylesheet
and input XML documents above (simply doing Transform("inpu t.xml",
"result.xml ")):
Unhandled Exception: System.Xml.Xsl. XslTransformExc eption: Cannot
construct namespace declaration xmlns='uri:shar edSchema'. Prefix '' is
already mapped to namespace 'uri:documentSc hema'.
at
System.Xml.Xsl. Runtime.XmlQuer yOutput.WriteNa mespaceDeclarat ion(String
prefix, String ns)
at <xsl:template match="body">(X mlQueryRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator
{urn:schemas-microsoft-com:xslt-debug}current)
at <xsl:template match="/">(XmlQueryRunt ime
{urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator
{urn:schemas-microsoft-com:xslt-debug}current)
at Root(XmlQueryRu ntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Execute(XmlQuer yRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl. ExecuteDelegate .Invoke(XmlQuer yRuntime runtime)
at System.Xml.Xsl. XmlILCommand.Ex ecute(Object defaultDocument ,
XmlResolver dataSources, XsltArgumentLis t argumentList,
XmlSequenceWrit er results)
at System.Xml.Xsl. XmlILCommand.Ex ecute(Object defaultDocument ,
XmlResolver dataSources, XsltArgumentLis t argumentList, XmlWriter
writer, Boolean closeWriter)
at System.Xml.Xsl. XmlILCommand.Ex ecute(XmlReader contextDocument ,
XmlResolver
dataSources, XsltArgumentLis t argumentList, Stream results)
at System.Xml.Xsl. XslCompiledTran sform.Transform (String inputUri,
String resultsFile)
at Test2007010501. Test.Main(Strin g[] args)
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/