user5000
user5000

Reputation: 39


 is shown by XSLT

I want print attribute and put some values to it.

Input :

<figure id="fig_1">
 <dis>text</dis>
</figure>

my output:

<image ref="fig_1"
        comment="text the&#xA;                                    "/>

Tried code :

<xsl:template match="dis[parent::figure]">
    <xsl:variable name="fig_name" select="parent::fig/@id"/>
    <image ref="{$fig_name}">
        <xsl:attribute name="comment">
            <xsl:value-of select="text()"/>
        </xsl:attribute>
    </tps:image>
</xsl:template>

I want to remove all &#xA;. How can I do it.

Upvotes: 0

Views: 45

Answers (1)

Ed Bangga
Ed Bangga

Reputation: 13006

use normalize-space() function to remove unnecessary white space.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />        
    <xsl:template match="long-desc[parent::fig]">
        <xsl:variable name="fig_name" select="parent::fig/@id"/>
        <image ref="{$fig_name}">
            <xsl:attribute name="comment">
                <xsl:value-of select="normalize-space(text())"/>
            </xsl:attribute>
        </image>
    </xsl:template>
</xsl:stylesheet>

Upvotes: 1

Related Questions