Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

All XSLT editors I've tried till now add tab or space characters to the XSLT to indent it for formatting. This is done even in places within the XSLT where these characters are significant to the XSLT processor.

XSLT modified for formatting in this way can produce output very different to that of the original XSLT if it had no formatting. To prevent this, xsl:text elements or other XSLT must be added to a sequence constructor to help separate formatting from content, this additional XSLT impacts on maintainability. Formatting characters also adversely impact on general usability of the tool in a number of ways (this is why word-processors don't use them I guess) and add to the size of the file.

As part of a larger project I've had to develop a light-weight XSLT editor, it's designed to format XSLT properly, but without tab or space characters, just a dynamic left-margin for each new line. The XSLT therefore doesn't need additional elements to separate formatting tab or space characters from content. The problem with this is that if XSLT from this editor is opened in other XSLT editors, characters will be added for formatting reasons and the XSLT may therefore no longer behave as intended.

Why then do existing XSLT editors use tabs or spaces for formatting in the first place?

I feel there must be valid reasons, perhaps historical, perhaps practical. An answer will help me understand whether I need to put compatibility options in place in my XSLT editor somehow, whether I should simply revert to using tabs or spaces for both XSLT content and formatting (though this seems like a backwards step to me), or even whether enough XSLT users might be able to persuade their tools vendors to include alternative formatting methods to tabs or spaces.

Note: I provided an XSLT sample demonstrating formatting differences in this answer to the question: Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?

share|improve this question
3  
Because in SGML/HTML/XML, whitespace is insignificant, except when it is. –  Jared Updike Sep 1 '11 at 17:31
add comment

2 Answers

Because those writing the XSLT editor, don't use it themselves to write XSLT, and confuse it with plain XML where whitespace matters less.

share|improve this answer
    
I think most developers of XSLT editors will ultimately listen to what there users ask them for. So perhaps, perhaps people aren't asking for a solution to this whitespace problem loud enough? –  pgfearo Sep 16 '11 at 20:09
add comment

I guess you'll be interested in XMLQuire which doesn't insert whitespace characters for indentation. Personally I don't mind and I know when to be careful about it, what's handy about using standard ASCII tabs and spaces for indentation is that when you need to quickly edit the file on a server, possibly with a terminal, with very basic editing capabilities, indentation is preserved so it's all legible. I think usefulness of this outweights the few rare case where it messes with your output.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.