"knocte " <knocte(_at_)gmail(_dot_)com> writes:
When you run a transformation and get breaks and spaces in the XML,
that is no different than than your HTML analogy. Whomever _consumes_
the XML needs to treat newlines as spaces. Which keeps to your
HTML/browser analogy.
Well, actually the thing is a web application that is consumed by a
browser, but I see that giving the response in only one line, like it
was "compressed", is shorter, cleaner and thus, better (I know that the
browser will ignore them too).
You chose to add spaces and breaks to your HTML to make it more
readable and the bandwidth apparently was not a concern then. Since
XML is also supposed to be readable, why insist on 1 line XML file?
The sequences:
A: "this word"
B: "thatnword"
are exactly the same length. So A (1 line) is not more "compressed"
than B (2 lines). Sure you may save a few spaces it you delete
indentation spaces, but that is probably nominal. I dont necessarily
buy "shorter, cleaner and thus, better".
If I have an XML file that I need to view or edit, then I like to have
proper indentation for readability. If the XML is only going to be
short lived and consumed by a computer, then I make sure it is at
least well-formed (if not valid) and pretty much leave the spacing up
to the tools ... they usually do the right thing(tm).
I think that I am wondering if a solution to this would be that the
second stylesheet that process the result of the first one should
normalize-space all tags that contain text unless the ones with an
attribute like notnormalize="false". What do you think? Is it possible?
Sure it is. In fact, there are a lot of ways to do this. Here's one
way off the top of my head (I'm sure the list can supply 100 others!):
<xsl:template match="text()[ not(parent::*/@notnormalize='false') ]">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
Have fun,
--
Rodman
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--