Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20159 Details for
Bug 80053
[RCP] Use only Foundation classes for RCP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch to get XMLMemento off XML Transform
ui-xmlmemento.patch (text/plain), 7.46 KB, created by
Jeff McAffer
on 2005-04-20 17:09:18 EDT
(
hide
)
Description:
patch to get XMLMemento off XML Transform
Filename:
MIME Type:
Creator:
Jeff McAffer
Created:
2005-04-20 17:09:18 EDT
Size:
7.46 KB
patch
obsolete
>Index: .classpath >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/.classpath,v >retrieving revision 1.9 >diff -u -r1.9 .classpath >--- .classpath 18 Apr 2005 21:15:23 -0000 1.9 >+++ .classpath 20 Apr 2005 21:08:19 -0000 >@@ -1,9 +1,24 @@ > <?xml version="1.0" encoding="UTF-8"?> > <classpath> >- <classpathentry kind="src" path="Eclipse UI/"/> >- <classpathentry kind="src" path="Eclipse UI Editor Support/"/> >- <classpathentry kind="src" path="Eclipse UI Components/"/> >- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> >- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> >+ <classpathentry kind="src" path="Eclipse UI"> >+ <attributes> >+ </attributes> >+ </classpathentry> >+ <classpathentry kind="src" path="Eclipse UI Editor Support"> >+ <attributes> >+ </attributes> >+ </classpathentry> >+ <classpathentry kind="src" path="Eclipse UI Components"> >+ <attributes> >+ </attributes> >+ </classpathentry> >+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> >+ <attributes> >+ </attributes> >+ </classpathentry> >+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> >+ <attributes> >+ </attributes> >+ </classpathentry> > <classpathentry kind="output" path="bin"/> > </classpath> >Index: Eclipse UI/org/eclipse/ui/XMLMemento.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/XMLMemento.java,v >retrieving revision 1.17 >diff -u -r1.17 XMLMemento.java >--- Eclipse UI/org/eclipse/ui/XMLMemento.java 25 Feb 2005 20:52:16 -0000 1.17 >+++ Eclipse UI/org/eclipse/ui/XMLMemento.java 20 Apr 2005 21:08:19 -0000 >@@ -11,33 +11,12 @@ > > package org.eclipse.ui; > >-import java.io.IOException; >-import java.io.Reader; >-import java.io.Writer; >-import java.util.ArrayList; >- >-import javax.xml.parsers.DocumentBuilder; >-import javax.xml.parsers.DocumentBuilderFactory; >-import javax.xml.parsers.ParserConfigurationException; >-import javax.xml.transform.OutputKeys; >-import javax.xml.transform.Result; >-import javax.xml.transform.Source; >-import javax.xml.transform.Transformer; >-import javax.xml.transform.TransformerConfigurationException; >-import javax.xml.transform.TransformerException; >-import javax.xml.transform.TransformerFactory; >-import javax.xml.transform.dom.DOMSource; >-import javax.xml.transform.stream.StreamResult; >- >+import java.io.*; >+import java.util.*; >+import javax.xml.parsers.*; > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPlugin; >-import org.w3c.dom.Attr; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-import org.w3c.dom.NamedNodeMap; >-import org.w3c.dom.Node; >-import org.w3c.dom.NodeList; >-import org.w3c.dom.Text; >+import org.w3c.dom.*; > import org.xml.sax.InputSource; > import org.xml.sax.SAXException; > >@@ -140,7 +119,8 @@ > document.appendChild(element); > return new XMLMemento(document, element); > } catch (ParserConfigurationException e) { >- throw new Error(e); >+// throw new Error(e); >+ throw new Error(e.getMessage()); > } > } > >@@ -406,18 +386,115 @@ > * @throws IOException if there is a problem serializing the document to the stream. > */ > public void save(Writer writer) throws IOException { >- Result result = new StreamResult(writer); >- Source source = new DOMSource(factory); >+ DOMWriter out = new DOMWriter(writer); > try { >- Transformer transformer = TransformerFactory.newInstance() >- .newTransformer(); >- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ >- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ >- transformer.transform(source, result); >- } catch (TransformerConfigurationException e) { >- throw (IOException) (new IOException().initCause(e)); >- } catch (TransformerException e) { >- throw (IOException) (new IOException().initCause(e)); >- } >+ save(element, out); >+ } finally { >+ out.close(); >+ } >+ } >+ >+ private void save(Element element, DOMWriter out) { >+ out.startTag(element); >+ NodeList children = element.getChildNodes(); >+ for (int i = 0; i < children.getLength(); i++) >+ save ((Element)children.item(i), out); >+ out.endTag(element); >+ } >+ >+ /** >+ * A simple XML writer. >+ */ >+ private static class DOMWriter extends PrintWriter { >+ protected int tab; >+ >+ /* constants */ >+ protected static final String XML_VERSION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; //$NON-NLS-1$ >+ >+ public DOMWriter(Writer output) throws UnsupportedEncodingException { >+ super(output); >+ tab = 0; >+ println(XML_VERSION); >+ } >+ >+ public void endTag(Element element) { >+ tab--; >+ if (!element.hasChildNodes()) >+ return; >+ StringBuffer sb = new StringBuffer(); >+ sb.append("</"); //$NON-NLS-1$ >+ sb.append(element.getNodeName()); >+ sb.append(">"); //$NON-NLS-1$ >+ printTabulation(); >+ println(sb.toString()); >+ } >+ >+ public void printTabulation() { >+ for (int i = 0; i < tab; i++) >+ super.print(" "); //$NON-NLS-1$ >+ } >+ >+ public void printTag(Element element, boolean shouldTab, boolean newLine) { >+ StringBuffer sb = new StringBuffer(); >+ sb.append("<"); //$NON-NLS-1$ >+ sb.append(element.getTagName()); >+ NamedNodeMap attributes = element.getAttributes(); >+ for (int i = 0; i < attributes.getLength(); i++) { >+ Attr attribute = (Attr)attributes.item(i); >+ sb.append(" "); //$NON-NLS-1$ >+ sb.append(attribute.getName()); >+ sb.append("=\""); //$NON-NLS-1$ >+ sb.append(getEscaped(String.valueOf(attribute.getValue()))); >+ sb.append("\""); //$NON-NLS-1$ >+ } >+ sb.append(element.hasChildNodes() ? ">" : "/>"); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (shouldTab) >+ printTabulation(); >+ if (newLine) >+ println(sb.toString()); >+ else >+ print(sb.toString()); >+ } >+ >+ public void startTag(Element element) { >+ printTag(element, true, true); >+ tab++; >+ } >+ >+ private static void appendEscapedChar(StringBuffer buffer, char c) { >+ String replacement = getReplacement(c); >+ if (replacement != null) { >+ buffer.append('&'); >+ buffer.append(replacement); >+ buffer.append(';'); >+ } else { >+ buffer.append(c); >+ } >+ } >+ >+ public static String getEscaped(String s) { >+ StringBuffer result = new StringBuffer(s.length() + 10); >+ for (int i = 0; i < s.length(); ++i) >+ appendEscapedChar(result, s.charAt(i)); >+ return result.toString(); >+ } >+ >+ private static String getReplacement(char c) { >+ // Encode special XML characters into the equivalent character references. >+ // These five are defined by default for all XML documents. >+ switch (c) { >+ case '<' : >+ return "lt"; //$NON-NLS-1$ >+ case '>' : >+ return "gt"; //$NON-NLS-1$ >+ case '"' : >+ return "quot"; //$NON-NLS-1$ >+ case '\'' : >+ return "apos"; //$NON-NLS-1$ >+ case '&' : >+ return "amp"; //$NON-NLS-1$ >+ } >+ return null; >+ } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 80053
: 20159