Link to home
Start Free TrialLog in
Avatar of william007
william007

asked on

  in xsl code

Hi, I am new to XSLT.
I wish to put   in xsl code, but it keeps showing me
XML Parsing Error: undefined entity
for the symbol &

What is the correct way to put  ?
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of william007
william007

ASKER

>>you need to define the entity
What is entity?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm sorry to interrupt your discussion, but this topic concerns me too.

The problem is when I put <!ENTITY nbsp "&#160;" > to a XSL or XML file, the XSLT processor  (MSXML) shows the following error:
Parse error 0xc00ce580:
Cannot have a DTD declaration outside of a DTD

If I enclose the declaration to a DTD, it requires me to declare all the tag and attributes I used in the XML. But I don't want to create a DTD ot Schema for my XML, I want only to declare a single entity. What should I do?
No problem interrupting, your problem is highly relevant here

There are two modes of parsing: validating and wellformedness
replacing the entities with there replacement values is considered wellformedness checking,
but you need to put the entity declarations in a DTD
<!DOCTYPE root [
<!ENTITY nbsp "&#160;" >
]>

problem with this approach is that the DOCTYPE is used by msxml to trigger validation
(the availability of the <!DOCTYPE ... is sufficient for msxml to switch from wellformedness checking to validating parsing,
thus requiring all elements to be defined)
You can work around this by explicitely switching off the validation

if you are calling the XSLT from javascript, this would be xslObj.valdateOnParse = false;

cheers

Geert
> the DOCTYPE is used by msxml to trigger validation

I got it now, thank you very much!
Thanks :)