CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: XSLT.Transform

  1. #1
    Join Date
    Nov 1999
    Location
    Malmoe, Sweden
    Posts
    112

    XSLT.Transform

    Hi!

    I'm new to XML and XSLT and need to transform some XML into other XML file in a .NET project. I use an XmlTextWriter to output the result. When I call Transform method of the XslTransform I can filter out some data but I don't get the Prolog (XML version="...).

    I shouldn't have to do anything with the XmlWriter object between creation and use by the Transform method, should I? If I call WriteStartDocument() and WriteEndDocument() before and after Transformation I get an InvalidOperationException saying:

    "Token Content in state Prolog would result in an invalid XML document."

    Stack Trace:

    at System.Xml.XmlTextWriter.AutoComplete(Token)
    at System.Xml.XmlTextWriter.WriteString(String)
    at System.Xml.Xsl.WriterOutput.RecordDone(RecordBuilder)
    at System.Xml.Xsl.RecordBuilder.TheEnd()
    at System.Xml.Xsl.Processor.Execute()
    at System.Xml.Xsl.XslTransform.Transform(XPathNavigator, XsltArgumentList, XmlWriter, XmlResolver)
    at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable, XsltArgumentList, XmlWriter)

    Any ideas what may cause this?

    Very greatful for any hints!

    Magnus

  2. #2
    Join Date
    Dec 2003
    Location
    Republic of Ireland
    Posts
    383
    If I got you right you should use XmlWriter.WriteProcessingInstruction Method

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Re: XSLT.Transform

    That was the perfect solution. Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured