TypeError: String required when indenting xml with namespaces
See original GitHub issueWhen trying to indent XML including namespaces in Sublime 3 Build 3143, I get the following in the console:
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 818, in run_
return self.run(edit)
File "indentxml in C:\Users\<username>\AppData\Roaming\Sublime Text 3\Installed Packages\Indent XML.sublime-package", line 47, in run
File "C:\Program Files\Sublime Text 3\sublime.py", line 823, in replace
sublime_api.view_replace(self.view_id, edit.edit_token, r, text)
TypeError: String required
Example of XML that generates the above error:
<xsd:element>
<xsd:annotation><xsd:documentation>
My documentation
</xsd:documentation></xsd:annotation>
</xsd:element>
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Working with namespace while parsing XML using ElementTree
There are two problems on this line: a=tree.find('parent'). First, <parent> is not an immediate child of the root element. <parent> is a grandchild...
Read more >xml.etree.ElementTree — The ElementTree XML API ...
Parsing XML fromstring() parses XML from a string directly into an Element , which is the root element of the parsed tree. Other...
Read more >XQuery, XSLT, and XPath Error Codes Namespace Document
It is a type error if the result of evaluating the sequence constructor cannot be converted to the required type. err:XTTE0510: It is...
Read more >XML Schema: Understanding Namespaces - Oracle
By now it should be clear that to use a namespace, we first bind it with a prefix and then use that prefix...
Read more >XML - Robot Framework
Parsing XML; Using lxml; Example; Finding elements with xpath; Element attributes; Handling XML namespaces; Boolean arguments; Importing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to clarify - the “String required” error is misleading and I’m not sure where is it coming from. The real problem is that the piece of XML you are trying to format has to be a valid XML, i.e. it should define all the namespaces.
For example,
technically is not a valid XML -
xsd
namespace is not defined. To make it ‘parseable’ and so ‘indentable’ namespaces need to be added:So this problem can appear when you are trying to indent not a whole document, but part of it (or a selection).
I understand this explanation doesn’t quite help to solve the problem, I just want to show that fixing this is tricky (namespaces need to be ‘mocked’ for indentiting or something). Also this is not in the list of my priorities at the moment, sorry. However I’ll try to see if there is anything I can do quickly.
Thanks for clarifying. I often work on XML snippets and can not have the namespaces declared. So instead of working on XML files with thousands of lines, I only have a few lines to minimize the clutter and workload in Sublime. I see that this is actually a duplicate of #105 Found a plugin that handles my requirements, IndentX, https://github.com/socsieng/IndentX