Community
Participate
Working Groups
Build ID: I20070625-1500 (as reported by Help/About Eclipse) I20070608-1718 (as reported by the error log) Steps To Reproduce: Obtain DocBook 4.5 xml DTD from http://www.oasis-open.org/docbook/xml/4.5/docbook-xml-4.5.zip Create a new XML file using that DTD. Make the XML file look like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" ".../docbookx.dtd" > <book><title>Testing</title><chapter><title>Test</title> <para><screen>screen test</screen></para> </chapter></book> Select all and use CTRL-SHIFT-F to format. More information: From the "Problem Occurred" Dialog box: "Format" did not complete normally. Please see the log for more information. (Time of error: ...) Reason: java.lang.NullPointerException Exception Stack Trace from log: java.lang.NullPointerException at org.eclipse.wst.xml.core.internal.provisional.format.ElementNodeFormatter.formatStartTag(ElementNodeFormatter.java:395) at org.eclipse.wst.xml.core.internal.provisional.format.ElementNodeFormatter.formatNode(ElementNodeFormatter.java:121) at org.eclipse.wst.xml.core.internal.provisional.format.NodeFormatter.format(NodeFormatter.java:75) at org.eclipse.wst.xml.core.internal.provisional.format.DocumentNodeFormatter.formatChildren(DocumentNodeFormatter.java:42) at org.eclipse.wst.xml.core.internal.provisional.format.ElementNodeFormatter.formatNode(ElementNodeFormatter.java:132) at org.eclipse.wst.xml.core.internal.provisional.format.NodeFormatter.format(NodeFormatter.java:75) at org.eclipse.wst.xml.core.internal.provisional.format.DocumentNodeFormatter.formatChildren(DocumentNodeFormatter.java:42) at org.eclipse.wst.xml.core.internal.provisional.format.ElementNodeFormatter.formatNode(ElementNodeFormatter.java:132) at org.eclipse.wst.xml.core.internal.provisional.format.NodeFormatter.format(NodeFormatter.java:75) at org.eclipse.wst.xml.core.internal.provisional.format.DocumentNodeFormatter.formatChildren(DocumentNodeFormatter.java:42) at org.eclipse.wst.xml.core.internal.provisional.format.ElementNodeFormatter.formatNode(ElementNodeFormatter.java:132) at org.eclipse.wst.xml.core.internal.provisional.format.NodeFormatter.format(NodeFormatter.java:75) at org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor.formatNode(AbstractStructuredFormatProcessor.java:405) at org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor.formatModel(AbstractStructuredFormatProcessor.java:346) at org.eclipse.wst.sse.core.internal.format.AbstractStructuredFormatProcessor.formatDocument(AbstractStructuredFormatProcessor.java:167) at org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy.format(StructuredFormattingStrategy.java:58) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:135) at org.eclipse.wst.sse.ui.internal.StructuredTextViewer.doOperation(StructuredTextViewer.java:454) at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:475) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:429) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:165) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:821) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:879) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:568) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1141) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1285) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3772) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3672) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:291) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4351) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2264) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443) at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
Better information: This apparently happens on any element with xml:space set to preserve. DTD and XML file follow. The DTD defines a "workingElement" and "nonWorkingElement". Both can include either element, plus #PCDATA. The nonWorkingElement has an implied 'xml:space' attribute set to 'preserve'. When the XML file is entered and formatted, the <workingElement> section is reformatted, then a null pointer exception happens at the <nonWorkingElement>. <!-- test DTD to create minimal repro for xml:space problem --> <!ELEMENT testcase (workingElement|nonWorkingElement)*> <!ELEMENT workingElement (#PCDATA|workingElement|nonWorkingElement)*> <!ELEMENT nonWorkingElement (#PCDATA|workingElement|nonWorkingElement)*> <!ATTLIST nonWorkingElement xml:space (preserve) #IMPLIED > <!-- end of DTD --> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE testcase SYSTEM "test.dtd" > <testcase> <workingElement> This section <workingElement> will be properly </workingElement> reformatted. </workingElement> <nonWorkingElement> This section <workingElement> will not be </workingElement> reformatted. </nonWorkingElement> </testcase>
As far as I can tell, this is caused by the definition of getImpliedValue() in org.eclipse.wst.xml.core.internal.contentmodel.basic.CMDataTypeImpl always returning null.
If the implied value kind is IMPLIED_VALUE_NONE, it would return null. We should actually only make use of the implied value for IMPLIED_VALUE_FIXED and IMPLIED_VALUE_DEFAULT, and then still check for nulls.
Reassigning formatting bugs to Nick
Created attachment 88317 [details] proposed patch See Bug 159566. This seems to be something that has existed since 1.5.
*** Bug 159566 has been marked as a duplicate of this bug. ***
Targetting 2.0.2 since this is only a problem prior to the new formatter in wtp 3.0.
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. - It's been reported more than once in bug reports and it's also been reported on the newsgroup. * Is there a work-around? If so, why do you believe the work-around is insufficient? - No * How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? - This fix has been tested against the content defined in the bug's original description. * Give a brief technical overview. Who has reviewed this fix? - The problem occurs when there is no implied value for an attribute. The null value had the .compareTo method called on it, and caused the NPE. To fix this, .equals was used on a String value that would not be null. * What is the risk associated with this fix? - This fix should have very little associated risk.
Fix looks good, low risk.
Patch approved, marking for PMC review.
Approved.
Released.
Verified with M-2.0.2RC3-20080221101112