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

Set indentation for attributes in new lines #9

Closed
MuntashirAkon opened this issue Jan 13, 2023 · 6 comments
Closed

Set indentation for attributes in new lines #9

MuntashirAkon opened this issue Jan 13, 2023 · 6 comments
Assignees

Comments

@MuntashirAkon
Copy link

There is an option to set indentation for child tags in XMLDocument but no option to set indentation for new line attributes and they are at present calculated at XMLElement#appendAttributesIndentText(Writer). It might be better to provide an option to set indentations instead of calculating them. For example, instead of providing an argument boolean newLineAttributes, you can provide int attributeIndentation whose negative value (e.g. -1) would imply no new line and any positive number would imply the amount of indentation.

Thanks.

@REAndroid
Copy link
Owner

I agree , there a lot of other issues to fix on com.reandroid.xml.* classes.

@MuntashirAkon
Copy link
Author

Any updates?

@REAndroid
Copy link
Owner

Sorry I don't know how I forgot this issue.
Keeping newLineAttributes, I have added setAttributesIndentScale(float indentScale) for elements, you can set negative value to pull back.

@MuntashirAkon
Copy link
Author

Keeping newLineAttributes, I have added setAttributesIndentScale(float indentScale) for elements, you can set negative value to pull back.

It only scales the calculated indentation, it does not set the indentation.

@REAndroid
Copy link
Owner

I feel like i missed your point. As on the last commit you can set indentation to any position you like, I kept newLineAttributes param to turn off/on indentation. The indentation for attributes must be calculated bc it is anchored with parent element.
Can you show me your goal with screenshoot/document ? Or make PR

@MuntashirAkon
Copy link
Author

I have ended up writing a concrete implementation of XmlPullParser to handle this. As I said in #18, I don't think XML conversion should be part of the library as it can be handled quite easily using XmlSerializer and Transformer functions.

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

2 participants