Re: [xslt] Question about white space output



srperan@sherlock.dif.um.es writes:
> When we process this, we obtain this output :
> 
> typedef sequence < sequence < sequence < long >>>secuencia2;
> 
> When we need :
> 
> typedef sequence < sequence < sequence < long > > > secuencia2;
> 
> Now, the question is, how can I insert the white spaces between symbols?
> symbols?
> 
Well, this is basically a xslt question and is more suited to a general xslt
mailing list than to this list, which is specifically on libxslt.

Unfortunately you left out relevant information again (what output-encoding
does your stylesheet provide? How do you process?)
Using copy & paste from your mail and adding what's needed I get
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output indent="no" encoding="ISO-8859-1" method="text"/>

  <xsl:strip-space elements="sequence"/>
<xsl:template match="sequence">
<xsl:choose>
	<xsl:when test="@name">typedef sequence &lt;<xsl:apply-templates
	select="sequence"/><xsl:if test="@max">,<xsl:value-of
	select="@max"/></xsl:if> &gt; <xsl:value-of
	select="@name"/>;</xsl:when>
		<xsl:when test="@type">sequence &lt;<xsl:value-of
		select="@type"/><xsl:if test="@max">, <xsl:value-of
		select="@max"/></xsl:if> &gt; </xsl:when>
			<xsl:otherwise>sequence &lt;<xsl:apply-templates
			select="sequence"/><xsl:if test="@max">,
			<xsl:value-of select="@max"/></xsl:if>&gt;
			</xsl:otherwise>
			</xsl:choose> <xsl:value-of select="@nombre"/>
</xsl:template>

</xsl:stylesheet>

and xsltproc (2.5.4) gives
typedef sequence <sequence <sequence <long > >
                         > secuencia2;

which isn't what you want, but isn't what you get either.

I guess your stylesheet got modified during mail.

If I use 
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output indent="no" encoding="ISO-8859-1" method="text"/>
  <xsl:strip-space elements="sequence"/>
<xsl:template match="sequence">
<xsl:choose>
	<xsl:when test="@name">typedef sequence &lt; <xsl:apply-templates
	select="sequence"/><xsl:if test="@max">,<xsl:value-of
	select="@max"/></xsl:if> &gt; <xsl:value-of
	select="@name"/>;</xsl:when>
		<xsl:when test="@type">sequence &lt; <xsl:value-of
		select="@type"/><xsl:if test="@max">, <xsl:value-of
		select="@max"/></xsl:if> &gt; </xsl:when>
			<xsl:otherwise>sequence &lt; <xsl:apply-templates
			select="sequence"/><xsl:if test="@max">,
			<xsl:value-of select="@max"/></xsl:if> &gt; </xsl:otherwise>
			</xsl:choose> <xsl:value-of select="@nombre"/>
</xsl:template>
</xsl:stylesheet>

I get
typedef sequence < sequence < sequence < long >  >  > secuencia2;
which seems to be what you want (unless you have a problem with two
blanks).

If you didn't specify ISO-8859-1 output encoding it's no surpise that
you found something like 'Â ' for nbsp since the default encoding is
utf8 and that's nbsp's utf8 represantation.

So it's just adding the WS to the text in the stylesheet apropiatly.
(And perhaps knowing that pure whitespace between elements should be
put into <xsl:text>...</xsl:text>; otherwise it's removed).

HTH
	Morus



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]