xsl-list
[Top] [All Lists]

Re: [xsl] Where did my tabs go? Trying to understand xsl:value-of, tabs and the separator attribute

2006-10-16 11:33:47



(no tabs) <xsl:value-of select="somenode" separator="{&tab;}" />

That one's an error: the &tab; is expanded before xslt starts so it is an
AVT where the expression in {} is just a tab character which isn't a
legal xpath expression.

 was under the impression that it didn't matter whether 
you had a numerical entity reference of something, or a named entity 
reference.

That's true they are all resolved before xslt starts so the xslt engine
can not treat them differently. except you have to interpret "true" in
the previous sentence with some care:-)

tabs in attribute values are normalised by an XML parser to spaces
unless they are entered as numeric character references.
and due to the details of the way entities are expanded your tab entity
expands to a tab character not to the character reference, so if you put
a literal tab or tab entity ref into any xml attribute the xml
application (eg the xslt engine) sees a space.
To stop this you need to use the character reference to #x09; or if you
want to use a named entity, define it to be a character reference, not a
character as in tab2 below

<!DOCTYPE x [
<!ENTITY tab "&#x09;" >
<!ENTITY tab2 "&#38;#x09;" >
]>
<x>

<a x="  " b="&#9;" c="&tab;" d="&tab2;"/>
</x>

run that past an xml parser and it will report


<!DOCTYPE x [
<!ENTITY tab "&#x09;" >
<!ENTITY tab2 "&#38;#x09;" >
]>
<x>

<y d="  " c=" " b="     " a=" "/>
</x>


a and c have value a space, b and d have value a tab.

isn't white space fun??

David

--~------------------------------------------------------------------
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>
--~--