Reputation: 2067
I have a code which generates a text file using xslt.
It's a rather large amount of data to paste in here so I'll try and only past relevant data.
I have a template which looks like this and this is my starting point
<xsl:template match="addrmap[not(@name='ADDRMAP_NAME_NOT_USED')]">
<xsl:result-document href="{$OUTPUT_DIR}/{@name}_defs_p.vhd">
<xsl:call-template name="vhdl_header">
<xsl:with-param name="block" select="."></xsl:with-param>
</xsl:call-template>
<xsl:text>
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.pk_avalon_mm_extif_defs;
</xsl:text>
<xsl:text>Test 2</xsl:text><xsl:text>
</xsl:text>
<xsl:variable name="offset" select="rdt:all2dec(rdt:resolve_offset(./@offset))"/>
<xsl:text>Test 3</xsl:text><xsl:text>
</xsl:text>
<xsl:apply-templates mode="map">
<xsl:with-param name="offset" select="$offset"/>
</xsl:apply-templates>
</xsl:call-template>
</xsl:result-document>
</xsl:template>
<xsl:template match="enum" mode="map">
<xsl:text>Test 4</xsl:text><xsl:text>
</xsl:text>
<xsl:text>Test 5</xsl:text><xsl:text>
</xsl:text>
</xsl:template>
I am using the expression below to track how text is written to my file
<xsl:text>Test #</xsl:text><xsl:text>
</xsl:text>
Running my code "Test 2" and "Test 3" gets print correctly with no indentation and right after each other. Now "Test 4" gets printed with and Indentation of 4 and two lines below "Test 3". "Test 5" is also printed correctly IE no indentation and one the next line after "Test 4". It looks like this
Test 2
Test 3
Test 4
Test 5
I cannot find why it does this. It looks to me its something that happens when entering the template. because I have a second template execute after this which behaves similar.
If I now take and removes the xsl:text and just have the text raw.
<xsl:template match="enum" mode="map">
Test 4<xsl:text>
</xsl:text>
<xsl:text>Test 5</xsl:text><xsl:text>
</xsl:text>
</xsl:template>
It looks a little different
Test 2
Test 3
Test 4
Test 5
now "Test 4" have the right indentation however it is now 3 lines below "Test 3"
I hope this makes sense.
I am using oXygen but I cant seem to debug my way out of this one
Regards
Upvotes: 0
Views: 86
Reputation: 167516
Consider to reduce your problems to minimal but complete samples to allow us to reproduce the problem. So far we can only guess that xsl:apply-templates mode="map"
which processes all child nodes (including text nodes) outputs some text nodes from the input, either through your own templates or as the built-in templates or your xsl:mode
settings do that. But you haven't shown any input.
If you only want to process enum
elements you can try <xsl:apply-templates select="enum" mode="map"/>
, if you only want to process child elements but not text nodes use select="*"
. A more radical approach might be to strip white space with xsl:strip-space
.
Upvotes: 1