Add XSL files for converting between the new and old profile types. #848
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If you use a new data types in the XML profile like
then such profile does not work in SLE15-SP2 and older. It would be nice to provide some tools for automatic conversion to the old format which would convert it to
Solution
profile_conversions.md
documentCDATA Problem
Although the XSLT conversion should work fine in most cases there is a small problem with the CDATA sections - they are not kept and the data are converted to a string literal (with proper escaping when needed). So the conversion is not exactly 1:1, converting back to the original data types results in losing the CDATA sections (although semantically it is the very same profile).
Unfortunately there is no simple solution, XSLT internally does not track whether the text data was originally a string literal or a CDATA section. We could explicitly specify in XSL which nodes should be outputted as CDATA (it is usually used for add-on URLs), but that would on the other hand add the CDATA always, even when the original file did not use it.
I found a better solution on StackOverflow but that uses a complicated two pass conversion. In the first pass it scans the XML for the CDATA sections and generates a new XSLT for the final conversion which outputs CDATA for that found elements.
But that is too complicated IMHO and still does not cover all cases (e.g. if you once use CDATA and in other case not). So let's use a simple solution.
Testing