Get a carriage return in empty elements .net xmltransform

Posted on 2004-10-28
Last Modified: 2008-02-01
Is there any way around this short of telling the xmlwriter not to indent?
I have a process that send an xml doc to a cust who changes some data and
returns it.  It gets rejected on the resubmit because of the problem below.

I have an xslt trans. I am transforming it with the .net transformation
object when it hits an empty element it reurns something like this.
instead of
<email></email> or <email/>

the .net objects seems to ignore  <xsl:strip-space elements="*" />.

Question by:kpejr
    LVL 4

    Assisted Solution

    Apart from the fact that it is ignoring your strip-space directive you could possibly run a replace on "> </" with "></" it is definately a work around but the best I could think of short term.

    LVL 6

    Accepted Solution

    In your XSLT, try to write the code that transforms for <email> in one line. That is for example:

    <email><xsl:value-of select="."></email>

    Have fun.

    Author Comment

    I tried the replace before, the problem is you would have to parse before you replaced or it replaces the cr after and end tag for a block as well as the ones you want to replace.

    I just tried <email><xsl:value-of select="."></email> and it still adds the cr.


    Author Comment

    Figured it out. You have to inherit the xmltextwriter and override WriteFullEndElement with this:

        Public Overrides Sub WriteFullEndElement()
        End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now