Tokens representing ordinary white space
MDOM::Token::Whitespace isa MDOM::Token isa MDOM::Element
As a full \*(L"round-trip\*(R" parser, \s-1MDOM\s0 records every last byte in a file and ensure that it is included in the MDOM::Document object.
This even includes whitespace. In fact, Perl documents are seen as \*(L"floating in a sea of whitespace\*(R", and thus any document will contain vast quantities of \*(C`MDOM::Token::Whitespace\*(C' objects.
For the most part, you shouldn't notice them. Or at least, you shouldn't have to notice them.
This means doing things like consistently using the \*(L"S for significant\*(R" series of MDOM::Node and MDOM::Element methods to do things.
If you want the nth child element, you should be using \*(C`schild\*(C' rather than \*(C`child\*(C', and likewise \*(C`snext_sibling\*(C', \*(C`sprevious_sibling\*(C', and so on and so forth.
Again, for the most part you should really not need to do anything very significant with whitespace.
But there are a couple of convenience methods provided, beyond those provided by the parent MDOM::Token and MDOM::Element classes.
Because \s-1MDOM\s0 sees documents as sitting on a sort of substrate made of whitespace, there are a couple of corner cases that get particularly nasty if they don't find whitespace in certain places.
Imagine walking down the beach to go into the ocean, and then quite unexpectedly falling off the side of the planet. Well it's somewhat equivalent to that, including the whole screaming death bit.
The \*(C`null\*(C' method is a convenience provided to get some internals out of some of these corner cases.
Specifically it create a whitespace token that represents nothing, or at least the null string ''. It's a handy way to have some \*(L"whitespace\*(R" right where you need it, without having to have any actual characters.
\*(C`tidy\*(C' is a convenience method for removing unneeded whitespace.
Specifically, it removes any whitespace from the end of a line.
Note that this doesn't include \s-1POD\s0, where you may well need to keep certain types of whitespace. The entire \s-1POD\s0 chunk lives in its own MDOM::Token::Pod object.
See the support section in the main module.
Adam Kennedy <[email protected]>
Copyright 2001 - 2006 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.