alek-sys / sublimetext_indentxml Goto Github PK
View Code? Open in Web Editor NEWPlugin for Sublime Text editor for reindenting XML and JSON files
License: MIT License
Plugin for Sublime Text editor for reindenting XML and JSON files
License: MIT License
big files wont indent ,dont know if its related to the file it self or just because there are too many lines ,here is what i get in console
indent_json
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "indentxml in /Users/Novo/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 49, in run
File "indentxml in /Users/Novo/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 116, in indent
File "./json/__init__.py", line 319, in loads
File "./json/decoder.py", line 352, in decode
File "./json/decoder.py", line 368, in raw_decode
File "./json/scanner.py", line 38, in _scan_once
File "./json/decoder.py", line 176, in JSONObject
ValueError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)
auto_indent
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "indentxml in /Users/Novo/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 49, in run
File "indentxml in /Users/Novo/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 77, in indent
File "indentxml in /Users/Novo/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 116, in indent
File "./json/__init__.py", line 319, in loads
File "./json/decoder.py", line 352, in decode
File "./json/decoder.py", line 368, in raw_decode
File "./json/scanner.py", line 38, in _scan_once
File "./json/decoder.py", line 176, in JSONObject
ValueError: Expecting property name enclosed in double quotes: line 2 column 1 (char 2)
It would be nice to be able to configure when an element should trigger a new line after/before it. When indenting XHTML, I do not think anyone would want to trigger a new line on some inline elements such as i and b.
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./indentxml.py", line 49, in run
File "./indentxml.py", line 92, in indent
File ".\xml\dom\minidom.py", line 1927, in parseString
File ".\xml\dom\expatbuilder.py", line 32, in
File ".\xml\parsers\expat.py", line 4, in
ImportError: No module named pyexpat
On Ubuntu 12.04.1 LTS I've received error:
Traceback (most recent call last): File "./sublime_plugin.py", line 362, in run_ File "./indentxml.py", line 32, in run File "./indentxml.py", line 48, in indentxml File ".\xml\dom\minidom.py", line 1927, in parseString File ".\xml\dom\expatbuilder.py", line 32, in <module> File ".\xml\parsers\expat.py", line 4, in <module> ImportError: No module named pyexpat
Looks like Sublime distribution doesn’t include pyexpat module.
Default version of Python used in Ubuntu 12.04 is 2.7.3 so you can't reuse system modules.
After a lot of hassle manage to install package control on Sublime Text 2 but when using Install Package command, when I search for indentxml I don't see the package.
I do see the package on http://wbond.net/sublime_packages/community but no idea how to install this.
Seems a bit of a hassle to just install package.
I'm new to sublime text, normally use Notepad++ but want to give this a try.
@alek-sys I have been trying to use indent JSON function for getting the JSON formatted, however looks like it only understands : {"key": value} format. I would want to extend this to be able to handle: {key: value }. Most of the cases, people might be using the JSON as follows rather than the the quoted string format. Does this seem to be in scope for this ?
I would like to contribute.
It fails to indent the XML (RSS) that comes from here :
Does the indentation really ignores whats in CDATA ?
Here's the error that I get :
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./indentxml.py", line 49, in run
File "./indentxml.py", line 96, in indent
xml.parsers.expat.ExpatError: mismatched tag: line 1, column 1006
Here is the piece of XML (or you can get it from the link in top of this issue report)
<?xml version="1.0" encoding="ISO-8859-1" ?><?xml-stylesheet type="text/xsl" href="http://www.rssweather.com/xslt.php" ?><?xml-stylesheet type="text/css" href="http://www.rssweather.com/rss.css" ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Paris, FRANCE Weather</title><link>http://www.rssweather.com/hw3.php?place=paris&state=&country=fr&utm_source=rss&utm_medium=rss</link><description><![CDATA[Current weather, forecasts and alerts delivered using RSS.<p>The weather information for this RSS feed is taken from the National Weather Service (http://weather.noaa.gov/), and powered by HamWeather (http://www.hamweather.com/). </p><h2>Using the Feeds</h2><ul><li>Request Frequency - The feeds are updated once per hour. More frequent requests may result in your access being limited.</li><li>Web Site Usage - If you are using the feed on your web site, you are required to maintain a link to rssWeather.com and hamweather.com</li></ul></b></p>]]></description><ttl>60</ttl><generator>HamWeather (http://www.hamweather.com/)</generator><language>en</language><item><title>Paris, FRANCE Weather :: 25C Fair</title><link>http://www.rssweather.com/hw3.php?place=paris&state=&country=fr&utm_source=rss&utm_medium=rss</link><category>Current Conditions</category><pubDate>Thu, 25 Jul 2013 10:00:00 +0100</pubDate><description>25C Fair</description><content:encoded><![CDATA[<h4><a href="http://www.rssweather.com/hw3.php?place=paris&state=&country=fr&utm_source=rss&utm_medium=rss" title="Paris, FRANCE Weather weather forecast"><img src="http://www.rssweather.net/images/fcicons/fair.gif" alt="fair" class="icon" width="55" height="58" id="fair.gif" border="0"/></a><span class="sky">Fair</span> <span class="temp">25°C</span></h4><dl style="display: inline;"> <dt style="display: inline; font-weight: bold;">Humidity:</dt><dd id="humidity" style="display: inline;">50%</dd> <dt style="display: inline; font-weight: bold;">Wind Speed:</dt><dd id="windspeed" style="display: inline;">11 KMH</dd> <dt style="display: inline; font-weight: bold;">Wind Direction:</dt><dd id="winddir" style="display: inline;">W (280°)</dd> <dt style="display: inline; font-weight: bold;">Barometer:</dt><dd id="pressure" style="display: inline;"> 1015 mb</dd> <dt style="display: inline; font-weight: bold;">Dewpoint:</dt><dd id="dewpoint" style="display: inline;">14°C</dd> <dt style="display: inline; font-weight: bold;">Heat Index:</dt><dd id="heatindex" style="display: inline;">26°C</dd> <dt style="display: inline; font-weight: bold;">Wind Chill:</dt><dd id="windchill" style="display: inline;">25°C</dd> <dt style="display: inline; font-weight: bold;">Visibility:</dt><dd id="visibility" style="display: inline;">11 km</dd></dl>]]></content:encoded><guid isPermaLink="false">C-1000 GMT+1 THU JUL 25 2013</guid></item></channel></rss>
Example:
<?xml version="1.0" encoding="UTF-8"?><root type="tag"><properties><property name="namespace" xsi:type="xsd:string">config</property></properties></root>
Causes:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
File ".\indentxml.py", line 32, in run
File ".\indentxml.py", line 48, in indentxml
File ".\xml\dom\minidom.py", line 1928, in parseString
File ".\xml\dom\expatbuilder.py", line 940, in parseString
File ".\xml\dom\expatbuilder.py", line 223, in parseString
xml.parsers.expat.ExpatError: unbound prefix: line 1, column 67
I've found that when switching between a Windows and Linux machines to keyboard shortcuts, doesn't work on Linux. If I edit the Linux shortcuts file to reflect the Windows file it works.
I have installed it through the package control.
Then I added the shorcuts using the example (https://github.com/alek-sys/sublimetext_indentxml)
Then restarted Sublime 2, and tried the xml example (http://www.sublimetext.com/forum/viewtopic.php?f=5&t=3262)
And didn't work, neither with shorcuts or command line. Did I miss something?
Currently there seems to be a hard check whether the current syntax setting is "XML". If it is not the case the "Format XML" menu entry is disabled.
But there a are a lot of other syntax schemes that are XML too and where the "Format XML" still makes sense. Such as XAML (can be installed with package control) or XSL (included out of the box).
I'm a bit unfamiliar with utf, but is there a reason why it won't parse if it is utf-16?
I could not make it work on OSX. I installed indent XML via Package control but there is no command available.
INPUT
<a><content><![CDATA[xxx]]></content></a>
OUTPUT
<a>
<content>
<![CDATA[xxx]]> </content>
</a>
EXPECTED
<a>
<content>
<![CDATA[xxx]]>
</content>
</a>
This could be most-easily solved by adding a note to the readme indicatating which license the code is available under.
The "indent xml" command only shows up if I have Sublime running without any open files. If I open a file and then open the command palette the command doesn't appear.
After I run the command indent_xml, the syntax of the file should automatically be set to XML by the plugin. This is already done on plugins like "SQL Beautifier".
This is a fairly simple change that greatly improves developers' performance.
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "indentxml in /Users/florentviel/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 49, in run
File "indentxml in /Users/florentviel/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 96, in indent
File "indentxml in /Users/florentviel/Library/Application Support/Sublime Text 3/Installed Packages/Indent XML.sublime-package", line 93, in indent
File "X/xml/dom/minidom.py", line 1972, in parseString
File "X/xml/dom/expatbuilder.py", line 926, in parseString
File "X/xml/dom/expatbuilder.py", line 221, in parseString
xml.parsers.expat.ExpatError: XML or text declaration not at start of entity: line 1, column 645
Sublime version: 3
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
File ".\indentxml.py", line 32, in run
File ".\indentxml.py", line 48, in indentxml
File ".\xml\dom\minidom.py", line 1928, in parseString
File ".\xml\dom\expatbuilder.py", line 940, in parseString
File ".\xml\dom\expatbuilder.py", line 223, in parseString
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 18628
Is possible to disable the alphabetical order of attributes in indent xml?
import socket
import sys, os
import xmltodict,json
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "socket successfully created"
except socket.error as err:
print "socket creation failed with error %s" %(err)
port = 8000
s.connect(('127.0.0.1', port))
s.send('GET /search?c=main&q=narendra+modi&format=xml&quick=1&hasmime=1 HTTP/1.1 Host: 127.0.0.1:8000 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Referer: http://127.0.0.1:8000/search?c=main&q=nagesh Connection: keep-alive If-Modified-Since: Thu, 05 Jun 2014 06:18:10 GMT\r\n\r\n')
data = '';
while True:
data = data + s.recv(1024)
if not s.recv(1024):break
var = data.find('\r\n\r\n')
xmldata = (data[var+4:])
result = xmltodict.parse(xmldata)
jdata = json.dumps(result)
jsonObj = json.loads(jdata)
print jsonObj['response']['result']
print '\n'
o/p is 👎
socket successfully created
Traceback (most recent call last):
File "result.py", line 24, in
result = xmltodict.parse(xmldata)
File "/usr/local/lib/python2.6/dist-packages/xmltodict.py", line 248, in parse
parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 11, column 6
ex: <a xmlns=""><b></b></a>
Traceback (most recent call last):
File ".\sublime_plugin.py", line 350, in run_
File ".\indentxml.py", line 37, in run
File ".\indentxml.py", line 48, in indentxml
File ".\xml\dom\minidom.py", line 57, in toprettyxml
File ".\xml\dom\minidom.py", line 1749, in writexml
File ".\xml\dom\minidom.py", line 812, in writexml
File ".\xml\dom\minidom.py", line 301, in _write_data
AttributeError: 'NoneType' object has no attribute 'replace'
The following example doesn't format because of the an '&' inside of a CDATA tag
<Data>
<Element><![CDATA[&]]>
</Element>
</Data>
Details
Hi,
your package works great below Windows. But below Linux I got this error message on the console:
Traceback (most recent call last):
File "./sublime_plugin.py", line 351, in run_
File "./indentxml.py", line 32, in run
File "./indentxml.py", line 48, in indentxml
File ".\xml\dom\minidom.py", line 1927, in parseString
File ".\xml\dom\expatbuilder.py", line 32, in
File ".\xml\parsers\expat.py", line 4, in
ImportError: No module named pyexpat
I'm using the latest build (Build 2165).
Any idea?
Cheers,
Magistrate
Hi, Mac KeyMap is missing an underscore, should be:
{ "keys": ["super+k", "super+f"], "command": "indent_xml" }
Thanks for the great package!
readme.md is very detailed about how to install but not about how to use.
It would be possible to include also a command to compress the XML/JSON to a minified version?
Currently , for JSON at least, this must be done with another plugin which also formats so you end with a duplicate feature...
Just installed the package (sublim text 2 / linux) and when i select my xml then do selection => format => indent xml
then i got :
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./indentxml.py", line 44, in run
File "./indentxml.py", line 96, in indent
ImportError: No module named pyexpat
This is the traceback:
Traceback (most recent call last):
File "/Users/charlie/Applications/Sublime Text 3.app/Contents/MacOS/sublime_plugin.py", line 531, in run_
return self.run(edit)
File "/Users/charlie/Library/Application Support/Sublime Text 3/Packages/Indent XML/indentxml.py", line 44, in run
s = self.indent(s)
File "/Users/charlie/Library/Application Support/Sublime Text 3/Packages/Indent XML/indentxml.py", line 100, in indent
s = xmlheader.group() + "\n" + s
TypeError: can't concat bytes to str
Hey there
I'm not sure whether this is the right place to address this issue, but I did not find any comment function on github.
Thanks for this plugin first of all! Helps me a lot.
there is just one thing: I don't want the plugin to rearrange my attributes of my xml nodes.
Could you tell me where I can disable that feature?
Thx a lot
Jonas
Hello,
Thanks for best job with this plugin.
The XML have 491800 characters.
The error is this:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
File ".\indentxml.py", line 49, in run
File ".\indentxml.py", line 96, in indent
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 491786
Regards and @goto thanks
I realise I can combine a shortcut key for the Indent XML command, but is there a reason why it doesn't show when I hit Command + Shift + P?
Saves having to select the whole file first.
The plugin, if encoding of file not utf-8, change text incorrect. (in line 42)
For example for windows-1251 endoding.
I found same script for guess what an encoding the file http://pypi.python.org/pypi/chardet, but may be there is same another solving.
Hi!
I just tried to format this code below, but I receive an error. I just work with C# otherwise I will try to just place the solution in here. Thanks in advance.
Maybe could the be accentuation?
Error msg:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
File ".\indentxml.py", line 44, in run
File ".\indentxml.py", line 96, in indent
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
text to Format:
<Requisicoes><Requisicao Chave="0c136047-ce55-4bd6-9aad-6b42fde53a3a" Uri="https://www.soc.com.br/WSSoc/services/LicencaMedicaWs" DataHora="10:30:41.796"><Envio><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" /></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><consultarLoteLicencasMedicas xmlns="http://services.soc.age.com/"><consultaAfastamento xmlns=""><abonado>false</abonado><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><dataFicha>17/09/2014</dataFicha><dataFimAfastamento>31/12/9999</dataFimAfastamento><dataInicioAfastamento>01/01/0001</dataInicioAfastamento><identificacaoVo>DADOS REMOVIDOS</identificacaoVo></consultaAfastamento></consultarLoteLicencasMedicas></s:Body></s:Envelope></Envio></Requisicao>
<Requisicao Chave="0c136047-ce55-4bd6-9aad-6b42fde53a3a" DataHora="10:30:42.270" TempoGasto="00:00:00.7448938"><Resposta><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" /><soap:Body><ns2:consultarLoteLicencasMedicasResponse xmlns:ns2="http://services.soc.age.com/"><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><cids>B00</cids><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>2</codigoFuncionario><codigoMotivoAfastamento>2</codigoMotivoAfastamento><codigoSequencialLicenca>53938015</codigoSequencialLicenca><cpfFuncionario>44218387729</cpfFuncionario><dataFicha>02/10/2015</dataFicha><dataFimAfastamento>19/10/2015</dataFimAfastamento><dataInicioAfastamento>02/10/2015</dataInicioAfastamento><descricaoMotivo>SUP. 15 DIAS.</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7778</matriculaFuncionario><tipoCid>DOENCA_RELACIONADOA_AO_TRABALHO</tipoCid><tipoDeAfastamento>2</tipoDeAfastamento></Afastamento><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>4</codigoFuncionario><codigoMotivoAfastamento>42</codigoMotivoAfastamento><codigoSequencialLicenca>53938296</codigoSequencialLicenca><cpfFuncionario>02374451747</cpfFuncionario><dataFicha>15/10/2015</dataFicha><dataFimAfastamento>15/10/2015</dataFimAfastamento><dataInicioAfastamento>15/10/2015</dataInicioAfastamento><descricaoMotivo>1 DIA</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7780</matriculaFuncionario><tipoDeAfastamento>7</tipoDeAfastamento></Afastamento><Afastamento><abonado>true</abonado><acidenteTrajeto>false</acidenteTrajeto><cids>E00</cids><codigoEmpresaFuncionario>297044</codigoEmpresaFuncionario><codigoFuncionario>1</codigoFuncionario><codigoMotivoAfastamento>35</codigoMotivoAfastamento><codigoSequencialLicenca>53938088</codigoSequencialLicenca><cpfFuncionario>06795882721</cpfFuncionario><dataFicha>05/10/2015</dataFicha><dataFimAfastamento>07/10/2015</dataFimAfastamento><dataInicioAfastamento>05/10/2015</dataInicioAfastamento><descricaoMotivo>3 DIAS.</descricaoMotivo><imprimirCid>false</imprimirCid><imprimirMotivo>false</imprimirMotivo><imprimirSolicitante>false</imprimirSolicitante><matriculaFuncionario>7777</matriculaFuncionario><tipoCid>DOENCA_RELACIONADOA_AO_TRABALHO</tipoCid><tipoDeAfastamento>11</tipoDeAfastamento></Afastamento></ns2:consultarLoteLicencasMedicasResponse></soap:Body></soap:Envelope></Resposta></Requisicao>
<Requisicao Chave="037c2757-a0f8-4c03-a4be-6bbfbdbe6280" Uri="http://vpc-1532-20132:1008/lg.com.br/svc/ServicoDeMovimentacao" DataHora="10:38:03.243"><Envio><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">lg.com.br/svc/ServicoDeMovimentacao/CadastreAfastamento</Action><h:LGAutenticacao xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="lg.com.br/svc/dto"><h:TokenSessao i:nil="true" /><h:tokenusuario>DADOS REMOVIDOS</h:tokenusuario></h:LGAutenticacao><h:LGContextoAmbiente xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="lg.com.br/svc/dto"><h:Ambiente>0</h:Ambiente><h:EnderecoHost i:nil="true" /><h:FuncaoEmExecucao i:nil="true" /><h:IdTenantSelecionado>0</h:IdTenantSelecionado><h:NomeHost i:nil="true" /><h:NomeTenantSelecionado i:nil="true" /></h:LGContextoAmbiente></s:Header><s:Body><CadastreAfastamento xmlns="lg.com.br/svc"><DadosAfastamento xmlns:d4p1="lg.com.br/svc/dto" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><d4p1:AcidenteDeTrajeto>false</d4p1:AcidenteDeTrajeto><d4p1:CID /><d4p1:CodigoDaEmpresa>1</d4p1:CodigoDaEmpresa><d4p1:CodigoDaSituacaoDeAfastamentoDoFuncionario>42</d4p1:CodigoDaSituacaoDeAfastamentoDoFuncionario><d4p1:DataDeInicioDoAfastamento>2015-10-15T00:00:00</d4p1:DataDeInicioDoAfastamento><d4p1:DataDeRetornoDoAfastamento>2015-10-16T00:00:00</d4p1:DataDeRetornoDoAfastamento><d4p1:DiasDeAuxilioDoenca i:nil="true" /><d4p1:DoencaRelacionadaAoTrabalho>false</d4p1:DoencaRelacionadaAoTrabalho><d4p1:MatriculaDoFuncionario>7780</d4p1:MatriculaDoFuncionario><d4p1:Observacao>1 DIA</d4p1:Observacao><d4p1:TipoDeAfastamentoRAIS>OUTROS</d4p1:TipoDeAfastamentoRAIS><d4p1:CalculeDiasAuxilioDoenca>false</d4p1:CalculeDiasAuxilioDoenca></DadosAfastamento></CadastreAfastamento></s:Body></s:Envelope></Envio></Requisicao>
<Requisicao Chave="037c2757-a0f8-4c03-a4be-6bbfbdbe6280" DataHora="10:38:24.354" TempoGasto="00:00:21.1618029"><Resposta><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header /><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="pt-BR">The creator of this fault did not specify a Reason.</faultstring><detail><ListaDeInconsistencias xmlns="lg.com.br/svc/dto" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Inconsistencias><Inconsistencia><Mensagem>Ocorrência de afastamento ja cadastrada.</Mensagem></Inconsistencia></Inconsistencias></ListaDeInconsistencias></detail></s:Fault></s:Body></s:Envelope></Resposta></Requisicao>
</Requisicoes>
I got an xml that contains elements like this:
<version>
1
</version>
I expect them to be converted to
<version>1</version>
like in V2 but it results in
<version>1
</version>
Not sure if i missed some config here.
The menu command is disabled, and thus the shortcut does not work either, unless the syntax is set to XML.
Many times one will be writing HTML as XHTML (all ebook producers, for instance) it would be handy to have the command available for HTML too. Sometimes XML will be embedded inside a file written in another language, and the running command only on the selection is useful too.
My take would actually be not trying to outsmart the user, and have the command available always, letting the user decide wether his selection is in an appropriate language that Indent XML will understand or not.
Thanks for the plugin! I have an Ant build file that has carefully placed newlines to separate sections of property declarations, targets, etc. When I run this it removes all the newlines and every section gets bunched up with the others. Is there an option to prevent it from doing so?
If XML is not properly formed, nothing happens. It will be good to indicate this to the user, otherwise a new user won't know why nothing happened.
Would be great to be able to specify that XML attributes should also be indented.
I have XML files that are full of attributes. I'd like them to be indented in the following way:
<?xml version="1.0" encoding="UTF-8" ?>
<Reply Success="TRUE" >
<JobInfo Name="Job 1"
GUID="{62A160F3-79E8-4358-9073-EDCAE4B4ED75}"
State="NEX_STARTED"
Status="STARTED"
Progress.DWD="32"
Description="Example Job"
User="WatchFolder"
SourceDescription="C : \ _ test . mp4"
AgentIP="192.168.62.133"
Priority.DWD="5"
DeleteProcessedSource.DWD="1"
StartTime_SCM="2008-05-1519:23:41" />
</ Reply>
Is there some way to specify that the indent should be 3 spaces rather than 2?
Thx!
Roger
Currently, under Windows 7 x64 / Sublime Text 3 build 3008, IndentXML returns the following error:
Traceback (most recent call last):
File "C:\sublimetext3\sublime_plugin.py", line 382, in run_
return self.run(edit)
File "C:\sublimetext3\Data\Packages\Indent XML\indentxml.py", line 37, in run
s = self.indentxml(s)
File "C:\sublimetext3\Data\Packages\Indent XML\indentxml.py", line 43, in indentxml
xmlheader = re.compile("<\?.*\?>").match(s)
TypeError: can't use a string pattern on a bytes-like object
Also, it looks like Will Bond's PackageControl will require a new package.json
to support the 2 vs. 3 difference
Hi Alex
Just noticed a new thing.
If I use the command on a whole doc (that is w/o selecting anything), it removes the Tag at the beginning of the doc.
cheers
MrWaz
If I reformat following XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Tag><Tag1>Småhus</Tag1></Tag>
It produces
<?xml version="1.0" encoding="ISO-8859-1"?>
<Tag>
<Tag1>Småhus</Tag1>
</Tag>
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 531, in run_
return self.run(edit)
File "/.config/sublime-text-3/Installed Packages/Indent XML.sublime-package/indentxml.py", line 44, in run/.config/sublime-text-3/Installed Packages/Indent XML.sublime-package/indentxml.py", line 77, in indent
File "
File "~/.config/sublime-text-3/Installed Packages/Indent XML.sublime-package/indentxml.py", line 100, in indent
TypeError: can't concat bytes to str
Hi, I'm a french user of Sublime and your marvelous plugin that really helps when dealing with openXML documents.
But the plugin fails to deal with files containing accents like "é", etc..
Traceback (most recent call last):
File ".\sublime_plugin.py", line 282, in run_
File ".\indentxml.py", line 37, in run
File ".\indentxml.py", line 45, in indentxml
File ".\xml\dom\minidom.py", line 1928, in parseString
File ".\xml\dom\expatbuilder.py", line 940, in parseString
File ".\xml\dom\expatbuilder.py", line 223, in parseString
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1049: ordinal not in range(128)
I'm not a python expert but checking line 45 in indentxml.py I did a slight change that change my life.
pyhton s = parseString(s).toprettyxml() => s = parseString(s.encode( "utf-8" )).toprettyxml()
Don't know if this was a good idea, but a least a suggestion to make your non-english users happy.
All the best
Mr Waz
<w:t xml:space="preserve"> The database has rows and the cache may have objects.
The database caching logic must know enough to create objects from the database schema. </w:t>
after indent
<w:t xml:space="preserve"><w:t xml:space="preserve">The database has rows and the cache may have objects.
The database caching logic must know enough to create objects from the database schema</w:t>
Currently when I reindent a XML that have empty tags, the plugin only supports the format:
<avp name="Filter-Id" value="377"/>
It would be ideal if there is a setting to have the alternate format:
<avp name="Filter-Id" value="377"></avp>
Thanks
Here's the XML in question:
<OTA_HotelResRQ xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" EchoToken="27516798AC15283F6F96295746FA0774" PrimaryLangID="de-DE" ResStatus="Book" Target="Production" TimeStamp="2014-03-07T19:06:46+01:00" TransactionIdentifier="1236213" Version="1.003" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelResRQ.xsd">
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.