cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lorenzo De Sio <l.de...@w4b.it>
Subject R: MySQL Numbers and Xalan...
Date Mon, 15 Jul 2002 14:42:42 GMT
Thanks, Joerg. 

I wrote a small "quick and dirty" stylesheet to perform such a
transformation, though I suspect something happening in the SQLTransformer
to convert numbers in the bad format, since MySQL, when directly queried,
outputs conformant numbers.

To Bert: thanks for the suggestion, but I'm working on a complex pipeline
which forces me to use the SQLTransformer :-))

To anyone who could be interested:
a *quick and dirty* XSL to convert 1.434343E8-like *integer* numbers to
XSLT/XPATH compliant (e.g. 1.434343E8 -> 143434300):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/ | @* | node()">
	<xsl:choose>
		<xsl:when test="(substring(.,2,1)='.') and
(substring-after(.,'E')!='')">
			<xsl:element name="{local-name()}">
			<xsl:variable name="number"
select="substring-before(.,'E')"/>
			<xsl:variable name="pow">1<xsl:call-template
name="for.loop">
					<xsl:with-param
name="i">1</xsl:with-param>
					<xsl:with-param name="count"
select="substring-after(.,'E')"/>
				</xsl:call-template></xsl:variable>
			<xsl:value-of select="$number * $pow"/>
			</xsl:element>
		</xsl:when>
		<xsl:otherwise>
			<xsl:copy>
		      <xsl:apply-templates select="@* | node()"/>
		    </xsl:copy>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
<xsl:template name="for.loop">
	<xsl:param name="i"/>
	<xsl:param name="count"/>
	<xsl:if test="$i &lt;= $count">0</xsl:if>
	<xsl:if test="$i &lt;= $count">
		<xsl:call-template name="for.loop">
			<xsl:with-param name="i">
				<!-- Increment index-->
				<xsl:value-of select="$i + 1"/>
			</xsl:with-param>
			<xsl:with-param name="count">
				<xsl:value-of select="$count"/>
			</xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

-----Messaggio originale-----
Da: Joerg Heinicke [mailto:joerg.heinicke@gmx.de]
Inviato: lunedì 15 luglio 2002 14.44
A: cocoon-users@xml.apache.org
Oggetto: Re: MySQL Numbers and Xalan...


It's not a valid number in XSLT/XPATH:

http://www.w3.org/TR/xpath#NT-Number

A number may only consist of digits and '.'. You either have to convert it 
before transformation or search for a stylesheet which transforms such a 
number to a conformant one.

Regards,

Joerg

Lorenzo De Sio wrote:
> Hi all,
> 
> I've got the following problem (on C2.0):
> 
> a rowset generated by the SQLTransformer (which seems to me to not allow
> specific control over column format) contains rows like these:
> 
>   <row>
>   <nome>Totale Toscana</nome> 
>   <costogesttotale>4.6985818E8</costogesttotale> 
>   <costooperatori>6.79535678E8</costooperatori> 
>   <entraterette>6.01985915E8</entraterette> 
>   <altreentrate>1.26699997E8</altreentrate> 
>   <dummy>65</dummy> 
>   </row>
> 
> the problem is that Xalan doesn't recognize these numeric values as
numbers,
> not allowing me to apply any number formatting.
> 
> Any ideas?
> 
> 
> Thanks in advance,
> 
> L:


-- 

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message