Search code examples
vb.netxslt

Space Character showing as symbol in HTML when converting to XML to HTML with XSLT


I have some code using VB.net to converts XML to HTML file using an XSLT stylesheet.

 Dim xslt As New XslCompiledTransform(True)
 xslt.Load(stylesheet)
 Dim HTMLoutputFile As String = TempDirectory + "test.html"
 If File.Exists(HTMLoutputFile) Then
    File.Delete(HTMLoutputFile)
 End If
 Dim outputStream As New FileStream(HTMLoutputFile, FileMode.Append)
 xslt.Transform(XMLoutputFile, Nothing, outputStream)
 outputStream.Close()

THE XLST has   to insert white spaces, but when opening the HTML code I get strange characters showing. The character is a black diamond symbol with a question mark in the middle.

I tried using   in the XSLT, but I get the same thing.

How can I get a whitespace instead of the weird characters?

Part of the XLST

<span class="Normal">   
        <xsl:for-each select="//reasons/Addendum">
            <b>Addendum Note</b>&#160;(<xsl:value-of select="sectionEnctInfo/NoteCreator"/>;
            <xsl:value-of select="sectionEnctInfo/datetimeStamp"/>)<br/>
            <xsl:call-template name="multilineNote">
                <xsl:with-param name="theNoteItemNode" select="noteItem"/>
            </xsl:call-template>
            <xsl:if test="noteItem/imageNoteFile != ''">            
                <br/><img src="{noteItem/imageNoteFile}"></img><br/>
            </xsl:if>
            <br/>
        </xsl:for-each>
    </span>
        

Solution

  • My suspicion would be that the XSLT processor is writing the output HTML file using one encoding, and you are opening it for reading using some software that is assuming a different encoding.

    Check any encoding specified in an xsl:output declaration in the stylesheet; and open the file using a hex editor to see how the characters are actually encoded.