NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 171 - trakem2 xml error
trakem2 xml error
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: TrakEM2
unspecified
PC Linux
: P4 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2010-05-21 11:05 CDT by german
Modified: 2010-08-21 13:36 CDT
1 user (show)

See Also:


Attachments
xml example (51.85 KB, text/xml)
2010-05-21 11:07 CDT, german
xml example (32.81 KB, text/xml)
2010-05-21 11:08 CDT, german

Description german 2010-05-21 11:05:16 CDT
can't reopen all the trakem2 projects, which i created during the last 1-2 weeks. gives following error:


==================

MAX_MEMORY: 16755515392
project file path 2: /projects/kevan/DAISY/cat_0507/cat_0507_LH/reconstructions/EM reconstructions/distal cluster/EM/bt2/untitled.xml
Loader.openFSProject: path is /projects/kevan/DAISY/cat_0507/cat_0507_LH/reconstructions/EM reconstructions/distal cluster/EM/bt2/untitled.xml
Fatal error: column=21 line=4
==================
ERROR:
org.xml.sax.SAXParseException: A '(' character or an element type is required in the declaration of element type "project".
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
	at ini.trakem2.persistence.FSLoader.openFSProject(FSLoader.java:270)
	at ini.trakem2.Project.openFSProject(Project.java:524)
	at ini.trakem2.Project.openFSProject(Project.java:515)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at HandleExtraFileTypes.tryOpen(HandleExtraFileTypes.java:192)
	at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:292)
	at HandleExtraFileTypes.run(HandleExtraFileTypes.java:38)
	at ij.IJ.runUserPlugIn(IJ.java:189)
	at ij.IJ.runPlugIn(IJ.java:155)
	at ij.IJ.runPlugIn(IJ.java:144)
	at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:412)
	at ij.io.Opener.openImage(Opener.java:289)
	at ij.io.Opener.openImage(Opener.java:308)
	at ij.io.Opener.open(Opener.java:142)
	at ij.io.Opener.open(Opener.java:70)
	at ij.plugin.Commands.run(Commands.java:23)
	at ij.IJ.runPlugIn(IJ.java:161)
	at ij.Executer.runCommand(Executer.java:147)
	at ij.Executer.run(Executer.java:78)
	at java.lang.Thread.run(Thread.java:619)
==================



Information about your version of Java - this information is useful for the Fiji developers:
  os.arch => amd64
  os.name => Linux
  os.version => 2.6.31.12-0.2-default
  java.version => 1.6.0_16
  java.vendor => Sun Microsystems Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_16-b01
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 14.2-b01
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.X11GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => null
  file.separator => /
Comment 1 german 2010-05-21 11:07:31 CDT
Created attachment 15
xml example
Comment 2 german 2010-05-21 11:08:38 CDT
Created attachment 16
xml example
Comment 3 Mark Longair 2010-05-21 13:12:08 CDT
It seems that the problem here is that it's possible in TrakEM2 to create a node whose name begins with a digit ("0507" in one of these case) which isn't a valid XML element name.  Changing the "0507" to "a0507" wherever it occurs in the file allows it to load.  Since the rules for checking these names are non-trivial, it might be best to check by trying to create an element when a name is suggested, e.g. as in the example in JRuby below.  (I can't see an obvious static method for checking names.)

>>> include_class 'javax.xml.parsers.DocumentBuilderFactory'
javax.xml.parsers.DocumentBuilderFactory

>>> factory = DocumentBuilderFactory.newInstance
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl@5e5c15

>>> builder = factory.newDocumentBuilder
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl@2e879

>>> implementation = builder.getDOMImplementation
com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl@8b60a

>>> document = implementation.createDocument(nil,nil,nil)
[#document: null]

>>> good_element = document.createElement("a0507")
[a0507: null]

>>> bad_element = document.createElement("0507")
com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java:608:in `createElement': org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.  (NativeException)
	from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
	from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
	from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke'
	from java/lang/reflect/Method.java:597:in `invoke'
	from org/jruby/javasupport/JavaMethod.java:251:in `invokeWithExceptionHandling'
	from org/jruby/javasupport/JavaMethod.java:223:in `invoke'
	from org/jruby/javasupport/JavaClass.java:411:in `execute'
	from org/jruby/internal/runtime/methods/SimpleCallbackMethod.java:67:in `call'
	 ... 11 levels...
	from JRuby/JRuby_Interpreter.java:18:in `eval'
	from common/AbstractInterpreter.java:659:in `execute'
	from common/AbstractInterpreter.java:559:in `run'
Complete Java stackTrace
org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
	at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createElement(CoreDocumentImpl.java:608)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:251)
	at org.jruby.javasupport.JavaMethod.invoke(JavaMethod.java:223)
	at org.jruby.javasupport.JavaClass$InstanceMethodInvoker.execute(JavaClass.java:411)
	at org.jruby.internal.runtime.methods.SimpleCallbackMethod.call(SimpleCallbackMethod.java:67)
	at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)
	at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:102)
	at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:243)
	at org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:657)
	at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:308)
	at org.jruby.evaluator.ASTInterpreter.localAsgnNode(ASTInterpreter.java:1256)
	at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:387)
	at org.jruby.evaluator.ASTInterpreter.rootNode(ASTInterpreter.java:1615)
	at org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:458)
	at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:168)
	at org.jruby.Ruby.evalScriptlet(Ruby.java:221)
	at JRuby.JRuby_Interpreter.eval(JRuby_Interpreter.java:18)
	at common.AbstractInterpreter.execute(AbstractInterpreter.java:659)
	at common.AbstractInterpreter$ExecuteCode.run(AbstractInterpreter.java:559)
	...internal jruby stack elided...
Comment 4 Albert Cardona 2010-05-21 15:19:21 CDT
I understand the problem. The "0507" should never have been allowed as name. There is currently a filter to prevent invalid XML names, I will take care that it includes a check for names starting with a number.

To restore your XML files, just prefix "0507" with an 'a' or any other alphabetic character: "a0507". Be sure to replace all occurrences.

Albert
Comment 5 german 2010-05-21 15:23:39 CDT
ok. thanks a lot
Comment 6 Albert Cardona 2010-08-21 13:36:26 CDT
A fix for this bug was released some time ago.