[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] XSL output problem
Subject: Re: [xsl] XSL output problem From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Sat, 9 Feb 2002 12:35:23 +0000 |
Hi Arief, > <xsl:template name="create_points"> > <xsl:param name="DIV"/> > <xsl:param name="MinY"/> > <xsl:param name="ScaleY"/> > <xsl:param name="intervalY"/> > > <xsl:variable name="pointlist"> > <xsl:for-each select="$DIV/*" xml:space="preserve"> > <xsl:number value="./cgr" grouping-size="3"/>,<xsl:number = > value="((@Depth - $MinY) div $ScaleY) * $intervalY" > grouping-size="3"/><xsl:value-of select="' '"/> > </xsl:for-each> > </xsl:variable> > <xsl:value-of select="$pointlist"/> > </xsl:template> > > The problem is, ... I got the polyine tag with its attributes, but > sometimes ... the points value attribute is cut in the middle and the > rest of value is in the new line, for example : > <polyline points=3D"34.67,23.45 56.88,2 > .45 88.99 /> There are a couple of things that are a little strange here. The first is the fact that you're using xsl:number to format numbers, but seem to be trying to format *decimal* numbers through this method. The xsl:number instruction is designed for handling integers; processors should round whatever number you give them to an integer before formatting it. I think that just writing out the numbers as they are should give you the correct formatting, so doing: <xsl:value-of select="number(cgr)" /> <xsl:text>,</xsl:text> <xsl:value-of select="((@Depth - $MinY) div $ScaleY) * $intervalY" /> <xsl:text> </xsl:text> You could use format-number() if you wanted a certain minimum number of digits before or a certain maximum number of digits after the decimal point, or if you want to group the digits (though I doubt that you want to group the digits, since ',' is taken as a separator between coordinates (or pairs of coordinates) in SVG. The other thing that might be causing you problems is the presence of the xml:space="preserve" on the xsl:for-each. Preserving whitespace within an XSLT element means that any whitespace in the stylesheet *is* included in the result document. So if you have line breaks or tabs to make your code readable, those line breaks and tabs get carried over to the result that you get. This *could* be what's causing the line breaks in your result, so I'd try getting rid of it and see what happens. Just use: <xsl:for-each select="$DIV/*"> <xsl:value-of select="number(cgr)" /> <xsl:text>,</xsl:text> <xsl:value-of select="((@Depth - $MinY) div $ScaleY) * $intervalY" /> <xsl:text> </xsl:text> </xsl:for-each> However, this doesn't explain why you'd get a line break in the *middle* of a number, which is what you illustrated as your result. Are you sure that the line break is actually present in the document, and doesn't just occur because you're viewing the document in an editor that wraps long lines? If you really do get line breaks occurring in the middle of your attribute values, especially if they're included in places where there's no whitespace in the value that you generate, then it's a big bug in the serialization carried out by your XSLT processor, and you should report it. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSL output problem, Arief | Thread | [xsl] Global variable in included s, Andrey Astakhov |
[xsl] Layers, Sarath Kumar Artham | Date | Re: [xsl] Sorting Problem, Jeni Tennison |
Month |
Keywords