Jump to content

thousand separator with xsl


Osman

This topic is 6995 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi,

How can i format my number fields into my desired format. I want to make my number fields with thousand separator as i can make in FileMaker number settings.

example

raw data : 8527863,45

formatted data : 8.527.863,45

Thanks

Adam Djuby

Link to comment
Share on other sites

For this you need the xsl:decimal-format element ("top-level element") and the XSLT format-number() function.

See XSLT 1.0 specification of W3C.

After <xsl:stylesheet ...> and before <xsl:template ...>, define a named format:

<xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/>

For your numbers, use then:

<xsl:value-of select="format-number(Xpath-to-your-field-with-number,'#.##0,00','european')"/>

Martin

Link to comment
Share on other sites

Not true! I had tested it before i wrote my post. Works perfectly. This has nothing to do with FM6 or 7, this is a function in Xalan, conforming to the W3C XSLT 1.0 standard.

You must use xsl:decimal-format and format-number() in conjunction. Just follow the receipt I have given above.

I beleve you have test before you have post.

I too !

In attachement : my (very simple) xml and xsl doc.

When I test it with Oxygen, the number "1234.5" is tranformed to "1.234,50".

When I drag and drop the xml document onto the FileMaker Developer 7.0v3 icon, using the xsl doc, the result = "1234.5" and that's not ok.

number.zip

Link to comment
Share on other sites

Ah, I see. So both of us are right. I thought of exporting and web publishing (I tested the functions on a web published database), you of importing.

The problem is that the FMPXMLRESULT grammar has no definition for number formats.

When the number field is created upon importing, FM just sets it to general formatting and overrides the format specified in the XSLT.

Let's Adam decide what he needs really.

Martin

Link to comment
Share on other sites

FileMaker Inc. deliberately disabled the xsl:number-format in Xalan becaus you can set the Format in FileMaker itself (use format of current layout). So there's no need for the number format function for export.

For XML imports, the decimal separator is a problem. See my filemaker2mysql example at FileMaker.com.

...

...

--

'

...

I guess the decimal separator from the date-format, then do a translate(',.', '.,'). Any subsequent number-formatting is then applied within fileMaker

Link to comment
Share on other sites

oops, wher's the xml gone?

next try, now encoded:

...

<xsl:template match="fmp:FMPXMLRESULT">

<xsl:variable name="dateformat" select="fmp:DATABASE/@DATEFORMAT" />

...

<xsl:when test="/*/*/fmp:FIELD[$pos]/@TYPE = 'NUMBER'">

<xsl:if test="$dateformat = 'd.M.yyyy'">

<xsl:value-of select="number(translate(fmp:DATA,'.,',',.'))" />

</xsl:if>

<xsl:if test="$dateformat = 'M/d/yyyy'">

<xsl:value-of select="number(fmp:DATA)" />

</xsl:if>

</xsl:when>

...

Link to comment
Share on other sites

To clarify: I spoke of FMS7A custom web publishing, I tested an example on my own custom web published databases according to the receipt I gave before, and it works. xsl:decimal-format and the XSLT format-number() function are NOT DISABLED in the Xalan component of FMS7A.

Martin

Update: "Emotions" removed. Interesting to see that FM Inc. uses different Xalan versions, but clear if one considers all the fmxslt: extension functions built into FMS7A.

Link to comment
Share on other sites

This topic is 6995 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.