Tech Tip: SVG and Decimal Numbers
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: December 9, 2016
4D allows SVG images to be used and even allows the images to be modified. SVG files are in XML structure and can also be modified using XML commands. When modifying the attributes make sure that the decimal numbers, if represented as text, are separated by periods (.) and not commas (,). This is because the SVG parser only reads decimal numbers separated by periods.
If not you can get a Runtime Error of the following format
SVG parser: Bad format for '{attribute name}' value: xpath={xpath of location causing error}
Such as the following example:
SVG SET ATTRIBUTE(*;"pictObject";elem_ID;"transform";"translate(2,5 10,5)") |
Will generate the error:
SVG parser: Bad format for 'transform' value: xpath=/@id={elem_ID}/@transform
The SVG parser only accepts period decimal separators like the following format:
SVG SET ATTRIBUTE(*;"pictObject";elem_ID;"transform";"translate(2.5 10.5)") |
A way to fix this is use the string function passing "&xml" as a format to always use "." as a separator:
$numString:=String($realNum;"&xml") |
Commented by Tai Bui on December 14, 2016 at 8:54 AM
Hi Keith,
Thank you for the notification. Yes, those were supposed to be periods. The asset has been modified to reflect this.
Commented by Keith Culotta on December 14, 2016 at 6:39 AM
The second example of "SVG SET ATTRIBUTE" shows only commas. Were periods intended?
Viewing the page with macOS 10.12.2