XML invisible characters on stage!

Automatically translated from English

Default End Of Line character and Byte Order Mark usage in text files have been modified in 4D v19 R2. With 4D v19 R3, 4D extends this behavior to XML files. Let’s see how.

This former blog-post was dedicated to modification on default End Of Line (EOL) character and Byte Order Mark (BOM) usage in text files.
Following the best practices described in it, 4D now extends the text files behavior to XML files written using DOM and SAX commands.

NEW BEHAVIORS

On macOS, XML files were written by default with CR as EOL when using DOM commands, and the two characters CRLF when using SAX commands. With the new behavior, XML files are written with LF as EOL, using DOM and SAX commands. This will standardize the behavior between DOM and SAX, and improve compatibility with version control systems like Git, which need to use LF as EOL character.
There are no changes on Windows for the EOL character since CRLF is correctly managed by version control systems like Git.

On all platforms, XML files are now written without BOM, using DOM and SAX commands. As UTF-8 has nearly become the standard text file format, the BOM is less and less used. So, 4D still follows the current best practices.

COMPATIBILITY SETTINGS

No changes will appear when moving an existing project or database to 4D v19 R3.

If your project or database was created with a former version than 4D v19 R2, the following compatibility settings will appear to activate the new behaviors:

⚠️   When opened in 4D v19 R3, projects or databases created with 4D v19 R2 behave differently regarding default EOL character and BOM management in XML documents only. Even though the new behavior is active and the compatibility options are available since 4D v19 R2 for text files, this new behavior is available only since 4D V19 R3 for XML files.

STAY IN CONTROL

If you want to define yourself which EOL character to use when writing an XML file using DOM or SAX commands, the XML SET OPTIONS command admits now the new selector XML line ending, which can get the following values: XML default, XML CR, XML LF or XML CRLF.

In the same way, you can define yourself if a BOM is inserted in the XML file using DOM or SAX commands by setting the new selector XML BOM in the XML SET OPTIONS command. This selector admits three values: XML default, XML enabled or XML disabled.

Of course, you can use these two new selectors with the XML GET OPTIONS command to know which behavior is currently in use.

⚠️   Since SAX file lines are written directly at each statement, if you need to set the BOM and/or EOL options, you must call the XML SET OPTIONS command before the first SAX writing command.

Avatar

• Product Owner •

Damien Fuzeau has joined the 4D Product team in February 2019. As a Product Owner, he is in charge of writing user stories, then translating them to functional specifications. His job also entails making sure that the feature implementations delivered are meeting the customer needs.

Damien is graduated from the University of Nantes in software engineering. He spent more than 23 years in its former company, first as developer (discovering 4D in 1997), and later as engineering manager and software architect. This company is a 4D OEM partner and deployed 4D based business softwares for thousands users, on hundreds servers. So, Damien is used to 4D development and deployment in a multi-language context.