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

  • Home
  • SEARCH
  • 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 695193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:56:03+00:00 2026-05-14T02:56:03+00:00

I’m trying to transform one XML format to another using XSL. Try as I

  • 0

I’m trying to transform one XML format to another using XSL. Try as I might, I can’t seem to get a result.

I’ve hacked away at this for a while now and I’ve had no success. I’m not even getting any exceptions. I’m going to post the entire code and hopefully someone can help me work out what I’ve done wrong.

I’m aware there are likely to be problems in the xsl I have in terms of selects and matches, but I’m not fussed about that at the moment.

The output I’m getting is the input XML without any XML tags. The transformation is simply not occurring.


Here’s my XML Document:

<?xml version="1.0"?>
<Transactions>
    <Account>
        <PersonalAccount>
            <AccountNumber>066645621</AccountNumber>
            <AccountName>A Smith</AccountName>
            <CurrentBalance>-200125.96</CurrentBalance>
            <AvailableBalance>0</AvailableBalance>
            <AccountType>LOAN</AccountType>
        </PersonalAccount>
    </Account>
    <StartDate>2010-03-01T00:00:00</StartDate>
    <EndDate>2010-03-23T00:00:00</EndDate>
    <Items>
        <Transaction>
            <ErrorNumber>-1</ErrorNumber>
            <Amount>12000</Amount>
            <Reference>Transaction 1</Reference>
            <CreatedDate>0001-01-01T00:00:00</CreatedDate>
            <EffectiveDate>2010-03-15T00:00:00</EffectiveDate>
            <IsCredit>true</IsCredit>
            <Balance>-324000</Balance>
        </Transaction>
        <Transaction>
            <ErrorNumber>-1</ErrorNumber>
            <Amount>11000</Amount>
            <Reference>Transaction 2</Reference>
            <CreatedDate>0001-01-01T00:00:00</CreatedDate>
            <EffectiveDate>2010-03-14T00:00:00</EffectiveDate>
            <IsCredit>true</IsCredit>
            <Balance>-324000</Balance>
        </Transaction>
    </Items>
</Transactions>

Here’s my XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" />
  <xsl:param name="currentdate"></xsl:param>
  <xsl:template match="Transactions">

<xsl:element name="OFX">
    <xsl:element name="SIGNONMSGSRSV1">
        <xsl:element name="SONRS">
            <xsl:element name="STATUS">
                <xsl:element name="CODE">0</xsl:element>
                <xsl:element name="SEVERITY">INFO</xsl:element>
            </xsl:element>
            <xsl:element name="DTSERVER"><xsl:value-of select="$currentdate" /></xsl:element>
            <xsl:element name="LANGUAGE">ENG</xsl:element>
        </xsl:element>
    </xsl:element>
    <xsl:element name="BANKMSGSRSV1">
        <xsl:element name="STMTTRNRS">
            <xsl:element name="TRNUID">1</xsl:element>
            <xsl:element name="STATUS">
                <xsl:element name="CODE">0</xsl:element>
                <xsl:element name="SEVERITY">INFO</xsl:element>
            </xsl:element>
            <xsl:element name="STMTRS">
                <xsl:element name="CURDEF">AUD</xsl:element>
                <xsl:element name="BANKACCTFROM">
                    <xsl:element name="BANKID">RAMS</xsl:element>
                    <xsl:element name="ACCTID"><xsl:value-of select="Account/PersonalAccount/AccountNumber" /></xsl:element>
                    <xsl:element name="ACCTTYPE"><xsl:value-of select="Account/PersonalAccount/AccountType" /></xsl:element>
                </xsl:element>
                <xsl:element name="BANKTRANLIST">
                    <xsl:element name="DTSTART"><xsl:value-of select="StartDate" /></xsl:element>
                    <xsl:element name="DTEND"><xsl:value-of select="EndDate" /></xsl:element>

    <xsl:for-each select="Items/Transaction">
                    <xsl:element name="STMTTRN">
                        <xsl:element name="TRNTYPE"><xsl:choose><xsl:when test="IsCredit">CREDIT</xsl:when><xsl:otherwise>DEBIT</xsl:otherwise></xsl:choose></xsl:element>
                        <xsl:element name="DTPOSTED"><xsl:value-of select="EffectiveDate" /></xsl:element>
                        <xsl:element name="DTUSER"><xsl:value-of select="CreatedDate" /></xsl:element>
                        <xsl:element name="TRNAMT"><xsl:value-of select="Amount" /></xsl:element>
                        <xsl:element name="FITID" />
                        <xsl:element name="NAME"><xsl:value-of select="Reference" /></xsl:element>
                        <xsl:element name="MEMO"><xsl:value-of select="Reference" /></xsl:element>
                    </xsl:element>
    </xsl:for-each>

                </xsl:element>
                <xsl:element name="LEDGERBAL">
                    <xsl:element name="BALAMT"><xsl:value-of select="Account/PersonalAccount/CurrentBalance" /></xsl:element>
                    <xsl:element name="DTASOF"><xsl:value-of select="EndDate" /></xsl:element>
                </xsl:element>
            </xsl:element>
        </xsl:element>
    </xsl:element>
</xsl:element>
  </xsl:template>
</xsl:stylesheet>

Here’s my method to transform my XML:

public string TransformToXml(XmlElement xmlElement, Dictionary<string, object> parameters)
{
    string strReturn = "";

    // Load the XSLT Document
    XslCompiledTransform xslt = new XslCompiledTransform();
    xslt.Load(xsltFileName);

    // arguments
    XsltArgumentList args = new XsltArgumentList();
    if (parameters != null && parameters.Count > 0)
    {
        foreach (string key in parameters.Keys)
        {
            args.AddParam(key, "", parameters[key]);
        }
    }

    //Create a memory stream to write to
    Stream objStream = new MemoryStream();

    // Apply the transform
    xslt.Transform(xmlElement, args, objStream);

    objStream.Seek(0, SeekOrigin.Begin);

    // Read the contents of the stream
    StreamReader objSR = new StreamReader(objStream);

    strReturn = objSR.ReadToEnd();

    return strReturn;
}

The contents of strReturn is an XML tag (<?xml version="1.0" encoding="utf-8"?>) followed by a raw dump of the contents of the original XML document, stripped of XML tags.

What am I doing wrong here?

  • 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-14T02:56:03+00:00Added an answer on May 14, 2026 at 2:56 am

    I have verified that the provided transformation when applied with XslCompiledTransform on the provided XML document produces very meaningful (probably the desired) output.

    Let me guess: maybe the provided XML is not the same as the one used in practice? Maybe you have a default namespace?

    If so, you need to match nodes in the default namespace — not in “no namespace”.

    You can easily verify if the XmlElement that you provide is in a namespace: inspect/print its NamespaceURI property.

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

Sidebar

Ask A Question

Stats

  • Questions 349k
  • Answers 349k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For general information about objects in memory I would suggest… May 14, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer In your controller, the corresponding value is $this->pageTitle. UPDATE Oops,… May 14, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer Using css only you cannot do this. So your proposed… May 14, 2026 at 6:43 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.