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

Spaces between elements breaks pretty_print #84

Closed
deyanstoykov opened this issue Nov 3, 2016 · 5 comments
Closed

Spaces between elements breaks pretty_print #84

deyanstoykov opened this issue Nov 3, 2016 · 5 comments
Labels

Comments

@deyanstoykov
Copy link

deyanstoykov commented Nov 3, 2016

When using input_type=xml and having a space between elements, pretty_print doesn't work.
Steps to reproduce:

# cat /tmp/empty.xml
<?xml version='1.0' encoding='UTF-8'?>
<tag1></tag1>

# ansible localhost -m xml -a "file=/tmp/empty.xml pretty_print=true input_type=xml xpath=/tag1 add_children='<bean><Property/></bean>'"

# cat /tmp/empty.xml
<?xml version='1.0' encoding='UTF-8'?>
<tag1>
  <bean>
    <Property/>
  </bean>
</tag1>

# ansible localhost -m xml -a "file=/tmp/empty.xml pretty_print=true input_type=xml xpath=/tag1 add_children='<bean> <Property/></bean>'"

# cat /tmp/empty.xml
<?xml version='1.0' encoding='UTF-8'?>
<tag1>
  <bean>
    <Property/>
  </bean>
  <bean> <Property/></bean>
</tag1>
@dagwieers
Copy link
Collaborator

The xml module is upstream now (and ships with Ansible v2.4).

Please close this issue, and if needed, open a new issue at: https://github.com/ansible/ansible/issues

@sm4rk0
Copy link
Collaborator

sm4rk0 commented Aug 10, 2017

I reproduced this issue with ansible devel and lxml 3.8.0
@deyanstoykov Would you please copy this issue over to ansible/ansible?

@sm4rk0
Copy link
Collaborator

sm4rk0 commented Aug 10, 2017

Just checked. The cause is within etree.tostring() from lxml and it's not a bug, but a feature:
http://lxml.de/FAQ.html#why-doesn-t-the-pretty-print-option-reformat-my-xml-output
I propose closing this issue.

@dagwieers
Copy link
Collaborator

I would like to start listing caveats with the xml module. We can start compiling a list on the Wiki, then move the important items to the notes of the module documentation.

@sm4rk0
Copy link
Collaborator

sm4rk0 commented Aug 14, 2017

This behaviour is noted here, so this issue now can be closed.

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

No branches or pull requests

3 participants