Subject:tabs converted to spaces Author:Joe Sims Date:20 Jul 2005 01:26 PM Originally Posted: 20 Jul 2005 01:22 PM
The problem I seem to be having is that when I run my transformation is that my tabs inside of my attribute values (which are vital since this is for an InfoPath Document) are begin translated in to spaces. I have tried tinkering with the tab setting within the options but to no prevail. I believe this problem may be routed in the tokenizing. I think there may not be a token for a tab only for a space, and thus when the tool reads whitespace it assumes it to be a space and thus my tabs become spaces. Any idea on how to maintain this whitespace other ways?
Thanks in advance.
Hi Joe,
the problem is that XML mandates that the content of an attribute should be normalized to convert line feed, carriage return and tab characters into plain spaces (see http://www.w3.org/TR/2004/REC-xml-20040204/#AVNormalize). So, if you really have to place tabs inside attributes, you should escape them as character entities (	)
Thank you replying to quickly but I just dont understand what you mean for me to do with the (	)? I need the tabs to be preserved in the element below (the value attribute) is it possible for you to show me what you mean?
Subject:tabs converted to spaces Author:(Deleted User) Date:21 Jul 2005 04:19 AM
Hi Joe,
the code you write will correctly create an attribute with a value containing tabs, if they are present in the XML node you are selecting. The issue is when you load the generated XML using a parser: in that moment the tabs will be replaced by spaces, because this is what the XML specs mandate.
There are ways to make so that the XSL generates strings like '	' instead of tabs, but unfortunately when used inside attribute values they get further processed into '	'.
Summarizing, I see only these workarounds:
1) don't place tabs into attribute values (e.g. use a text node)
2) post-process the XML to replace the tabs with the entity reference
Note: the issue would appear also for new line characters (CR and LF)