PDA

View Full Version : XML File Changes - Order changes



MSherman
10-22-2012, 03:20 PM
Hi,

There is an XML file used by dependent software that needs to be edited during install/uninstall. The XML File Changes should be able to do this, and is almost capable. Two issues I am having are:

1) (Major) - The order of the children appears to be alphabetical, instead of what is specified inside of the installer. This is critical because xml files can conform to a schema, order is not always independent. This is causing things to fail.
2) (Minor) - The parser does not recognize cases to use <tag/> for tags with no content, so it replaces everything in the file with ></EndTag>. Not critical, since it's equivilent, but certainly not necessary.

In addition, any information on where this information is in the Direct Editor would be helpful - the XML tables I saw had nothing close to the XPath statements that were in the read only box inside the view.

I searched around on the forums and google and found a little bit about the second issue, written in 2008, and may have found something related to the first one (think it said attributes, though), but little else. Anyone know a fix/workaround, or do I have change to not use this convenient feature??

Thanks,
Matt

DebbieL
10-22-2012, 03:34 PM
1) What sort of changes are you making? Are you configuring the whole XML file in the XML File Changes view? Or just making some changes to some of the nodes?

As it says in the documentation, the XML File Changes view does not enable you to specify the order in which new elements should be listed in the XML file. Therefore, importing only the nodes that you want to modify at run time helps to avoid issues that may occur if your product requires that the elements be listed in a particular order.

If that doesn't meet your requirements, you may want to consider using the Text File Changes view. It lets you specify search-and-replace behavior for content in text files (including XML files). It would not reorder elements in XML files.

2) It sounds like you need to clear the Format XML after changes check box. To find this check box, select the XML file that you are configuring in the XML File Changes view. Then, check the Advanced tab, where you'll find this check box. The following help topic has a description of this check box:
Advanced Tab for an XML File (http://helpnet.flexerasoftware.com/installshield19helplib/helplibrary/XML-AdvancedXMLFile.htm)

MSherman
10-22-2012, 03:43 PM
Debbie,

Thanks for the quick response. I didn't see that in the documentation for XML File Changes, so sorry about that. I still wouldn't expect the end file to look different than the imported view inside of the editor (which shows it in the correct order), but that is no matter. I am adding nodes to the end of a configuration file, not modifying existing ones. The new children are one level down from the root, so it is a simple add.

It would be really useful if the XML File Changes was expanded to write in the order you specify, because xml schemas are not all defined using choose, so child order can matter. Any idea if this is planned for the future?

I am not sure the text file changes will help me, but perhaps I can do some kind of cheating to have it highlight the entire file except the end root tag, and then append my new stuff to the end (before the end root tag). Worth a shot. If not, I will add custom actions using vb scripts like previous versions required.

The format piece does prevent it from wrapping pieces it finds when it rewrites the whole file, but it does not prevent it from adding the ending tags where /> would do.

Thanks,
Matt

DebbieL
10-23-2012, 09:22 AM
If you do try out the Text File Changes view, perhaps you could configure a search to look for the last tag in the file, and replace it with the new code plus the last tag.

The request to be able to specify the order of nodes is logged as issue IOA-000052309 in our tracking system. I'm not sure when this would be implemented.

MSherman
10-31-2012, 09:48 AM
Debbie,

Thanks for adding that to the list of future functionalities.

It also seems to be a bit difficult to add multiple notes. It might be helpful if the entire feature opens up more to allow direct manipulation of the XPath queries.

For instance, If I right click Xml File Changes and do an Import, and my config file looks like:

<Configuration>
<Client id="guid1">
<Class>Classes.Class1</Class>
<Toolbar>
<StandardItem>
<Name>Name1</Name>
<StandardItem>
<Name>Name2</Name>
</Toolbar>
</Client>
<Client id="guid2">
<Class/>
</Client>
</Configuration>

In the above, importing automatically identifies that the two clients are different, but is not able to recognize the standard items are different, and only imports the first one. Unless I'm somehow missing a "query import" type functionality, it seems I'd be forced to generate this manually rather than import the file?

Thanks,
Matt

DebbieL
10-31-2012, 11:45 AM
It sounds like the import functionality is not as advanced as you'd like it to be; it looks at just elements and attributes, not positions. In any case, though, if you need to modify both of those nodes, you can manually add the second one, and tweak the XPath expressions as needed (for example, include [position() = 1] types of qualifiers).