Yes I have the following code: OutputFormat format = new OutputFormat("xml", "UTF-8", false); format.setIndenting(false); format.setPreserveSpace(true); format.setOmitComments(false); format.setStandalone(true); format.setOmitXMLDeclaration(true); format.setLineSeparator(System.getProperty("line.separator")); XMLSerializer serializer = new XMLSerializer(out, format); serializer.setNamespaces(true); serializer.serialize(e);
The source document has the CRs and LFs as and these are then written out as CR / LF by XMLSerializer. The resulting XSLT is then misinterpreted by Xalan (matching a space rather than a CR or LF). It is nasty having CR or LF in the middle of an attribute and I think that there should be an option at least to stop this happening. The code seems to use the same 2 functions to escape the output - printEscaped and printXMLChar - these functions never do anything different for attribute or element text. Cheers -----Original Message----- From: Constantine Georges [mailto:[EMAIL PROTECTED] Sent: 06 May 2003 13:52 To: [EMAIL PROTECTED] Subject: Re: XMLSerializer attributes and carriage returns - bug? Have you tried setting preserve space to true in the OutputFormat object? I thought that XMLSerializer normalized space unless you told it otherwise. It also truncates long lines unless you tell it otherwise. I know that line truncation is by design, so I'm assuming that space normalization is also. C To: [EMAIL PROTECTED] Thomas Greenwood cc: (bcc: Constantine Georges/Towers Perrin) <[EMAIL PROTECTED]> Subject: XMLSerializer attributes and carriage returns - bug? 05/06/2003 06:34 AM Please respond to xerces-j-user I have an XML document that contains carriage returns and line feeds in attributes. When I serialize this document with XMLSerializer these carriage returns and line feeds appear in the output as exactly that - but this then causes problems using the document as an XSLT, escaping the carriage returns and line feeds stops any problems. I have written some code that should fix these problems, but was this by design or is this a bug? If this is a bug then I'll send my new code sample in with a bug report, if not is there any way to get the current XMLSerializer to escape the carriage returns and line feeds in attributes (does not look like there is any code to do this)? Thanks ************************************************************************ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Any views or opinions are solely those of the author and do not necessarily represent those of Exel Computer Systems plc. If you have received this email in error please notify Customer Services on 0115 946 0101. ************************************************************************ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]