hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Whitespace and newline in generated XML

Wed Jan 30, 2019 9:05 am

Hi,

in my AI project, I let the installer modify an XML configuration file, based on user input. I noticed two strange things in the generated XML file which may or may not have the same cause. The XML file is a .NET config file, originally generated by Visual Studio. The main part of this file is the <Application.Properties.Settings> element which has many <setting> sub elements which in turn have one, possibly empty, <value> sub element each. I added the file as regular file and added the XML editor for the same file, as described in https://www.advancedinstaller.com/user- ... files.html. The editor should modify the content of some <setting/value> elements; for four elements, the new value is taken from user input, and for another six, it is hard coded in the installer project.

Problem 1: For those elements whose value is taken from user input, the opening <value> tag becomes <value >, i.e. a space character is added before the right angle bracket (not so for the closing tag which remains <value/>).

Problem 2: One of the fields in the entry dialog can be left empty by the user, its assigned property value is initially defined as "[~]" (without quotation marks). This seems to be the syntax for an empty string. However, if the user leaves this field empty, the respective <value> becomes a single line break, rather than being really empty.

The AI version is 14.6. Thank you for your comments.

Hans

Edit: I read the "Possible new line in XML value ..." on this board but I am sure my cause is different.

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Whitespace and newline in generated XML

Wed Jan 30, 2019 11:21 am

Hello Hans,

I have tested this on the 14.6 version of Advanced Installer but I was not able to reproduce the described behavior.

In order for me to further investigate this, could you please send me a copy of your .AIP file and also a copy of the XML file by e-mail at support at advancedinstaller dot com?

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Whitespace and newline in generated XML

Thu Jan 31, 2019 5:35 pm

Hi Catalin,

I emailed you the project and the input and output XML files.

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Whitespace and newline in generated XML

Mon Feb 04, 2019 8:54 am

Hello Hans,

Thanks for the sent files.

However, I think that you forgot to also attach the .AIP file and the log file to the e-mail. Could you please also send me these?

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Whitespace and newline in generated XML

Mon Feb 04, 2019 11:49 am

you forgot to also attach the .AIP file and the log file
Yes indeed. Sorry for that - I emailed you those files!

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Whitespace and newline in generated XML

Wed Feb 06, 2019 2:45 pm

Hello Hans,

First of all, thanks for the sent files.

After further investigating this, it seems that by setting your property to the "[~]" value in "Install Parameters" page, it actually sets the property to the "New Line" character value, as it can be seen in the log file.

From what I knew, there wasn't any way in which you could initialize a property value to an empty string from "Install Parameters" page. I have to admit that I also was tricked into thinking that there was actually a way of setting a property value to an empty string from "Install Parameters" page.

When creating a property in the "Install Parameters" page, its value is added in the "Property Table". The "Nullable" characteristic of the "Value" column is set to "N" ("No"), which means that the text for the "Value" column may never be Null or an empty string.

Creating a Windows Installer property is quite different than declaring a variable. You can not create an empty property, as stated above. A property can actually have two states:

- it has whatever value beside null / empty string ==> it exists.

- it has a value of null / empty string ==> it does not exist.

With that being said, if you want to have an empty value for a property, simply do not create it.

However, another thing you can do is to use a "Set Installer Property" custom action in which you can set your property to:

Code: Select all

{}
like this:
Set_Installer_Property.PNG
Set_Installer_Property.PNG (18.93KiB)Viewed 6362 times
You may ask yourself now: Is there a difference between not creating the property at all and setting its value to "{}" through a custom action? The answer to this is no, there is no difference. Now you may ask yourself: Why do I need to set the property when I can simply do not create it at all. The answer to this is because it helps you keep track of the used properties from within your project (similar to when you declare a variable in one of your projects).

Hope this helped making things more clear for you now.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Whitespace and newline in generated XML

Thu Feb 07, 2019 9:59 am

Thanks Catalin!

Inspired by your suggestion, I found an easier solution that works for me. Instead of initializing the property to

Code: Select all

[~]
, I initialize it to

Code: Select all

[|]
. The effect is what I want: The respective input field is initially empty, and no line breaks occur, whether or not I type into this field.

One question remains. Why are the

Code: Select all

<value>
tags changed into

Code: Select all

<value >
? This happens independently of whether the property is initialized to

Code: Select all

[~]
or

Code: Select all

[|]
. The whitespace seems to be insignificant for the XML parser but it's strange.

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Whitespace and newline in generated XML

Fri Feb 08, 2019 10:40 am

Hello Hans,
Thanks Catalin!
You are always welcome.
Inspired by your suggestion, I found an easier solution that works for me. Instead of initializing the property
I am glad you found a solution that fits your needs.

In what regards the whitespace, to be honest with you, I am not sure why that happens. Since I was not able to replicate the behavior, it is hard for me to tell what causes it. However, as you have already said, the whitespace should be insignificant for the XML parser, since XML does not have predefined tags (like HTML does, for example).

If possible, can you please try to create a buildable sample which reproduces the behavior and forward it over to me by e-mail at support at advancedinstaller dot com?

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Whitespace and newline in generated XML

Fri Feb 08, 2019 11:54 am

How weird... the bad behaviour has fixed itself in the latest version of the installer... Maybe it had to do with the newlines which I removed?

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Whitespace and newline in generated XML

Fri Feb 08, 2019 1:17 pm

Hello Hans,
How weird... the bad behavior has fixed itself in the latest version of the installer...
I am glad to hear that the bad behavior was fixed.
Maybe it had to do with the newlines which I removed?
That could be the cause, indeed, but to be honest I can not tell for sure since I was not able to reproduce this on our end.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”