ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:68161] [Ruby trunk - Bug #10864] [Open] REXML adds white space to text property when indent > -1
       [not found] <redmine.issue-10864.20150217233550@ruby-lang.org>
@ 2015-02-17 23:35 ` alex
  2018-02-19  4:56 ` [ruby-core:85632] [Ruby trunk Bug#10864][Assigned] " hsbt
  2018-02-25  8:20 ` [ruby-core:85802] [Ruby trunk Bug#10864][Rejected] " kou
  2 siblings, 0 replies; 3+ messages in thread
From: alex @ 2015-02-17 23:35 UTC (permalink / raw
  To: ruby-core

Issue #10864 has been reported by Alex McLain.

----------------------------------------
Bug #10864: REXML adds white space to text property when indent > -1
https://bugs.ruby-lang.org/issues/10864

* Author: Alex McLain
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The following example shows that REXML is adding white space to the text property of elements when setting the :indent option on Document#write greater than -1. The value written should be the same value read.

~~~ruby
require 'rexml/document'

xml_string = ''

REXML::Document.new(xml_string).tap do |doc|
  doc.add_element('root').tap do |root|
    write_text = 'bar'
    puts "Write Text: #{write_text.inspect}"
    root.add_element('foo').text = write_text
  end
  
  doc.write output: xml_string, indent: 4
end

REXML::Document.new(xml_string).tap do |doc|
  read_text = doc.elements['/root/foo'].first
  puts "Read Text:  #{read_text.inspect}"
end

puts "XML String:"
puts xml_string
~~~

~~~text
Write Text: "bar"
Read Text:  "\n        bar\n    "
XML String:
<root>
    <foo>
        bar
    </foo>
</root>
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:85632] [Ruby trunk Bug#10864][Assigned] REXML adds white space to text property when indent > -1
       [not found] <redmine.issue-10864.20150217233550@ruby-lang.org>
  2015-02-17 23:35 ` [ruby-core:68161] [Ruby trunk - Bug #10864] [Open] REXML adds white space to text property when indent > -1 alex
@ 2018-02-19  4:56 ` hsbt
  2018-02-25  8:20 ` [ruby-core:85802] [Ruby trunk Bug#10864][Rejected] " kou
  2 siblings, 0 replies; 3+ messages in thread
From: hsbt @ 2018-02-19  4:56 UTC (permalink / raw
  To: ruby-core

Issue #10864 has been updated by hsbt (Hiroshi SHIBATA).

Status changed from Open to Assigned
Assignee set to kou (Kouhei Sutou)

----------------------------------------
Bug #10864: REXML adds white space to text property when indent > -1
https://bugs.ruby-lang.org/issues/10864#change-70419

* Author: amclain (Alex McLain)
* Status: Assigned
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The following example shows that REXML is adding white space to the text property of elements when setting the :indent option on Document#write greater than -1. The value written should be the same value read.

~~~ruby
require 'rexml/document'

xml_string = ''

REXML::Document.new(xml_string).tap do |doc|
  doc.add_element('root').tap do |root|
    write_text = 'bar'
    puts "Write Text: #{write_text.inspect}"
    root.add_element('foo').text = write_text
  end
  
  doc.write output: xml_string, indent: 4
end

REXML::Document.new(xml_string).tap do |doc|
  read_text = doc.elements['/root/foo'].first
  puts "Read Text:  #{read_text.inspect}"
end

puts "XML String:"
puts xml_string
~~~

~~~text
Write Text: "bar"
Read Text:  "\n        bar\n    "
XML String:
<root>
    <foo>
        bar
    </foo>
</root>
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:85802] [Ruby trunk Bug#10864][Rejected] REXML adds white space to text property when indent > -1
       [not found] <redmine.issue-10864.20150217233550@ruby-lang.org>
  2015-02-17 23:35 ` [ruby-core:68161] [Ruby trunk - Bug #10864] [Open] REXML adds white space to text property when indent > -1 alex
  2018-02-19  4:56 ` [ruby-core:85632] [Ruby trunk Bug#10864][Assigned] " hsbt
@ 2018-02-25  8:20 ` kou
  2 siblings, 0 replies; 3+ messages in thread
From: kou @ 2018-02-25  8:20 UTC (permalink / raw
  To: ruby-core

Issue #10864 has been updated by kou (Kouhei Sutou).

Status changed from Assigned to Rejected

If you don't want to add extra spaces with indent, use `transitive: true` option:

```ruby
require 'rexml/document'

xml_string = ''

REXML::Document.new(xml_string).tap do |doc|
  doc.add_element('root').tap do |root|
    write_text = 'bar'
    puts "Write Text: #{write_text.inspect}"
    root.add_element('foo').text = write_text
  end

  doc.write output: xml_string, indent: 4, transitive: true
end

REXML::Document.new(xml_string).tap do |doc|
  read_text = doc.elements['/root/foo'].first
  puts "Read Text:  #{read_text.inspect}"
end

puts "XML String:"
puts xml_string
```

Output:

```text
Write Text: "bar"
Read Text:  "bar"
XML String:
<root
><foo
    >bar</foo
    ></root
>
```


----------------------------------------
Bug #10864: REXML adds white space to text property when indent > -1
https://bugs.ruby-lang.org/issues/10864#change-70655

* Author: amclain (Alex McLain)
* Status: Rejected
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The following example shows that REXML is adding white space to the text property of elements when setting the :indent option on Document#write greater than -1. The value written should be the same value read.

~~~ruby
require 'rexml/document'

xml_string = ''

REXML::Document.new(xml_string).tap do |doc|
  doc.add_element('root').tap do |root|
    write_text = 'bar'
    puts "Write Text: #{write_text.inspect}"
    root.add_element('foo').text = write_text
  end
  
  doc.write output: xml_string, indent: 4
end

REXML::Document.new(xml_string).tap do |doc|
  read_text = doc.elements['/root/foo'].first
  puts "Read Text:  #{read_text.inspect}"
end

puts "XML String:"
puts xml_string
~~~

~~~text
Write Text: "bar"
Read Text:  "\n        bar\n    "
XML String:
<root>
    <foo>
        bar
    </foo>
</root>
~~~



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-25  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10864.20150217233550@ruby-lang.org>
2015-02-17 23:35 ` [ruby-core:68161] [Ruby trunk - Bug #10864] [Open] REXML adds white space to text property when indent > -1 alex
2018-02-19  4:56 ` [ruby-core:85632] [Ruby trunk Bug#10864][Assigned] " hsbt
2018-02-25  8:20 ` [ruby-core:85802] [Ruby trunk Bug#10864][Rejected] " kou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).