sbmlteam / jsbml

JSBML is a community-driven project to create a free, open-source, pure Java™ library for reading, writing, and manipulating SBML files (the Systems Biology Markup Language) and data streams. It is an alternative to the mixed Java/native code-based interface provided in libSBML.

Home Page:https://sbml.org/software/jsbml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setting notes that is invalid xml throws com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '<'

piotr-gawron opened this issue · comments

Here is an example that leads to this exception:

    SBMLDocument doc = new SBMLDocument(3, 1);
    Model result = doc.createModel("");
    result.setNotes("x=y<z");

The solution to such problem would be encoding the string before surrounding it with xml tags here:
https://github.com/sbmlteam/jsbml/blob/master/core/src/org/sbml/jsbml/util/StringTools.java#L651

Normally I would use something like StringEscapeUtils from the Apache Commons Lang but because you are not using external libraries (at least I don't see them), you might at least check what they are doing and apply something similar.