Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XSL files for converting between the new and old profile types. #848

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

lslezak
Copy link
Member

@lslezak lslezak commented Sep 20, 2022

Problem

If you use a new data types in the XML profile like

  <confirm t="boolean">true</confirm>

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

  <confirm config:type="boolean">true</confirm>

Solution

  • Provide XSL files for converting the profile
  • See more details in the new profile_conversions.md document

CDATA 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

  • Tested manually with several testing XML profiles, both conversions work fine

@coveralls
Copy link

coveralls commented Sep 20, 2022

Coverage Status

Coverage remained the same at 68.593% when pulling b2b496d on xsl_type_conversion into 53cf143 on master.

@lslezak lslezak force-pushed the xsl_type_conversion branch 2 times, most recently from 66a1083 to 17c4961 Compare December 21, 2022 14:23
…sc#1206597)

Allow to easily convert profiles between "config:type" <=> "t",
e.g. simplify the profile or make the profile to work in SLE15-SP2 or older.
@lslezak lslezak changed the title [PoC] Add XSL files for converting between the new and old profile types. Add XSL files for converting between the new and old profile types. Dec 21, 2022
Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this XSLT looks alien to me, it looks good. These are very handy scripts. Thanks!

@lslezak lslezak merged commit 5daf4ba into master Dec 21, 2022
@lslezak lslezak deleted the xsl_type_conversion branch December 21, 2022 15:04
@yast-bot
Copy link
Contributor

✔️ Public Jenkins job #244 successfully finished
✔️ Created OBS submit request #1044092

@yast-bot
Copy link
Contributor

✔️ Internal Jenkins job #154 successfully finished
✔️ Created IBS submit request #286900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants