After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 160262 - intltool doesn't inherit xml:space attribute
intltool doesn't inherit xml:space attribute
Status: RESOLVED FIXED
Product: intltool
Classification: Deprecated
Component: general
unspecified
Other Linux
: High major
: ---
Assigned To: intltool maintainers
intltool maintainers
Depends on:
Blocks: 163689
 
 
Reported: 2004-12-02 21:00 UTC by Rodney Dawes
Modified: 2005-06-26 10:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix intltool-merge to correctly handle xml:space inheritance (4.72 KB, patch)
2004-12-03 13:12 UTC, Danilo Segan
none Details | Review
Fix intltool-merge to correctly handle xml:space inheritance (5.16 KB, patch)
2004-12-04 00:14 UTC, Danilo Segan
none Details | Review
Switch intltool-extract to XML::Parser as well (14.55 KB, patch)
2005-01-09 18:21 UTC, Danilo Segan
needs-work Details | Review
Switch intltool-extract to XML::Parser, minor cleanups (28.50 KB, patch)
2005-06-26 10:55 UTC, Danilo Segan
committed Details | Review

Description Rodney Dawes 2004-12-02 21:00:14 UTC
As specified by the XML recommendation, the xml:space attribute needs to be
inherited by children, if a parent tag specifies it. We need to do this in
intltool as well. Or perhaps we just need to preserve whitespace by default. I
believe we used to. If I knew how to inherit the property with XML::Parser, I'd
fix it myself. But, I don't... so, Danilo, can you please fix this? We need to
do this for Evolution. Thanks.
Comment 1 Danilo Segan 2004-12-03 10:38:24 UTC
Uhm, it seems we need to handle it ourselves, since XML::Parser style doesn't
help there automatically.

I'll work on a patch.
Comment 2 Danilo Segan 2004-12-03 12:55:36 UTC
Another thing: intltool-extract is not yet using XML::Parser (I planned to
switch to it, and that's why I have rewritten XML parsing in intltool-merge to
separate out getXMLString which will be useful in intltool-extract as well), so
we cannot extract such messages correctly.

Now, in what ways are you using this in Evolution, so I can see if we can at
least get a simpler quick fix? (If you don't need these to be extracted for
translation, but just intltool-merge to respect them, it's much easier at this
time :)
Comment 3 Danilo Segan 2004-12-03 13:12:45 UTC
Created attachment 34447 [details] [review]
Fix intltool-merge to correctly handle xml:space inheritance

This fixes intltool-merge at least. Fixing intltool-extract will involve
switching over to XML::Parser as well.

2004-12-03  Danilo Šegan  <dsegan@gmx.net>

	Part of fix for #160262: Correct handling of xml:space inheritance.

	* intltool-merge.in.in (traverse): Add $spacepreserve parameter.
	(translate_subnodes): Add $spacepreservee parameter.
	(getXMLstring): Add $spacepreserve parameter.
Comment 4 Rodney Dawes 2004-12-03 17:13:45 UTC
Evolution isn't using intltool yet for the error xml files. I'm working on
moving it to do so, but this bug was a blocker for that. I think the extraction
might be fine right now, if intltool-extract preserves whitespace, but I think
we need to fix it to use XML::Parser too, if we are going to extract strings
from XML for translation, but it is probably a lower priority.
Comment 5 Danilo Segan 2004-12-03 17:32:40 UTC
intltool-extract preserves whitespace only when xml:space="preserve" is present
on tag it is extracting (and always on attributes). Spaces are stripped for a
reason (which is that translators like that), and we won't go back to
non-stripping since it will cause major compatibility problems.

This means that you can't do the following:

<root>
<tag xml:space="preserve">
<_translate>
Spaces
are
preserved
</_translate>
</tag>
</root>

Of course, switch to XML::Parser is planned already (I have even started working
on it a while ago), but since I want to avoid any regressions, I'm taking my
time (i.e. I don't want to lose ability to extract comments for translators, and
I want to make as much of code reusable between both intltool-merge and
intltool-extract, so we avoid many problems in front).
Comment 6 Rodney Dawes 2004-12-03 19:01:35 UTC
Shouldn't the block of XML you just specified, work, since it has
xml:space="preserve"?
Comment 7 Danilo Segan 2004-12-03 19:11:28 UTC
Yes, it *should*, but intltool-extract uses regular expressions to extract XML,
so you can guess why it doesn't work correctly (that's why I pointed this
example out).

intltool-extract would extract message as "Spaces are preserved" instead of
"\nSpaces\nare\npreserved\n".
Comment 8 Rodney Dawes 2004-12-03 22:17:30 UTC
Hrmm. Your patch doesn't seem to fix the problem. xml:space="preserve" is set on
the root node in my xml.in, but teh resulting .xml still has the whitespace
removed. The example you pasted here should be a suitable test, but move the
xml:space attribute to the root node instead. Thanks dude.
Comment 9 Danilo Segan 2004-12-04 00:14:46 UTC
Created attachment 34473 [details] [review]
Fix intltool-merge to correctly handle xml:space inheritance

Updated patch.

2004-12-04  Danilo Šegan  <dsegan@gmx.net>

	Part of fix for #160262: Correct handling of xml:space inheritance.

	* intltool-merge.in.in (traverse): Add $spacepreserve parameter.
	(translate_subnodes): Add $spacepreservee parameter.
	(getXMLstring): Add $spacepreserve parameter.
	(parseTree): Set $spacepreserve for root node as well.
Comment 10 Danilo Segan 2004-12-04 00:16:07 UTC
Uhm, now that I think of this, I also need to check for xml:space="default" and
reset $spacepreserve to 0 in nested tags when I come across that.
Comment 11 Rodney Dawes 2004-12-04 21:05:33 UTC
Yeah, you do. I think it is a lower priority though and won't happen as often.
Comment 12 Rodney Dawes 2004-12-04 21:16:21 UTC
Hrmm. Your latest patch still isn't working for me either. :(
Comment 13 Rodney Dawes 2004-12-04 21:19:19 UTC
Ugh. Ignore me. I am stupid. I copied a broken version of the xml over to xml.in
to do the intltool conversion, without realizing it. So of course it didn't work :P.
Comment 14 Rodney Dawes 2004-12-04 21:36:18 UTC
Such confusion. Even after fixing the xml.in file to be correct, it still isn't
working for me. Here's a block to test with:

<?xml version="1.0" encoding="UTF-8"?>
<error-list domain="shell" xml:space="preserve">

 <error id="upgrade-nospace" type="error">
  <_primary>Insufficient disk space for upgrade.</_primary>
  <_secondary>Upgrading your data and settings will require up to {0} of disk
space, but you only have {1} available.

You will need to make more space available in your home directory before you can
continue.</_secondary>
  <button stock="gtk-quit" response="GTK_RESPONSE_CANCEL"/>
 </error>

</error_list>
Comment 15 Rodney Dawes 2005-01-04 21:00:24 UTC
Danilo? Can you look at this? Your patches aren't working for me, and we really
need this to work properly for Evolution. Thanks.
Comment 16 Danilo Segan 2005-01-05 00:00:00 UTC
Rodney, this is what I explained above: you want intltool-extract patches, and
that's not very trivial. My patch above would only work for cases where there're
no messages to extract (intltool-merge would output expected XML in non
"_"-marked tags).

As I also said, intltool-extract is not yet using XML::Parser itself, so I'll up
my priority on doing that, and I'll try to get there before January 10th
(feature freeze for Gnome 2.10), but I make no promises.
Comment 17 Danilo Segan 2005-01-09 18:21:27 UTC
Created attachment 35739 [details] [review]
Switch intltool-extract to XML::Parser as well

