I am using XLST files to transform XML to XML.
What are valid representation of space?
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
In word processing and digital typesetting, a non-breaking space, , also called NBSP, required space, hard space, or fixed space (though it is not of fixed width), is a space character that prevents an automatic line break at its position.
Alternatively called a fixed space or hard space, NBSP (non-breaking space) is used in programming and word processing to create a space in a line that cannot be broken by word wrap. With HTML, lets you create multiple spaces that are visible on a web page and not only in the source code.
A nonbreaking space is the same width as a word space, but it prevents the text from flowing to a new line or page. It's like invisible glue between the words on either side.
XML does not have any named entities besides <
, >
, &
, "
, and '
.
All other characters can be represented verbatim, given that you declared the right encoding in the XML declaration (e.g. <?xml version="1.0" encoding="..." ?>
), and actually saved the XML file in that encoding. Declaring UTF-8 is optional, as this is the default for XML.
The "right" encoding is any encoding that contains all the characters you want to use. Choosing Unicode is both popular and practical, but XML does not care as long as you've declared it properly.
Any character the chosen character set supports you can use as-is, with the exception of those that have special meaning in XML (<
, >
, or &
, which must always be escaped, and '
, or "
, which only must be be escaped in certain situations). All other characters can be escaped, but you don't need to.
To make a point, these representations are 100% equivalent in terms of the resulting document (i.e. the object you get after an XML parser has read the file):
<foo>Test Test</foo> <!-- unescaped - given that the " " really is char code 160 -->
<foo>Test Test</foo> <!-- partially escaped -->
<foo>Test Test</foo> <!-- decimal escaped -->
<foo>Test Test</foo> <!-- hex escaped -->
The non-breaking space is in no way special or different from, say, the letter "T". For convenience when editing the XML file with a text editor, you might want to choose the escaped form, but there is no technical requirement to do that.
Note that you can declare custom named entities (like
) using a DOCTYPE.
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
But given the fact that XML accepts any character that's hardly ever necessary. Especially not when you create the document using a proper tool, like a DOM API.
As it relates to the question, add all the entities that are causing parse errors to the DOCTYPE of your *.xls style sheet.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Now you can use
as you would normally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With