Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:24:56+00:00 2026-05-27T20:24:56+00:00

I am seeing some weird behavior (or I am missing something) with the following

  • 0

I am seeing some weird behavior (or I am missing something) with the following nUnit test:

        [Test]
    public void Test() {
        const string works = @"
<doc>
  <simple>simple</simple>
  <ItemDef>
    <Description>
    </Description>
  </ItemDef>
</doc>
";
        const string doesntWork = @"
<doc>
  <simple>simple</simple>
  <ItemDef>
    <Description>
        <TranslatedText>3</TranslatedText>
    </Description>
  </ItemDef>
</doc>
";
        string xsl = @"<?xml version='1.0' encoding='iso-8859-1'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
  <xsl:output indent='yes'/>
  <xsl:template match='simple'>
    <node>
    </node>
  </xsl:template>
</xsl:stylesheet>
";

        TransformXml2(works, xsl);
        TransformXml2(doesntWork, xsl);
    }
    protected static void TransformXml2(string xml, string xsl) {
        XslCompiledTransform transform = new XslCompiledTransform();
        transform.Load(XmlReader.Create(new StringReader(xsl)));
        XmlDocument document = new XmlDocument();
        document.LoadXml(xml);
        XmlReader input = new XmlNodeReader(document.DocumentElement);
        transform.Transform(input, new XsltArgumentList(), XmlTextWriter.Create(new StringBuilder()));
    }

When I run this test, the second TransformXml2 call fails with the following error:

Token Text in state EndRootElement would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment.

The only difference between the two pieces of XML is the following node:

<TranslatedText>3</TranslatedText>

Anyone have any idea what is going on?

Just so you know, I am aware the TransformXml2 call does nothing useful. I just wanted to provide some executable code that demonstrates the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:24:57+00:00Added an answer on May 27, 2026 at 8:24 pm

    The reason is that the second input contains text after the <simple>simple</simple> element that you’re not handling. The default (built-in) template for processing text nodes is outputting that text after the <node></node>, which results in a document that’s not well-formed:

    <node/>
    
    
          3
    

    That’s what the processor is warning you about.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm seeing some weird behavior in php when comparing a double to a string
I am seeing some rather weird behavior with PowerShell, it looks like custom functions
I am seeing some very weird behavior with a set of ListViews that I
All, I am seeing some really weird behavior when I run a query in
I'm seeing a weird error message and am looking for some ideas as to
I'm seeing some code I've inherited that looks like the following: @interface SomeClass (private)
I'm seeing some weird behaviour debugging my C# code - I cant post my
I'm seeing some strange behavior when I run Rails server with rails s -e
I'm seeing some different behavior between g++ and msvc around value initializing non-copyable objects.
I am seeing a weird behavior when I POST using AJAX. When I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.