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

XML read/write is not idempotent #41

Open
Aliaksei-Tatarynchyk opened this issue Mar 27, 2019 · 0 comments
Open

XML read/write is not idempotent #41

Aliaksei-Tatarynchyk opened this issue Mar 27, 2019 · 0 comments

Comments

@Aliaksei-Tatarynchyk
Copy link
Collaborator

Aliaksei-Tatarynchyk commented Mar 27, 2019

Shaper currently converts xml into yaml with errors, it doesn't able to distinguish child elements and attributes. E.g. if we have the following xml:

<rest-security>
  <default-acl value="Profile$login$restUser:read,write,execute"/>
  <default-acl2>Profile$login$restUser:read,write,execute</default-acl2>
  <default-acl3 value="test">Profile$login$restUser:read,write,execute</default-acl3>
  <default-acl4 value="test">
    <value>Profile$login$restUser:read,write,execute</value>
  </default-acl4>
</rest-security>

It will be converted to yaml:

  rest-security:
    default-acl:
      '@value': Profile$login$restUser:read,write,execute
    default-acl2: Profile$login$restUser:read,write,execute
    default-acl3:
      '@value': test
      '#text': Profile$login$restUser:read,write,execute
    default-acl4:
      '@value': test
      value: Profile$login$restUser:read,write,execute

Output xml after writing this yaml will be:

	<default-acl>
		<key name="@value">Profile$login$restUser:read,write,execute</key>
	</default-acl>
	<default-acl2>Profile$login$restUser:read,write,execute</default-acl2>
	<default-acl3>
		<key name="@value">test</key>
		<key name="#text">Profile$login$restUser:read,write,execute</key>
	</default-acl3>
	<default-acl4>
		<key name="@value">test</key>
		<value>Profile$login$restUser:read,write,execute</value>
	</default-acl4>
</rest-security>

It's drastically different. Also it ignores DTD declaration, e.g. if to put <!DOCTYPE rest-security SYSTEM "dynamosystemresource:/atg/dtds/rest/restSecurity_1.0.dtd"> it will not appear in yaml.

I'd suggest as quick fix - to change parser mapping for .xml files from XMLParser to TextParser. In this case the yaml will be:

test\xmtext.xml: |-
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE rest-security SYSTEM "dynamosystemresource:/atg/dtds/rest/restSecurity_1.0.dtd">

  <rest-security>
    <default-acl value="Profile$login$restUser:read,write,execute"/>
    <default-acl2>Profile$login$restUser:read,write,execute</default-acl2>
    <default-acl3 value="test">Profile$login$restUser:read,write,execute</default-acl3>
    <default-acl4 value="test">
      <value>Profile$login$restUser:read,write,execute</value>
    </default-acl4>
  </rest-security>

And the output xml will be identical to the initial one.

Aliaksei-Tatarynchyk added a commit to Aliaksei-Tatarynchyk/shaper that referenced this issue Apr 2, 2019
Aliaksei-Tatarynchyk added a commit to Aliaksei-Tatarynchyk/shaper that referenced this issue Apr 2, 2019
Aliaksei-Tatarynchyk added a commit to Aliaksei-Tatarynchyk/shaper that referenced this issue Apr 2, 2019
- comment test until the issue will not be fixed fully
Aliaksei-Tatarynchyk added a commit to Aliaksei-Tatarynchyk/shaper that referenced this issue May 27, 2019
- fix CI - change write bytes to just write to be able to write string
Aliaksei-Tatarynchyk added a commit to Aliaksei-Tatarynchyk/shaper that referenced this issue May 27, 2019
- fix test data
- fix CI - change write bytes to just write to be able to write string
- comment test until the issue will not be fixed fully
arno49 pushed a commit that referenced this issue May 27, 2019
- fix test data
- fix CI - change write bytes to just write to be able to write string
- comment test until the issue will not be fixed fully
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

No branches or pull requests

1 participant