Conversion fails when JSON key name is not a legal XML element name #10

Closed
dwcramer opened this Issue Nov 11, 2013 · 3 comments

Projects

None yet

2 participants

@dwcramer

Given the input JSON:

{
   "^.{0,256}$": "foo"
}

I receive the following error:

dcramer@anatine ~/Desktop/json2plainparams/json_schema (master)
$ ./json2xml.py test.json 
Debug mode is on. Events are logged at: dicttoxml.log
test.json
Traceback (most recent call last):
  File "./json2xml.py", line 18, in <module>
    dom = parseString(xml)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1931, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 46

Due to the fact that <^.{0,256}$>foo</^.{0,256}$> would not be well-formed xml.

I would suggest an xml format like foo to avoid this problem.

@quandyfactory

Thanks for bringing this to my attention. I should be able to commit a fix in the next day or so.

@dwcramer

Thanks! Btw., in my original message I see that my suggested output was munged because I hadn't escaped the angle brackets. Here's what I was trying to say: "I would suggest an xml format like <key name="^.{0,256}$">foo</key> to avoid this problem. "

@quandyfactory

Sorry it took a lot longer than I expected, but I finally got around to fixing this issue. It's addressed in version 1.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment