Re: [Pharo-users] XML Writer not pretty printing
Thanks! #removeAllFormattingNodes did the trick. Perhaps #prettyPrinted / #enablePrettyPrinting should call it by default? WIth regards, Peter On Tue, Aug 14, 2018 at 10:27 PM Carlo wrote: > Hi Peter > > It seems that #preservesIgnorableWhitespace: is only adhered to "...When > validation is enabled and a DTD with element declarations is present..." > (See comment in SAX2ContentHandler>>ignorableWhitespace:) The actual > parsing code is in SAXParserDriver>>handleWhitespace: > > What you could do is use #removeAllFormattingNodes but > your-mileage-may-vary... > > parser := XMLDOMParser > on:' > > > > '. > > (parser parseDocument) > removeAllFormattingNodes; > prettyPrinted. > > Regards > Carlo > > On 14 Aug 2018, at 13:08, Peter Uhnak wrote: > > Hi, > > I am trying to output a pretty printed document, but it seems that the > configuration is being ignored > > doc := ' > > > > ' parseXML. > > String << [ :stream | > doc > printOn: stream > beforeWritingDo: [ :writer | > writer > enablePrettyPrinting; > enablePlatformSpecificLineBreak. > writer formatter indentString: ' '. ] ] > > > produces > > "' > > > > '" > > I thought that maybe #preservesIgnorableWhitespace: has something to do > with it, but whether it is true or false, the output is not pretty printed > (not to mention, that pretty printing should ignore any preserved > whitespaces anyway). > > Is this a bug? Should I print it in a different way? > > Thanks, > Peter > > >
Re: [Pharo-users] XML Writer not pretty printing
Hi Peter It seems that #preservesIgnorableWhitespace: is only adhered to "...When validation is enabled and a DTD with element declarations is present..." (See comment in SAX2ContentHandler>>ignorableWhitespace:) The actual parsing code is in SAXParserDriver>>handleWhitespace: What you could do is use #removeAllFormattingNodes but your-mileage-may-vary... parser := XMLDOMParser on:' '. (parser parseDocument) removeAllFormattingNodes; prettyPrinted. Regards Carlo On 14 Aug 2018, at 13:08, Peter Uhnak wrote: Hi, I am trying to output a pretty printed document, but it seems that the configuration is being ignored doc := ' ' parseXML. String << [ :stream | doc printOn: stream beforeWritingDo: [ :writer | writer enablePrettyPrinting; enablePlatformSpecificLineBreak. writer formatter indentString: ' '. ] ] produces "' '" I thought that maybe #preservesIgnorableWhitespace: has something to do with it, but whether it is true or false, the output is not pretty printed (not to mention, that pretty printing should ignore any preserved whitespaces anyway). Is this a bug? Should I print it in a different way? Thanks, Peter
[Pharo-users] XML Writer not pretty printing
Hi, I am trying to output a pretty printed document, but it seems that the configuration is being ignored doc := ' ' parseXML. String << [ :stream | doc printOn: stream beforeWritingDo: [ :writer | writer enablePrettyPrinting; enablePlatformSpecificLineBreak. writer formatter indentString: ' '. ] ] produces "' '" I thought that maybe #preservesIgnorableWhitespace: has something to do with it, but whether it is true or false, the output is not pretty printed (not to mention, that pretty printing should ignore any preserved whitespaces anyway). Is this a bug? Should I print it in a different way? Thanks, Peter