Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How to avoid newline

From: "Anthony Jones" <Ant@------------.--->
To: 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>&#10;</xsl:text>

This can help preserve the indentation formating of your XSL code in your
original source code.








transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent