Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in processing messages (2) #44

Open
mephenor opened this issue Mar 3, 2011 · 12 comments
Open

Error in processing messages (2) #44

mephenor opened this issue Mar 3, 2011 · 12 comments

Comments

@mephenor
Copy link
Collaborator

mephenor commented Mar 3, 2011

Thank you for the quick fix of the bug "Error in processing messages - ID: 3196638". Unfortunately there is still a problem in the method processStartElement in the class StringParser. If you want to import a message it causes an error, because the method getMessage from the class constraint returns null if it isn't set. I would suggest the following code fragment for the method processStartElement :

if (typeOfNotes.equals("notes")) {
parentSBMLElement.getNotes().addChild(xmlNode);
} else if (typeOfNotes.equals("message") && parentSBMLElement instanceof Constraint) {
XMLNode message = ((Constraint) parentSBMLElement).getMessage();
if(message!=null)
message.addChild(xmlNode);
else
{
((Constraint) parentSBMLElement).setMessage(xmlNode);
}

With this change in the code you insure that a message wil be set even if there was no one before.

Reported by: *anonymous

@mephenor
Copy link
Collaborator Author

mephenor commented Mar 4, 2011

  • assigned_to: nobody --> niko-rodrigue
  • labels: --> XML Reading/Writing
  • status: open --> pending-works-for-me

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

mephenor commented Mar 4, 2011

Did you get a NullPointerException ??

The original XMLNode of the message is set in the SBMLCoreParser when an element message is encountered, the same way as the typeOfNotes is set earlier.
It tried to create a model with a constraint that contain notes and message and the read/write seems to be working fine, I am not sure I tried the getMessageString() though.

Also, I close the first bug report but it is open for comments so you could have put your comment there.

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

mephenor commented Mar 4, 2011

  • status: pending-works-for-me --> open-works-for-me

Original comment by: sebfroh

@mephenor
Copy link
Collaborator Author

mephenor commented Mar 4, 2011

Okay, I think I get it. The namespace used for messages is
"http://www.w3.org/1999/xhtml".
The parser for this namespace is StringParser (file PackageParserNamespaces.xml):
line:
<entry key="http://www.w3.org/1999/xhtml">
org.sbml.jsbml.xml.parsers.StringParser
</entry>

The Code in SBMLCoreParser for a message tag in constraint is never executed.

Original comment by: sebfroh

@mephenor
Copy link
Collaborator Author

mephenor commented Mar 7, 2011

Then this was your SBML file that was wrong ?
Not sure how we could prevent that and send a nice error message or warning. May be we could test if an element named message or notes is sent to the StringParser and in this case sent a warning message to the user saying that there is probably something wrong with their model. In this case, the test to see if getMessage() or getNotes() return null make more sense so I will had them.

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

I think its a bit difficult. The specification L3V1 §4.10 says, that the content of the message-tag has the namespace xhtml.
So I thought that the sbml-file could look like:
...
<message xmlns:xhtml="http://www.w3.org/1999/xhtml">
...
</message>
...

the following fragment would be parsed by SBMLCoreParser:
...
<message>
...
</message>
...

while the first fragment with namespace would be parsed by StringParser.
I think both solutions are conform with L3V1 §4.10.

Original comment by: sebfroh

@mephenor
Copy link
Collaborator Author

Yes, written like that, the first fragment should be valid and the message element should be processed by the SBMLCoreParser. I will have a look at it.

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

  • status: open-works-for-me --> open-accepted

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

I don't understand why it is necessary to access the parentSBMLElement? This might be null in some cases. What is it needed for? It seems the code fragment above should be placed in some child of Constraint, but where?

Original comment by: draeger

@mephenor
Copy link
Collaborator Author

Andreas, this code is a part of the parsing, in StringParser.processStartElement and it is working fine.

The problem is happening if you define the xhtml namespace in the message element instead of in the actual html code like it is done in general.

Something like that :
<message xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:p>Constraint message</xhtml:p>
</message>

For me, the parsing is working fine but the namespace is not written out again on the message element when writting back the sbml model, the problem is that in general we are not trying to check if there is any namespaces to write in standard element which we will nee to do anyway to support the SBML level 3 packages where a namespace declaration could happen more or less anywhere.

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

mephenor commented Jun 3, 2011

  • milestone: --> jsbml 1.0

Original comment by: niko-rodrigue

@mephenor
Copy link
Collaborator Author

mephenor commented Sep 3, 2015

  • Group: jsbml 1.0 --> jsbml 1.2

Original comment by: niko-rodrigue

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

No branches or pull requests

2 participants