Ooh sorry Christopher. I made the problem sound more sever than it really is :P I have a JavaBean that is writing out its information as an xml document. So it has a function toXML that does something like "<javabean>" " <javabeanid>" + jbId + "</javabeanid>" " <javabeandesc>" + jbDesc + "</javabeandesc>" "</javabean>" My concern is that if the desc or other parts for the javabean has a String with special chars then I have to do a function to "xml friendly" it "<javabean>" " <javabeanid>" + jbId + "</javabeanid>" " <javabeandesc>" + com.util.XmlUtil.xmlFriendly(jbDesc) + "</javabeandesc>" "</javabean>" This function just looks big and messy. It has to do a recursive matching of special XML reserved symbols (<,>,...) and replaces them with the correct XML formats of them (<, >, ...) While this works just fine and doesnt take too long (unless processing ALOT of xmls). I'm just wondering if Java already has something to do this, kind of like how encodeURL will. -Tim
-----Original Message----- From: Christopher K. St. John [mailto:[EMAIL PROTECTED]] Sent: Monday, November 12, 2001 11:24 AM To: [EMAIL PROTECTED] Subject: Re: XML reformatting "Chen, Gin" wrote: > > I have an application that uses XML data from a Servlet. The XML is > not in a file. Rather, it is dynamically generated. I have problems with > some special chars within the actual xml files themselves. > ... It's an entire XML document. > If the document has '<', then it isn't an XML document at all. From your description, the application that claims to be generating XML has a bug. Best thing is to fix the application to generate valid XML. If you can't do that, then you need to find out what exactly the application _is_ generating before you can write a filter to convert it to XML. Is the '<' the only problem? Does it generate binary data? Does it regenerate user input? For example, you can't use CDATA sections if it's possible that the data might contain the CDATA end marker. This is all mildly off-topic for servlet-interest, you might want to try XML-DEV: http://www.xml.org/xml/xmldev.shtml XML-DEV is a very good mailing list. --- Christopher St. John [EMAIL PROTECTED] DistribuTopia http://www.distributopia.com ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
