Search code examples
xmlaemsax

Sax Parse exception : unknown type


We have to include an attribute value as json string in an XML for the application to read. This would look something like

<mytag attribute1="{'type':'foo/bar'}">
  .............
</mytag>

But while parsing this configuration file, application is throwing a SAX Exception:

 org.xml.sax.SAXException: unknown type: 'type':'foo/bar'

Any pointers for solving this issue would be helpful

Thanks


Solution

  • I had this problem too, if you're using a '{' at the start of an attribute, you will get a SAXException. I fixed my issue by putting a '\' before it. In your case it would be attribute1="\{'type':'foo/bar'}".