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 83693 Details for
Bug 207806
Eventformatter does not correctly serialize the any properties.
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]
updated patch
207806.txt (text/plain), 9.17 KB, created by
Rohit Shetty
on 2007-11-24 10:40:55 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Rohit Shetty
Created:
2007-11-24 10:40:55 EST
Size:
9.17 KB
patch
obsolete
>Index: src/org/eclipse/hyades/logging/core/XmlUtility.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src/org/eclipse/hyades/logging/core/XmlUtility.java,v >retrieving revision 1.1 >diff -u -r1.1 XmlUtility.java >--- src/org/eclipse/hyades/logging/core/XmlUtility.java 6 Sep 2006 17:54:05 -0000 1.1 >+++ src/org/eclipse/hyades/logging/core/XmlUtility.java 24 Nov 2007 15:36:09 -0000 >@@ -15,6 +15,8 @@ > import java.nio.charset.Charset; > > import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.SAXParser; >+import javax.xml.parsers.SAXParserFactory; > import javax.xml.transform.OutputKeys; > import javax.xml.transform.Transformer; > import javax.xml.transform.TransformerConfigurationException; >@@ -29,6 +31,8 @@ > import org.w3c.dom.DocumentType; > import org.w3c.dom.Node; > import org.xml.sax.InputSource; >+import org.xml.sax.SAXException; >+import org.xml.sax.helpers.DefaultHandler; > > /********************************************************************** > * Copyright (c) 2005, 2006 IBM Corporation and others. >@@ -1099,6 +1103,32 @@ > } > > /** >+ * >+ * Verifies if the specified XML fragment is valid wrt the syntax. >+ * >+ * @param string The string to be normalized. >+ * @return "true" is the specified string is a valid XML fragment, "false" otherwise. >+ */ >+ >+ public static boolean isValidXML(String xml) >+ { >+ StringReader xmlStream = new StringReader(xml); >+ SAXParserFactory factory = SAXParserFactory.newInstance(); >+ try { >+ SAXParser saxParser = factory.newSAXParser(); >+ InputSource source = new InputSource(xmlStream); >+ saxParser.parse(source, new DefaultHandler()); >+ } catch (Throwable t) { >+ return false; >+ } finally { >+ if (xmlStream != null) { >+ xmlStream.close(); >+ } >+ } >+ return true; >+ } >+ >+ /** > * Normalizes the parameter string according to the XML specification for > * attribute-value normalization > * (<a href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a>) >Index: src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 EventHandler.java >--- src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java 6 Sep 2006 17:54:15 -0000 1.1 >+++ src.cbe101/org/eclipse/hyades/logging/events/cbe/internal/util/EventHandler.java 24 Nov 2007 15:35:53 -0000 >@@ -597,7 +597,7 @@ > //Do not persist white space (e.g. formatting characters) > // between elements: > if (anyElementCharacters.trim().length() > 0) { >- ((CommonBaseEvent) (object)).addAny(XmlUtility.normalize(anyElementCharacters)); >+ ((CommonBaseEvent) (object)).addAny(anyElementCharacters.trim()); > } > > if(eventListener != null){ >@@ -619,10 +619,10 @@ > String currentAnyElement = otherSituation.getAny(); > > if ((currentAnyElement != null) && (currentAnyElement.trim().length() > 0)) { >- otherSituation.setAny(currentAnyElement.concat(XmlUtility.normalize(anyElementCharacters))); >+ otherSituation.setAny(currentAnyElement.concat(anyElementCharacters)); > } > else { >- otherSituation.setAny(XmlUtility.normalize(anyElementCharacters)); >+ otherSituation.setAny(anyElementCharacters.trim()); > } > } > } >Index: src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java,v >retrieving revision 1.2 >diff -u -r1.2 EventFormatter.java >--- src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java 5 Oct 2006 21:07:44 -0000 1.2 >+++ src.events/org/eclipse/tptp/logging/events/cbe/util/EventFormatter.java 24 Nov 2007 15:36:07 -0000 >@@ -2089,10 +2089,17 @@ > buffer.append("\t\t\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyData); >- } >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyData)) >+ { >+ buffer.append(anyData); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyData)); >+ } >+ } > > if (format) { > buffer.append(Constants.LINE_SEPARATOR); >@@ -2127,10 +2134,17 @@ > buffer.append("\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyElement); >- } >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyElement)) >+ { >+ buffer.append(anyElement); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyElement)); >+ } >+ } > } > > if (format) { >Index: src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java,v >retrieving revision 1.2 >diff -u -r1.2 EventFormatter.java >--- src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java 5 Oct 2006 21:07:44 -0000 1.2 >+++ src.cbe101/org/eclipse/hyades/logging/events/cbe/util/EventFormatter.java 24 Nov 2007 15:35:59 -0000 >@@ -2091,9 +2091,16 @@ > buffer.append("\t\t\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyData); >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyData)) >+ { >+ buffer.append(anyData); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyData)); >+ } > } > > if (format) { >@@ -2129,9 +2136,16 @@ > buffer.append("\t"); > } > >- // Do NOT normalize since this string is assumed to be a >- // valid XML fragment: >- buffer.append(anyElement); >+ // Normalizing since this string might not always be >+ // a valid XML fragment: Bugzilla 207806 >+ if(XmlUtility.isValidXML(anyElement)) >+ { >+ buffer.append(anyElement); >+ } >+ else >+ { >+ buffer.append(XmlUtility.normalize(anyElement)); >+ } > } > } > >Index: src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.logging.events/src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 EventHandler.java >--- src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java 6 Sep 2006 17:54:23 -0000 1.1 >+++ src.events/org/eclipse/tptp/logging/events/cbe/internal/util/EventHandler.java 24 Nov 2007 15:36:01 -0000 >@@ -1080,7 +1080,7 @@ > > //Do not persist white space (e.g. formatting characters) between elements: > if (charactersBuffer.toString().trim().length() > 0) { >- commonBaseEvent.addAny(XmlUtility.normalize(charactersBuffer.toString())); >+ commonBaseEvent.addAny(charactersBuffer.toString().trim()); > } > > if(eventListener != null){ >@@ -1247,7 +1247,7 @@ > > //Do not persist white space (e.g. formatting characters) between elements: > if (charactersBuffer.toString().trim().length() > 0) { >- otherSituation.setAny(XmlUtility.normalize(charactersBuffer.toString())); >+ otherSituation.setAny(charactersBuffer.toString().trim()); > } > > ((Situation)(parsedElements.get(parsedElements.size() - 1))).setSituationType(otherSituation);
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
Flags:
rohit.shetty
:
review?
Actions:
View
|
Diff
Attachments on
bug 207806
:
83388
|
83389
| 83693 |
83694
|
89501