Re: Controlling whitespace in XSL output - tutorial anywhere?
- From: Simon Brooke <stillyet@xxxxxxxxxxxxxx>
- Date: Wed, 24 Oct 2007 11:57:30 -0000
On 23 Oct, 00:13, Joe Kesselman <keshlam-nos...@xxxxxxxxxxx> wrote:
Mike Kay's book has a good section on how XSLT treats whitespace, and
how to exercise some control over it. (I still think that book is the
best hardcopy XSLT reference I've seen -- it was good enough to keep me
from writing one.)
Thanks. I'll have a look for that.
>NHibernate chokes on whitespace inside certain elements. In consequence
>I'm currently using 'indent="no"' in my xsl-output directive
That's always the right choice unless you are formatting the document
more for human-readability than machine-readability. Indentation, by
definition, changes the content of the document. If you're generating
HTML or something else where the whitespace doesn't matter, great;
otherwise this is a Bad Thing and you Shouldn't Do It.
That's all very well, but in my experience it's a great benefit to
the
developer (and an even greater benefit to subsequent maintainers)
if intermediate results are human readable and self-documenting.
I'd really greatly prefer it if things (i.e. not XML parsers
themselves, but
the things which consume their output) which use XML formats for
configuration and so on would treat leading and trailing whitespace
as
insignificant, and treat a node which contains nothing but whitespace
as an empty node. However, Hibernate (and many other things, to be
fair)
does not do this. I agree that's a Hibernate issue and not an XML
one.
There are things you can do to hint whether spaces are intended to be
meaningful or not -- the xml:space attribute, and/or the
xsl:preserve-space and xsl:strip-space directives in the stylesheet. You
may be able to use these to explicitly retain whitespace in those places
where it actually matters and discard it where it doesn't.
>white space inside attribute values.
If the attribute type is not CDATA, XML will automatically normalize
spaces. Otherwise, it's your stylesheet's responsibility to extract only
the portion of the data you want to preserve.
Aye. However, in this circumstance I don't own the schema, so I can't
fix it.
.
- Follow-Ups:
- Re: Controlling whitespace in XSL output - tutorial anywhere?
- From: Joseph Kesselman
- Re: Controlling whitespace in XSL output - tutorial anywhere?
- References:
- Controlling whitespace in XSL output - tutorial anywhere?
- From: Simon Brooke
- Re: Controlling whitespace in XSL output - tutorial anywhere?
- From: Joe Kesselman
- Controlling whitespace in XSL output - tutorial anywhere?
- Prev by Date: Re: Trees in XML
- Next by Date: Re: Trees in XML
- Previous by thread: Re: Controlling whitespace in XSL output - tutorial anywhere?
- Next by thread: Re: Controlling whitespace in XSL output - tutorial anywhere?
- Index(es):
Relevant Pages
|