Garth, what you need is XmlOptionCharEscapeMap. See http://xmlbeans.apache.org/docs/2.1.0/reference/org/apache/xmlbeans/XmlO ptionCharEscapeMap.html. E.g.,
XmlOptionCharEscapeMap escapes = new XmlOptionCharEscapeMap(); escapes.addMapping('A', XmlOptionCharEscapeMap.HEXADECIMAL); escapes.addMapping('B', XmlOptionCharEscapeMap.DECIMAL); escapes.addMapping('>', XmlOptionCharEscapeMap.PREDEF_ENTITY); XmlOptions opts = new XmlOptions(); opts.setSaveSubstituteCharacters(escapes); System.out.println(myXml.xmlText(opts)); will result in: A being printed as A B being printed as B > being printed as > Cheers, Wing Yew -----Original Message----- From: Garth Patil [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 13, 2007 5:33 PM To: user@xmlbeans.apache.org Subject: Controlling encoding/escaping of an attribute Hi, I am using xmlbeans to generate the xml that is posted to a web service. The web service provider is rather picky about the encoding/escaping of the content of one of the attributes. Particularly, they ask that line feeds be terminated by For example: <request> <message text="This is the first line. This is the second line. This is the third line."/> </request> If I try to just use a \r\n or a \n, that appears without modification in the xml. If I try to set the encoded value explicitly, xmlbeans converts the leading ampersand to & How can I control the escaping of the attribute so that the line feed character has this encoding? Thanks, Garth --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]