Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - How to avoid newline [Thread Next] Re: How to avoid newlineTo: NULL Date: 1/2/2007 12:48:00 PM
"Oliver Block" <news200605@b...> wrote in message
news:4vo1ngF1ctl66U1@m......
> Hello,
>
> in my xslt document I apply (besides others) to templates in a row of the
> following form:
>
> <xsl:template match="method/parameter[position() = 1]">
> <xsl:value-of select="attribute::name"/> /* <xsl:value-of
> select="attrbutetype"/> */
> </xsl:template>
>
> <xsl:template match="method/parameter[position() > 1]">
> , <xsl:value-of select="attribute::name"/> /* <xsl:value-of
> select="attrbutetype"/> */
> </xsl:template>
>
>
> I want the output of these two templates appear in a SINGLE ROW. Right now
> they appear in several rows. How can I accomplish that?
>
> tia,
>
> Oliver
>
I've found the best solution to this problem is simply to never leave string
literals lying around inline with the rest of your xsl code. Always place
it inside an xsl:text element. Your code would then look like:-
<xsl:template match="method/parameter[position() = 1]">
<xsl:value-of select="attribute::name"/>
<xsl:text> /* </xsl:text>
<xsl:value-of select="attrbutetype"/>
<xsl:text> */ </xsl:text>
</xsl:template>
<xsl:template match="method/parameter[position() > 1]">
<xsl:text>, <xsl:text>
<xsl:value-of select="attribute::name"/>
<xsl:text> /* <xsl:text>
<xsl:value-of select="attrbutetype"/>
<xsl:text> */ <xsl:text>
</xsl:template>
This allows you to format your XSL in a way that suits readability of the
code. New lines are only copied to the output if they are found in a text
element. To write a text element that represents the end of line use:-
<xsl:text> </xsl:text>
This can help preserve the indentation formating of your XSL code in your
original source code.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
