[Mono-list] Mono not using self closing tags.

MarxWright michael.e.harrison at hotmail.com
Mon Mar 9 08:38:55 UTC 2015


I'm trying to remove the closing tag from my transformed document but it only
creates a newline and full closing tags: 

<item Data="XXX" Data1="123.24" Num="3">
</item>

As I have a lot of data I would prefer: <item Data="XXX" Data1="123.24"
Num="3" />

I cannot seem to find the solution anywhere. To annoy me more it works as
desired on Windows but not when running on Wheezy using mono 2.10.8.1. which
makes me think perhaps a Mono component is causing my trouble. 

Has anyone got any ideas? 

This is the code I use: 

    XmlWriterSettings xmlSettings = new XmlWriterSettings(); 
    xmlSettings.Indent = true; 
    xmlSettings.NewLineChars = "\n"; 
    xmlSettings.OmitXmlDeclaration = true; 

    XmlReader reader = XmlReader.Create(new StringReader(xml)); 

    using (XmlWriter writer = XmlWriter.Create(outputStream, xmlSettings)) 
    { 
         m_SoapXSLT.Transform(reader, writer); 
    } 

    string outStr = outputStream.ToString(); 

Here is a sample from my XSL document: 

<?xml version="1.0" encoding="UTF-8" ?> 

<xsl:stylesheet version="3.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">

<xsl:output method="xml" indent="yes"  omit-xml-declaration="yes"/>

... 
<xsl:if test="self::node()[@type='46']">
    <xsl:element name="elementName">
        <xsl:attribute name="NumItems">
            <xsl:value-of
select="count(self::node()/selections/selection)"/>
            </xsl:attribute>
            <xsl:for-each select="self::node()/items/item">
                <xsl:element name="item">
                    <xsl:attribute name="Data">
                        <xsl:value-of select="@data1"/>
                    </xsl:attribute>
                    <xsl:attribute name="Data1">
                        <xsl:value-of select="@data2"/>
                    </xsl:attribute>
                    <xsl:attribute name="Num">
                        <xsl:value-of select="position()"/>
                    </xsl:attribute>
                </xsl:element>
            </xsl:for-each>
        </xsl:element>
    </xsl:if>
... 

Regards, Mike! 



--
View this message in context: http://mono.1490590.n4.nabble.com/Mono-not-using-self-closing-tags-tp4665600.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list