This patch switches intltool-extract to XML::Parser as well, and I fix
xml:space handling along the way.  I tried to do as much verbatim copying from
intltool-merge.in.in as I could (that was also my motivation in restructuring
XML handling code in intltool-merge), but it would need more cleaning-up.

I DON'T want to commit this before it's all cleaned up, and before I add
comment support as well (otherwise, we would have a regression in
intltool-extract, and that won't happen). Of course, I want to do more testing
as well.

I suggest you use intltool with this patch internally in Evolution until I
clean it up (it would involve cleaning up code in intltool-merge as well, and I
noticed quite a few areas that would benefit from being looked over).  This
patch is something I'd call "minimal changes from intltool-merge", it's far
from optimal!

[Note that I should handle xml:space="default" now as well, though I didn't
test it; I tested your above example, and it seems to work fine, as do all the
testcases, except the comment extraction]

2005-01-09  Danilo 各gan  <dsegan@gmx.net>

	Fix for #160262: Correct handling of xml:space inheritance.
	Switch intltool-extract to XML::Parser as well.

	* intltool-extract.in.in (intltool_tree_cdatastart)
	(intltool_tree_cdataend, intltool_tree_char)
	(intltool_tree_start): Copied verbatim from intltool-merge.in.in.
	(parseTree): Verbatim copy from intltool-merge.in.in.
	(getXMLstring): Verbatim copy from intltool-merge.in.in.
	(translate_subnodes): Copied from intltool-merge.in.in and removed
	MULTIPLE_OUTPUT handling.
	(readXml): Added, parse string as XML.
	(traverse): Added.
	(getAttributeString): Added.
	(type_xml): Use XML::Parser for extracting XML messages.

	* intltool-merge.in.in (traverse): Add $spacepreserve parameter.
	(translate_subnodes): Add $spacepreservee parameter.
	(getXMLstring): Add $spacepreserve parameter.
	(parseTree): Set $spacepreserve for root node as well.
Comment 18 Rodney Dawes 2005-01-22 01:25:46 UTC
Danilo, can you commit the intltool-merge.in.in portion of your patching for
this? And also a test case if possible? Thanks.
Comment 19 Danilo Segan 2005-06-26 10:55:54 UTC
Created attachment 48345 [details] [review]
Switch intltool-extract to XML::Parser, minor cleanups

2005-06-26  Danilo Šegan  <dsegan@gmx.net>

	Fix #160262: Correct handling of xml:space inheritance.

	* tests/selftest.pl.in: Added testcases 25 and 26 for inherited
	xml:space. 

	* tests/cases/space-preserve.xml.in: 
	* tests/cases/spacepreserve.po: 
	* tests/results/space-preserve.xml.in.h:
	* tests/results/space-preserve.xml: Added testcase.

	* tests/results/merge-deepattr.xml: Updated testcase.

	* tests/results/extract-comments.xml.h: 
	* tests/cases/extract-comments.xml: Updated testcase.

	* intltool-extract.in.in (intltool_tree_comment)
	(intltool_tree_cdatastart, intltool_tree_cdataend)
	(intltool_tree_char, intltool_tree_start, getXMLstring):
	Verbatim copy from intltool-merge.in.in.
	(readXml): Copied from intltool-merge.in.in and added comment
	handler.
	(getAttributeString): New function.

	* intltool-merge.in.in (intltool_tree_comment): Added for
	compatibility with intltool-extract.

	(getAttributeString, getXMLstring): Some code clean-ups.

	(traverse): Add $spacepreserve parameter.
	(translate_subnodes): Add $spacepreserve parameter.
	(getXMLstring): Add $spacepreserve parameter.
	(parseTree): Set $spacepreserve for root node as well.
Comment 20 Danilo Segan 2005-06-26 10:57:33 UTC
I've committed this (along with a test case which checks both inheriting
xml:space="preserve" and inheriting/reverting to xml:space="default"). Please
test as much as possible, since we're finally using XML::Parser in
intltool-extract as well (which fixes some other bugs, such as not being able to
use ">" in a comment for translators).