I suppose ... I guess I see the problem as a lexical issue and not an
algorithmic issue. I cannot comment on optimization opportunities
for XSLT engines when faced with an explicit string or a variable
reference ... perhaps someone on the list can comment on this.
Without looking at what any real system does I'd expect the variable to
be more efficient (in general) Although I doubt it's measurabl:-)
with an entity ref you first have to expand all the entities
and then the XSLT engine has to parse each instance as a new string
literal, whereas with a variable reference the string is internalised
just once as an xpath string and then accessed by reference (unless the
optimiser decides to inline the variable reference I suppose...)
Would you tackle the following with a variable as well?
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp ' '>
Personally I've never seen the facination with "nbsp" "#160" seems to be
just as good a spelling of that character name, so I'd just use  
I don't think people new to XSLT should forget that we are, after
all, working with XML files.
Although one problem with using entities like this is that some XML
parsers forget that a <!DOCTYPE reference doesn't imply a request to
validate so can generate lots of spurious warnings that the stylesheet
is invalid.
One use I have seen for entities in XSLT1 is as a proxy for function
definitions. Rather than having entities for xpath literals as in teh
examples here you can have an entity that expands to a boolean predicate
which you use as foo[&bar;] with teh predicate being evaluated each
time. Again though in xslt2 you can just parse the predicate once by
making it a function accessed like foo[my:bar(.)] which is often nicer
than using entity expansion.
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--