version 1.32, 2001/02/21 10:27:23
|
version 1.33, 2001/03/07 16:15:30
|
Line 266 void ParseCharset (Element e
|
Line 266 void ParseCharset (Element e
|
XhtmlEntityCreated |
XhtmlEntityCreated |
A XTHML entity has been created by the XML parser. |
A XTHML entity has been created by the XML parser. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
void XhtmlEntityCreated (int entityValue, |
void XhtmlEntityCreated (int entityValue, |
STRING entityName, |
STRING entityName, |
|
ThotBool entityFound, |
ParserData *context) |
ParserData *context) |
|
|
{ |
{ |
ElementType elType; |
ElementType elType; |
Element elText; |
Element elLeaf; |
AttributeType attrType; |
AttributeType attrType; |
Attribute attr; |
Attribute attr; |
Language lang; |
Language lang; |
Line 280 void XhtmlEntityCreated (int
|
Line 281 void XhtmlEntityCreated (int
|
CHAR_T buffer[MaxEntityLength+10]; |
CHAR_T buffer[MaxEntityLength+10]; |
#define MAX_ENTITY_LENGTH 80 |
#define MAX_ENTITY_LENGTH 80 |
|
|
if (entityValue < 255) |
if (entityValue <= 255 && entityFound) |
{ |
{ |
|
/* It is an ISO latin1 character */ |
buffer[0] = ((UCHAR_T) entityValue); |
buffer[0] = ((UCHAR_T) entityValue); |
buffer[1] = WC_EOS; |
buffer[1] = WC_EOS; |
lang = TtaGetLanguageIdFromAlphabet('L'); |
lang = TtaGetLanguageIdFromAlphabet('L'); |
|
PutInXmlElement (buffer); |
} |
} |
else |
else |
/* try to find a fallback character */ |
{ |
GetFallbackCharacter (entityValue, buffer, &lang); |
if (entityFound) |
|
{ |
|
/* try to find a fallback character */ |
|
GetFallbackCharacter (entityValue, buffer, &lang); |
|
} |
|
|
/* create a new text leaf */ |
/* Create a new text leaf */ |
elType.ElSSchema = TtaGetDocumentSSchema (context->doc); |
elType.ElSSchema = GetXMLSSchema (XHTML_TYPE, context->doc); |
elType.ElTypeNum = HTML_EL_TEXT_UNIT; |
elType.ElTypeNum = HTML_EL_TEXT_UNIT; |
elText = TtaNewElement (context->doc, elType); |
elLeaf = TtaNewElement (context->doc, elType); |
XmlSetElemLineNumber (elText); |
XmlSetElemLineNumber (elLeaf); |
InsertXmlElement (&elText); |
InsertXmlElement (&elLeaf); |
TtaSetTextContent (elText, buffer, lang, context->doc); |
if (buffer[0] == '?' || !entityFound) |
context->lastElement = elText; |
/* Character not found in the fallback table or not supported */ |
context->lastElementClosed = TRUE; |
/* Put the symbol '?' into the new text leaf */ |
context->mergeText = FALSE; |
TtaSetTextContent (elLeaf, TEXT("?"), lang, context->doc); |
|
else |
/* Make that text leaf read-only */ |
/* Character found in the fallback table */ |
TtaSetAccessRight (elText, ReadOnly, context->doc); |
TtaSetTextContent (elLeaf, buffer, lang, context->doc); |
|
context->lastElement = elLeaf; |
/* Associate an attribute EntityName with the new text leaf */ |
context->lastElementClosed = TRUE; |
attrType.AttrSSchema = TtaGetDocumentSSchema (context->doc); |
context->mergeText = FALSE; |
attrType.AttrTypeNum = HTML_ATTR_EntityName; |
|
attr = TtaNewAttribute (attrType); |
|
TtaAttachAttribute (elText, attr, context->doc); |
|
|
|
len = ustrlen (entityName); |
/* Make that text leaf read-only */ |
if (len > MAX_ENTITY_LENGTH -3) |
TtaSetAccessRight (elLeaf, ReadOnly, context->doc); |
len = MAX_ENTITY_LENGTH -3; |
|
buffer[0] = '&'; |
/* Associate an attribute EntityName with the new text leaf */ |
ustrncpy (&buffer[1], entityName, len); |
attrType.AttrSSchema = elType.ElSSchema; |
buffer[len+1] = ';'; |
attrType.AttrTypeNum = HTML_ATTR_EntityName; |
buffer[len+2] = WC_EOS; |
attr = TtaNewAttribute (attrType); |
TtaSetAttributeText (attr, buffer, elText, context->doc); |
TtaAttachAttribute (elLeaf, attr, context->doc); |
|
len = ustrlen (entityName); |
|
if (len > MAX_ENTITY_LENGTH -3) |
|
len = MAX_ENTITY_LENGTH -3; |
|
buffer[0] = '&'; |
|
ustrncpy (&buffer[1], entityName, len); |
|
buffer[len+1] = ';'; |
|
buffer[len+2] = WC_EOS; |
|
TtaSetAttributeText (attr, buffer, elLeaf, context->doc); |
|
} |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |