xml - Blank line coming when i am using line feed -


my xml show below:

<description> <longdescription>a</longdescription> <longdescription>b</longdescription> <longdescription>c</longdescription> </description> 

and desired output is:

<description> <longdescription>a  b  c</longdescription> </description> 

i using below code fetch output:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0">   <xsl:output omit-xml-declaration="no" indent="yes" />   <xsl:strip-space elements="*" />    <xsl:template match="node()|@*">     <xsl:copy>       <xsl:apply-templates select="node()|@*" />     </xsl:copy>   </xsl:template>    <xsl:template match="description">     <xsl:copy>       <xsl:apply-templates select="*[not(self::longdescription)]" />       <longdescription>         <xsl:apply-templates select="longdescription/text()" />       </longdescription>     </xsl:copy>   </xsl:template>    <xsl:template match="longdescription/text()">     <xsl:if test="position() &gt; 1"></xsl:if>     <xsl:text>&#xa;</xsl:text>     <xsl:value-of select="."/>    </xsl:template> </xsl:stylesheet> 

but using getting result as:

<?xml version="1.0" encoding="utf-8"?> <description> <longdescription> b c</longdescription> </description> 

i want "a" come besides longdescription not in next line.

i have tried using strip , normalize option it's not working.

but these options not working.

can me on possible.

thanks in advance, ankit

i removed new line in longdescription

  <longdescription><xsl:apply-templates select="longdescription/text()" />   </longdescription> 

this template bit strange, should way:

<xsl:template match="longdescription/text()">   <xsl:if test="position() &gt; 1"><xsl:text>&#xa;</xsl:text></xsl:if>   <xsl:value-of select="."/>  </xsl:template> 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -