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 8190825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:45:52+00:00 2026-06-07T03:45:52+00:00

I have been tasked with testing some XSLT code to ensure that it is

  • 0

I have been tasked with testing some XSLT code to ensure that it is outputting what we need. The problem is that the column data appears, but the actual data itself disappears. Since I have never dealt with XSLT or csv files before, I am at a loss of why this is happening. Here is XSLT:

    public const string XSLT = @"
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform""
    xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" exclude-result-prefixes=""msxsl"">  
<xsl:output method=""text"" encoding=""us-ascii"" />

  <xsl:template match=""DataRow"">IncidentNumber,IncidentDate,LocationCode,Location,DateReported,DaysFromWork,OSHAReportable, TotalDaysFromWork,InjuredEmployeeName,EmployeeType,ReportedBy,Witness,ThisIncidentIs,InjuryOrIllnessType,Hospital, Recurring,CauseOfInjury,InjuryType,BodyPartInjured,BodyFluid,AECIPremises,
<xsl:apply-templates select=""Derate""/>

</xsl:template>

<xsl:template match=""Data"">
   <xsl:for-each select=""*"">
     <xsl:if test=""position() != last()"">
       <xsl:text>'</xsl:text>
       <xsl:value-of disable-output-escaping=""yes"" select="".""/>
       <xsl:text>'</xsl:text>
      <xsl:value-of select=""','""/>
     </xsl:if>
     <xsl:if test=""position() = last()"">
     <xsl:text>'</xsl:text>
      <xsl:value-of disable-output-escaping=""yes"" select="".""/>
     <xsl:text>'</xsl:text>
     </xsl:if>
 </xsl:for-each>,
</xsl:template>
</xsl:stylesheet>
";   

Here is my test method:

[TestMethod]
[DeploymentItem("app.config")]
public void OneDayTest()
{
     var target = new Harvester();
     var config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap 
            { ExeConfigFilename = @"app.config" }, ConfigurationUserLevel.None);
     target.ConfigureHarvester(config);            
     var results = target.Harvest(new HarvestTargetTimeRangeUTC{StartTimeUTC = new DateTime(2012, 1, 1).ToUniversalTime(),
            EndTimeUTC = DateTime.Now.ToUniversalTime()});           

     XmlSchemaSet set = new XmlSchemaSet();
     set.Add(XmlSchema.Read(XElement.Parse(Constants.Xsd).CreateReader(), (o, e) => { }));
     bool valid = true;
     (new XDocument(results)).Validate(set, (o, e) =>
     {
         valid = false;
     });
     Assert.IsTrue(valid);

     XslCompiledTransform transformer = new XslCompiledTransform();
     transformer.Load(XElement.Parse(Constants.XSLT).CreateReader());
     var stream = new MemoryStream();
     transformer.Transform(results.CreateReader(), null, new StreamWriter(stream));
     stream.Position = 0;
     File.WriteAllBytes("UnsubmittedWorkmansCompIncidentsReportID.csv", stream.ToArray());            
}

In both my XSLT and my test method I am using a predefined company format. really all I did was tweak it to fit my data. it works in the other ones with no problem so I’m not sure why it’s not working here.

When I debug it, the data is present at this line:

transformer.Transform(results.CreateReader(), null, new StreamWriter(stream)); 

but after that I don’t know what happens.

If anyone could share some light on this I would appreciate it.

  • 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-06-07T03:45:54+00:00Added an answer on June 7, 2026 at 3:45 am

    The problem was a mismatch in my template which I failed to notice the first 1000 times I looked at it. After walking away for a bit, coming back and reading Dimitre Novatchev comments I found the problem.

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

Sidebar

Related Questions

I have been tasked with refactoring some components that used xmlbeans to now make
I have a bit of code that I have been tasked with converting to
Here is the problem I am facing. I have been tasked with testing the
I have been tasked with producing a analytic tool for some of the data
I have been tasked with testing the contents of several pop-ups throughout our application.
I have been tasked with converting some scripts referencing an Informix database to be
I have been tasked with designing my web services client code to use the
I'm part of a testing team and have been tasked with behaving badly using
I have been tasked with writing an ADP application using Access. The back-end data
I have been tasked with looking for a performance testing solution for one of

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.