Thanks for the reply Henry. The input is HTML and am using following code for transformation StringReader reader = new StringReader(htmlText); InputSource inputSource = new InputSource(reader); StringReader reader = new StringReader(htmlText); InputSource inputSource = new InputSource(reader); htmlToXmlTransformer.transform(new DOMSource(doc), new StreamResult(resultStringWriter));
The attribute name attr1 was just an example. Yes, I think the attribute value is getting normalized but XML Spy is able to preserve the extra white spaces on transformation. Is there any way to tell parser to retain white spaces? Henry Zongaro wrote: > > Hi, Kapil. > > Kapil <[EMAIL PROTECTED]> wrote on 2007-08-13 10:18:58 AM: >> Am converting HTML to XML using XALAN tranformer. The HTML contains > element >> having attribute value with white spaces, for example >> >> The attr1 value contains two white spaces. When I convert this to XML > using >> XSLT, the extra white space is stripped. . How can I preserve extra >> whitespaces for attribute value for all elements. The white spaces are >> preserved if I do the tranformation using XML Spy. > > Is your input HTML or XHTML? If it's HTML, in what form are you getting > the input to the Xalan? > > Is the attribute name here really attr1 or is that just an example? I'm > just speculating that the attribute-value normalization rules of XML might > be getting applied; the declared type of an attribute would have an > impact. According to section 3.3.3 of the XML Recommendation,[1] "If the > attribute type is not CDATA, then the XML processor MUST further process > the normalized attribute value by discarding any leading and trailing > space (#x20) characters, and by replacing sequences of space (#x20) > characters by a single space (#x20) character." > > Thanks, > > Henry > [1] http://www.w3.org/TR/2006/REC-xml-20060816/#AVNormalize > ------------------------------------------------------------------ > Henry Zongaro XSLT Processors Development > IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044 > mailto:[EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Preserving-whitespaces-in-attribute-value-during-xsl-tranformation-tf4261429.html#a12138653 Sent from the Xalan - J - Users mailing list archive at Nabble.com.