Open kanngard opened 6 years ago
+1
Fix for this is critical - most of the XML I work with includes namespaces. SAML metadata fails due to tags like "<md:EntityDescriptor ...".
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,
<xsd:element>
<xsd:annotation><xsd:documentation>
My documentation
</xsd:documentation></xsd:annotation>
</xsd:element>
technically is not a valid XML - xsd
namespace is not defined. To make it 'parseable' and so 'indentable' namespaces need to be added:
<xsd:element xmlns:xsd="https://tempuri.org">
<xsd:annotation><xsd:documentation>
My documentation
</xsd:documentation></xsd:annotation>
</xsd:element>
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.
That makes sense, thank you for the reply.
In SAML metadata files, the namespace is always inferred, and I’ve never seen it explicitly declared, so I’ll wait for now. It might be nice to have a non-strict style for your indent plugin, where it only looks for matching open/close or self-closing tags and ignores unknown / undefined tags names.
Regardless, thank you for your work on this.
Regards,
Raun
From: Alexey Nesterov [mailto:notifications@github.com] Sent: Monday, January 29, 2018 1:57 AM To: alek-sys/sublimetext_indentxml sublimetext_indentxml@noreply.github.com Cc: Raun Nohavitza raun.nohavitza@centrify.com; Comment comment@noreply.github.com Subject: Re: [alek-sys/sublimetext_indentxml] TypeError: String required when indenting xml with namespaces (#106)
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,
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
When trying to indent XML including namespaces in Sublime 3 Build 3143, I get the following in the console:
Example of XML that generates the above error: