Annotation of Amaya/amaya/XHTMLbuilder.c, revision 1.86

1.1       cvs         1: /*
                      2:  *
1.78      vatton      3:  *  (c) COPYRIGHT INRIA and W3C, 1996-2003
1.1       cvs         4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
                      7: 
                      8: /*
1.30      cvs         9:  * XHTMLbuilder.c
1.23      cvs        10:  * Builds the corresponding abstract tree for a Thot document of type HTML.
1.1       cvs        11:  *
1.20      cvs        12:  * Authors: L. Carcone
                     13:  *          V. Quint 
1.1       cvs        14:  */
                     15: 
                     16: #define THOT_EXPORT extern
                     17: #include "amaya.h"
                     18: #include "css.h"
1.2       cvs        19: #include "parser.h"
                     20: #include "HTML.h"
1.30      cvs        21: #include "fetchHTMLname.h"
1.2       cvs        22: 
1.13      cvs        23: #include "css_f.h"
1.76      vatton     24: #include "EDITstyle_f.h"
1.13      cvs        25: #include "fetchXMLname_f.h"
1.30      cvs        26: #include "fetchHTMLname_f.h"
1.22      cvs        27: #include "html2thot_f.h"
1.1       cvs        28: #include "HTMLactions_f.h"
                     29: #include "HTMLedit_f.h"
1.22      cvs        30: #include "HTMLform_f.h"
1.1       cvs        31: #include "HTMLimage_f.h"
                     32: #include "HTMLtable_f.h"
                     33: #include "HTMLimage_f.h"
                     34: #include "UIcss_f.h"
1.13      cvs        35: #include "styleparser_f.h"
1.2       cvs        36: #include "XHTMLbuilder_f.h"
1.13      cvs        37: #include "Xml2thot_f.h"
1.1       cvs        38: 
1.30      cvs        39: #define MaxMsgLength 200
                     40: 
1.47      cvs        41: /* Elements that cannot contain text as immediate children.
                     42:    When some text is present in the HTML file it must be 
                     43:    surrounded by a Pseudo_paragraph element */
                     44: static int          NoTextChild[] =
                     45: {
                     46:    HTML_EL_Document, HTML_EL_HTML, HTML_EL_HEAD, HTML_EL_BODY,
                     47:    HTML_EL_Definition_List, HTML_EL_Block_Quote, HTML_EL_Directory,
                     48:    HTML_EL_Form, HTML_EL_Menu, HTML_EL_FIELDSET,
                     49:    HTML_EL_Numbered_List, HTML_EL_Option_Menu,
                     50:    HTML_EL_Unnumbered_List, HTML_EL_Definition, HTML_EL_List_Item,
                     51:    HTML_EL_MAP, HTML_EL_map, HTML_EL_Applet,
                     52:    HTML_EL_Object, HTML_EL_IFRAME, HTML_EL_NOFRAMES,
                     53:    HTML_EL_Division, HTML_EL_Center, HTML_EL_NOSCRIPT,
                     54:    HTML_EL_Data_cell, HTML_EL_Heading_cell,
                     55:    0};
                     56: 
1.28      cvs        57: /* Define a pointer to let parser functions access the HTML entity table */
                     58: extern XmlEntity *pXhtmlEntityTable;
1.6       cvs        59: 
1.30      cvs        60: /* maximum size of error messages */
                     61: #define MaxMsgLength 200
                     62: 
1.6       cvs        63: /*----------------------------------------------------------------------
1.15      cvs        64:   ParseCharset:
1.6       cvs        65:   Parses the element HTTP-EQUIV and looks for the charset value.
                     66:   ----------------------------------------------------------------------*/
1.30      cvs        67: void             ParseCharset (Element el, Document doc) 
                     68: 
1.6       cvs        69: {
1.15      cvs        70:    AttributeType attrType;
                     71:    Attribute     attr;
                     72:    SSchema       docSSchema;
                     73:    CHARSET       charset;
1.39      cvs        74:    char         *text, *text2, *ptrText, *str;
                     75:    char          charsetname[MAX_LENGTH];
1.15      cvs        76:    int           length;
1.6       cvs        77:    int           pos, index = 0;
                     78: 
1.15      cvs        79:    charset = TtaGetDocumentCharset (doc);
                     80:    if (charset != UNDEFINED_CHARSET)
                     81:      /* the charset was already defined by the http header */
                     82:      return;
1.6       cvs        83: 
                     84:    docSSchema = TtaGetDocumentSSchema (doc);
                     85:    attrType.AttrSSchema = docSSchema;
                     86:    attrType.AttrTypeNum = HTML_ATTR_http_equiv;
                     87:    attr = TtaGetAttribute (el, attrType);
                     88:    if (attr != NULL)
                     89:      {
                     90:        /* There is a HTTP-EQUIV attribute */
                     91:        length = TtaGetTextAttributeLength (attr);
                     92:        if (length > 0)
                     93:         {
1.37      cvs        94:           text = TtaGetMemory (length + 1);
1.6       cvs        95:           TtaGiveTextAttributeValue (attr, text, &length);
1.37      cvs        96:           if (!strcasecmp (text, "content-type"))
1.6       cvs        97:             {
                     98:               attrType.AttrTypeNum = HTML_ATTR_meta_content;
                     99:               attr = TtaGetAttribute (el, attrType);
                    100:               if (attr != NULL)
                    101:                 {
                    102:                   length = TtaGetTextAttributeLength (attr);
                    103:                   if (length > 0)
                    104:                     {
1.37      cvs       105:                       text2 = TtaGetMemory (length + 1);
1.6       cvs       106:                       TtaGiveTextAttributeValue (attr, text2, &length);
                    107:                       ptrText = text2;
                    108:                       while (*ptrText)
                    109:                         {
1.53      vatton    110:                           *ptrText = tolower (*ptrText);
1.6       cvs       111:                           ptrText++;
                    112:                         }
                    113:                       
1.37      cvs       114:                       str = strstr (text2, "charset=");
1.6       cvs       115:                       if (str)
                    116:                         {
                    117:                           pos = str - text2 + 8;
1.37      cvs       118:                           while (text2[pos] != SPACE &&
                    119:                                  text2[pos] != TAB && text2[pos] != EOS)
1.6       cvs       120:                             charsetname[index++] = text2[pos++];
1.37      cvs       121:                           charsetname[index] = EOS;
1.15      cvs       122:                           charset = TtaGetCharset (charsetname);
                    123:                           if (charset != UNDEFINED_CHARSET)
1.77      cvs       124:                             TtaSetDocumentCharset (doc, charset, FALSE);
1.6       cvs       125:                         }
                    126:                       TtaFreeMemory (text2);
                    127:                     }       
                    128:                 } 
                    129:             }
                    130:           TtaFreeMemory (text);
                    131:         }
                    132:      }
                    133: }
                    134: 
1.23      cvs       135: /*----------------------------------------------------------------------
1.47      cvs       136:    XhtmlCannotContainText 
                    137:    Return TRUE if element el is a block element.
                    138:   ----------------------------------------------------------------------*/
                    139: ThotBool      XhtmlCannotContainText (ElementType elType)
                    140: 
                    141: {
                    142:    int        i;
                    143:    ThotBool   ret;
                    144: 
                    145:    if (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML"))
                    146:       /* not an HTML element */
                    147:       ret = TRUE;
                    148:    else
                    149:      {
                    150:        ret = FALSE;
                    151:        i = 0;
                    152:        while (NoTextChild[i] > 0 && NoTextChild[i] != elType.ElTypeNum)
                    153:            i++;
                    154:        if (NoTextChild[i] == elType.ElTypeNum)
                    155:            ret = TRUE;
                    156:      }
                    157:    return ret;
1.23      cvs       158: }
                    159: 
1.6       cvs       160: /*----------------------------------------------------------------------
                    161:   XhtmlElementComplete
1.20      cvs       162:   Complete Xhtml elements.
1.6       cvs       163:   Check its attributes and its contents.
                    164:   ----------------------------------------------------------------------*/
1.72      cvs       165: void       XhtmlElementComplete (ParserData *context, Element el, int *error)
1.30      cvs       166: 
                    167: {
1.72      cvs       168:    Document       doc;   
1.30      cvs       169:    ElementType    elType, newElType, childType;
                    170:    Element        constElem, child, desc, leaf, prev, next, last,
1.62      quint     171:                  elFrames, lastFrame, lastChild, parent, picture, content;
1.30      cvs       172:    Attribute      attr;
                    173:    AttributeType  attrType;
                    174:    Language       lang;
1.41      cvs       175:    char           *text;
1.39      cvs       176:    char           lastChar[2];
1.79      quint     177:    char           *name1, *data;
1.30      cvs       178:    int            length;
                    179:    SSchema        docSSchema;
1.62      quint     180:    ThotBool       isImage;
                    181:    PresentationValue    pval;
                    182:    PresentationContext  ctxt;
1.6       cvs       183: 
                    184:    *error = 0;
1.72      cvs       185:    doc = context->doc;
1.6       cvs       186:    docSSchema = TtaGetDocumentSSchema (doc);
                    187: 
                    188:    elType = TtaGetElementType (el);
                    189:    /* is this a block-level element in a character-level element? */
1.56      cvs       190:    if (!IsXMLElementInline (elType, doc) &&
1.24      cvs       191:        elType.ElTypeNum != HTML_EL_Comment_ &&
                    192:        elType.ElTypeNum != HTML_EL_XMLPI)
1.6       cvs       193:        BlockInCharLevelElem (el);
                    194: 
                    195:    newElType.ElSSchema = elType.ElSSchema;
                    196:    switch (elType.ElTypeNum)
                    197:      {
1.62      quint     198:      case HTML_EL_Object:      /* it's an object */
1.79      quint     199:        data = NULL;
1.62      quint     200:        isImage = FALSE;
                    201:        /* is there a type attribute on the object element? */
                    202:        attrType.AttrSSchema = elType.ElSSchema;
                    203:        attrType.AttrTypeNum = HTML_ATTR_Object_type;
1.6       cvs       204:        attr = TtaGetAttribute (el, attrType);
1.62      quint     205:        if (attr)
                    206:         /* there is a type attribute. Get its value to see if the object
                    207:            represents an image */
1.6       cvs       208:         {
                    209:           length = TtaGetTextAttributeLength (attr);
                    210:           if (length > 0)
                    211:             {
1.37      cvs       212:               name1 = TtaGetMemory (length + 1);
1.6       cvs       213:               TtaGiveTextAttributeValue (attr, name1, &length);
1.68      kahan     214:               if (!strcmp (name1, AM_MATHML_MIME_TYPE) ||
1.62      quint     215:                   !strcmp (name1, "application/postscript") ||
                    216:                   !strcmp (name1, "image/x-bitmap") ||
                    217:                   !strcmp (name1, "image/x-xpixmap") ||
                    218:                   !strcmp (name1, "image/gif") ||
                    219:                   !strcmp (name1, "image/jpeg") ||
                    220:                   !strcmp (name1, "image/png") ||
1.67      kahan     221:                   !strcmp (name1, "image/svg") ||
1.83      cvs       222:                   !strcmp (name1, AM_SVG_MIME_TYPE) ||
                    223:                   !strcmp (name1, AM_XHTML_MIME_TYPE) ||
                    224:                   !strcmp (name1, "text/html") ||
                    225:                   !strcmp (name1, "text/htm") ||
                    226:                   !strcmp (name1, AM_GENERIC_XML_MIME_TYPE))
1.62      quint     227:                 isImage = TRUE;
                    228:               TtaFreeMemory (name1);
                    229:             }
                    230:         }
1.79      quint     231: 
                    232:        attrType.AttrTypeNum = HTML_ATTR_data;
                    233:        attr = TtaGetAttribute (el, attrType);
                    234:        if (attr)
                    235:         /* the object has a data attribute */
                    236:         {
                    237:           length = TtaGetTextAttributeLength (attr);
                    238:           if (length > 0)
                    239:             {
                    240:               data = TtaGetMemory (length + 1);
                    241:               TtaGiveTextAttributeValue (attr, data, &length);
                    242:               if (!isImage)
                    243:                 if (!strcmp (&data[length-3], "mml") ||
                    244:                     !strcmp (&data[length-3], "gif") ||
                    245:                     !strcmp (&data[length-3], "jpg") ||
                    246:                     !strcmp (&data[length-4], "jpeg") ||
                    247:                     !strcmp (&data[length-3], "png") ||
                    248:                     !strcmp (&data[length-3], "svg") ||
1.80      cvs       249:                     !strcmp (&data[length-4], "svgz") ||
1.83      cvs       250:                     !strcmp (&data[length-3], "htm") ||
                    251:                     !strcmp (&data[length-4], "html") ||
                    252:                     !strcmp (&data[length-3], "xml"))
1.79      quint     253:                   isImage = TRUE;
                    254:             }
                    255:         }
1.62      quint     256:        picture = NULL;     /* no PICTURE element yet */
                    257:        child = TtaGetFirstChild (el);
                    258:        if (isImage)
                    259:         /* the object represents an image. We need a PICTURE element as
                    260:            child of the object to hold the image */
                    261:         {
                    262:           if (child)
                    263:             {
                    264:               elType = TtaGetElementType (child);
                    265:               if (elType.ElTypeNum == HTML_EL_PICTURE_UNIT)
                    266:                 /* there is already a PICTURE element */
                    267:                 picture = child;
                    268:             }
1.79      quint     269:           /* if the object element has no PICTURE element as its first child
1.62      quint     270:              create one */
                    271:           if (!picture)
                    272:             {
                    273:               elType.ElTypeNum = HTML_EL_PICTURE_UNIT;
                    274:               picture = TtaNewTree (doc, elType, "");
                    275:               if (child)
                    276:                 TtaInsertSibling (picture, child, TRUE, doc);
                    277:               else
                    278:                 TtaInsertFirstChild (&picture, el, doc);
                    279:               child = picture;
                    280:             }
                    281:           /* copy attribute data of the object into the SRC attribute of
                    282:              the PICTURE element */
1.79      quint     283:           if (data)
                    284:             /* the object has a data attribute */
                    285:             {
                    286:               attrType.AttrTypeNum = HTML_ATTR_SRC;
                    287:               attr = TtaGetAttribute (picture, attrType);
                    288:               if (attr == NULL)
                    289:                 {
                    290:                   attr = TtaNewAttribute (attrType);
                    291:                   TtaAttachAttribute (picture, attr, doc);
                    292:                 }
                    293:               TtaSetAttributeText (attr, data, picture, doc);
                    294:             }
                    295:           attrType.AttrTypeNum = HTML_ATTR_Height_;
1.62      quint     296:           attr = TtaGetAttribute (el, attrType);
                    297:           if (attr)
1.79      quint     298:             /* the Object has a height attribute. Applies it to the
                    299:                picture element */
                    300:             {
                    301:               length = TtaGetTextAttributeLength (attr);
                    302:               if (length > 0)
                    303:                 {
                    304:                   text = TtaGetMemory (length + 1);
                    305:                   TtaGiveTextAttributeValue (attr, text, &length);
                    306:                   /* create the corresponding attribute IntHeightPercent or */
                    307:                   /* IntHeightPxl */
                    308:                   CreateAttrHeightPercentPxl (text, el, doc, -1);
                    309:                   TtaFreeMemory (text);
                    310:                 }
                    311:             }
                    312:           attrType.AttrTypeNum = HTML_ATTR_Width__;
                    313:           attr = TtaGetAttribute (el, attrType);
                    314:           if (attr)
                    315:             /* the Object has a width attribute. Applies it to the
                    316:                picture element */
1.62      quint     317:             {
                    318:               length = TtaGetTextAttributeLength (attr);
                    319:               if (length > 0)
1.6       cvs       320:                 {
1.79      quint     321:                   text = TtaGetMemory (length + 1);
                    322:                   TtaGiveTextAttributeValue (attr, text, &length);
                    323:                   /* create the corresponding attribute IntWidthPercent or */
                    324:                   /* IntWidthPxl */
                    325:                   CreateAttrWidthPercentPxl (text, el, doc, -1);
                    326:                   TtaFreeMemory (text);
1.6       cvs       327:                 }
                    328:             }
                    329:         }
                    330:        /* is the Object_Content element already created ? */
1.62      quint     331:        if (child)
                    332:         /* the object element has at least 1 child element */
                    333:         {
                    334:           content = NULL;
                    335:           desc = child;
1.6       cvs       336:           elType = TtaGetElementType (desc);
1.62      quint     337:           if (elType.ElTypeNum != HTML_EL_Object_Content)
                    338:             {
                    339:               TtaNextSibling(&desc);
                    340:               if (desc)
                    341:                 elType = TtaGetElementType (desc);
                    342:             }
                    343:           /* is it the Object_Content element ? */
                    344:           if (elType.ElTypeNum == HTML_EL_Object_Content)
                    345:             content = desc;
                    346:           else
1.6       cvs       347:             {
1.62      quint     348:               /* create an Object_Content element */
                    349:               elType.ElTypeNum = HTML_EL_Object_Content;
                    350:               content = TtaNewElement (doc, elType);
                    351:               if (picture)
                    352:                 TtaInsertSibling (content, picture, FALSE, doc);
                    353:               else
                    354:                 TtaInsertSibling (content, child, TRUE, doc);
                    355:               /* move previous existing children into Object_Content */
1.6       cvs       356:               child = TtaGetLastChild(el);
1.62      quint     357:               while (child != content)
                    358:                 {
                    359:                   TtaRemoveTree (child, doc);
                    360:                   TtaInsertFirstChild (&child, content, doc);
                    361:                   child = TtaGetLastChild(el);
                    362:                 }
                    363:             }
                    364:           if (picture && content)
                    365:             /* there is a picture element. The Object_Content must not be
                    366:                displayed in the main view */
                    367:             {
                    368:               ctxt = TtaGetSpecificStyleContext (doc);
                    369:               /* the presentation rule to be set is not a CSS rule */
                    370:               ctxt->cssSpecificity = 0;
                    371:               ctxt->destroy = FALSE;
1.85      vatton    372:               pval.typed_data.unit = UNIT_PX;
1.62      quint     373:               pval.typed_data.value = 0;
                    374:               pval.typed_data.real = FALSE;
                    375:               TtaSetStylePresentation (PRVisibility, content, NULL, ctxt, pval);
1.6       cvs       376:             }
                    377:         }
1.79      quint     378:        if (data)
                    379:         TtaFreeMemory (data);
1.6       cvs       380:        break;
1.62      quint     381: 
1.6       cvs       382:      case HTML_EL_Unnumbered_List:
                    383:      case HTML_EL_Numbered_List:
                    384:      case HTML_EL_Menu:
                    385:      case HTML_EL_Directory:
                    386:        /* It's a List element. It should only have List_Item children.
                    387:          If it has List element chidren, move these List elements
                    388:          within their previous List_Item sibling.  This is to fix
                    389:          a bug in document generated by Mozilla. */
                    390:        prev = NULL;
                    391:        next = NULL;
                    392:        child = TtaGetFirstChild (el);
                    393:        while (child != NULL)
                    394:         {
                    395:           next = child;
                    396:           TtaNextSibling (&next);
                    397:           elType = TtaGetElementType (child);
                    398:           if (elType.ElTypeNum == HTML_EL_Unnumbered_List ||
                    399:               elType.ElTypeNum == HTML_EL_Numbered_List ||
                    400:               elType.ElTypeNum == HTML_EL_Menu ||
                    401:               elType.ElTypeNum == HTML_EL_Directory)
                    402:             /* this list element is a child of another list element */
                    403:             if (prev)
                    404:               {
                    405:                 elType = TtaGetElementType (prev);
                    406:                 if (elType.ElTypeNum == HTML_EL_List_Item)
                    407:                   {
                    408:                     /* get the last child of the previous List_Item */
                    409:                     desc = TtaGetFirstChild (prev);
                    410:                     last = NULL;
                    411:                     while (desc)
                    412:                       {
                    413:                         last = desc;
                    414:                         TtaNextSibling (&desc);
                    415:                       }
                    416:                     /* move the list element after the last child of the
                    417:                        previous List_Item */
                    418:                     TtaRemoveTree (child, doc);
                    419:                     if (last)
                    420:                       TtaInsertSibling (child, last, FALSE, doc);
                    421:                     else
                    422:                       TtaInsertFirstChild (&child, prev, doc);
                    423:                     child = prev;
                    424:                   }
                    425:               }
                    426:           prev = child;
                    427:           child = next;
                    428:         }
                    429:        break;
                    430:        
                    431:      case HTML_EL_FRAMESET:
                    432:        /* The FRAMESET element is now complete.  Gather all its FRAMESET
                    433:          and FRAME children and wrap them up in a Frames element */
                    434:        elFrames = NULL; lastFrame = NULL;
                    435:        lastChild = NULL;
                    436:        child = TtaGetFirstChild (el);
                    437:        while (child != NULL)
                    438:         {
                    439:           next = child;
                    440:           TtaNextSibling (&next);
                    441:           elType = TtaGetElementType (child);
                    442:           if (elType.ElTypeNum == HTML_EL_FRAMESET ||
                    443:               elType.ElTypeNum == HTML_EL_FRAME ||
                    444:               elType.ElTypeNum == HTML_EL_Comment_)
                    445:             {
                    446:               /* create the Frames element if it does not exist */
                    447:               if (elFrames == NULL)
                    448:                 {
                    449:                   newElType.ElSSchema = docSSchema;
                    450:                   newElType.ElTypeNum = HTML_EL_Frames;
                    451:                   elFrames = TtaNewElement (doc, newElType);
1.63      cvs       452:                   if (DocumentMeta[doc]->xmlformat)
                    453:                     XmlSetElemLineNumber (elFrames);
                    454:                   else
                    455:                     SetHtmlElemLineNumber (elFrames);
1.6       cvs       456:                   TtaInsertSibling (elFrames, child, TRUE, doc);
                    457:                 }
                    458:               /* move the element as the last child of the Frames element */
                    459:               TtaRemoveTree (child, doc);
                    460:               if (lastFrame == NULL)
                    461:                 TtaInsertFirstChild (&child, elFrames, doc);
                    462:               else
                    463:                 TtaInsertSibling (child, lastFrame, FALSE, doc);
                    464:               lastFrame = child;
                    465:             }
                    466:           child = next;
                    467:         }
                    468:        break;
                    469:        
                    470:      case HTML_EL_Input:       /* it's an INPUT without any TYPE attribute */
                    471:        /* Create a child of type Text_Input */
                    472:        elType.ElTypeNum = HTML_EL_Text_Input;
                    473:        child = TtaNewTree (doc, elType, "");
1.63      cvs       474:        if (DocumentMeta[doc]->xmlformat)
                    475:         XmlSetElemLineNumber (child);
                    476:        else
                    477:         SetHtmlElemLineNumber (child);
1.6       cvs       478:        TtaInsertFirstChild (&child, el, doc);
                    479:        /* now, process it like a Text_Input element */
                    480: 
                    481:      case HTML_EL_Text_Input:
                    482:      case HTML_EL_Password_Input:
                    483:      case HTML_EL_File_Input:
                    484:        /* get element Inserted_Text */
                    485:        child = TtaGetFirstChild (el);
                    486:        if (child != NULL)
                    487:         {
                    488:           attrType.AttrSSchema = docSSchema;
                    489:           attrType.AttrTypeNum = HTML_ATTR_Value_;
                    490:           attr = TtaGetAttribute (el, attrType);
                    491:           if (attr != NULL)
                    492:             {
                    493:               /* copy the value of attribute "value" into the first text
                    494:                  leaf of element */
                    495:               length = TtaGetTextAttributeLength (attr);
                    496:               if (length > 0)
                    497:                 {
                    498:                   /* get the text leaf */
                    499:                   leaf = TtaGetFirstChild (child);
                    500:                   if (leaf != NULL)
                    501:                     {
                    502:                       childType = TtaGetElementType (leaf);
                    503:                       if (childType.ElTypeNum == HTML_EL_TEXT_UNIT)
                    504:                         {
                    505:                           /* copy attribute value into the text leaf */
1.37      cvs       506:                           text = TtaGetMemory (length + 1);
1.6       cvs       507:                           TtaGiveTextAttributeValue (attr, text, &length);
                    508:                           TtaSetTextContent (leaf, text, 
                    509:                                              TtaGetDefaultLanguage (), doc);
                    510:                           TtaFreeMemory (text);
                    511:                         }
                    512:                     }
                    513:                 }
                    514:             }
                    515:         }
                    516:        break;
                    517:        
                    518:      case HTML_EL_META:
1.15      cvs       519:        ParseCharset (el, doc);
1.6       cvs       520:        break;
                    521: 
                    522:      case HTML_EL_STYLE_:      /* it's a STYLE element */
1.60      vatton    523:      case HTML_EL_SCRIPT_:     /* it's a SCRIPT element */
1.6       cvs       524:      case HTML_EL_Preformatted:        /* it's a PRE */
                    525:        /* if the last line of the Preformatted is empty, remove it */
                    526:        leaf = XmlLastLeafInElement (el);
                    527:        if (leaf != NULL)
                    528:         {
                    529:           elType = TtaGetElementType (leaf);
                    530:           if (elType.ElTypeNum == HTML_EL_TEXT_UNIT)
                    531:             /* the last leaf is a TEXT element */
                    532:             {
                    533:               length = TtaGetTextLength (leaf);
                    534:               if (length > 0)
                    535:                 {
                    536:                   TtaGiveSubString (leaf, lastChar, length, 1);
                    537:                   if (lastChar[0] == EOL)
                    538:                     /* last character is new line, delete it */
                    539:                     {
                    540:                       if (length == 1)
                    541:                         /* empty TEXT element */
                    542:                         TtaDeleteTree (leaf, doc);
                    543:                       else
                    544:                         /* remove the last character */
                    545:                         TtaDeleteTextContent (leaf, length, 1, doc);
                    546:                     }
                    547:                 }
                    548:             }
                    549:         }
1.75      kahan     550:        if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
1.63      cvs       551:         {
                    552:           if (IsXmlParsingCSS ())
                    553:             {
                    554:               text = GetStyleContents (el);
                    555:               if (text)
                    556:                 {
1.71      vatton    557:                   ReadCSSRules (doc, NULL, text, NULL,
1.82      quint     558:                                 TtaGetElementLineNumber (el), FALSE, el);
1.63      cvs       559:                   TtaFreeMemory (text);
                    560:                 }
                    561:               SetXmlParsingCSS (FALSE);
                    562:             }
                    563:         }
                    564:        else
1.6       cvs       565:         {
1.63      cvs       566:           if (IsHtmlParsingCSS ())
1.6       cvs       567:             {
1.63      cvs       568:               text = GetStyleContents (el);
                    569:               if (text)
                    570:                 {
1.71      vatton    571:                   ReadCSSRules (doc, NULL, text, NULL,
1.82      quint     572:                                 TtaGetElementLineNumber (el), FALSE, el);
1.63      cvs       573:                   TtaFreeMemory (text);
                    574:                 }
                    575:               SetHtmlParsingCSS (FALSE);
1.6       cvs       576:             }
                    577:         }
                    578:        /* and continue as if it were a Preformatted or a Script */
                    579:        break;
                    580:        
                    581:      case HTML_EL_Text_Area:   /* it's a Text_Area */
1.69      cvs       582:        if (DocumentMeta[doc]->xmlformat)
                    583:         SetParsingTextArea (FALSE);
                    584:        else
                    585:         SetHtmlParsingTextArea (FALSE);
1.6       cvs       586:        child = TtaGetFirstChild (el);
                    587:        if (child == NULL)
                    588:         /* it's an empty Text_Area */
                    589:         /* insert a Inserted_Text element in the element */
                    590:         {
                    591:           newElType.ElTypeNum = HTML_EL_Inserted_Text;
                    592:           child = TtaNewTree (doc, newElType, "");
                    593:           TtaInsertFirstChild (&child, el, doc);
                    594:         }
                    595:        else
                    596:         {
                    597:           /* save the text into Default_Value attribute */
                    598:           attrType.AttrSSchema = docSSchema;
                    599:           attrType.AttrTypeNum = HTML_ATTR_Default_Value;
                    600:           if (TtaGetAttribute (el, attrType) == NULL)
                    601:             /* attribute Default_Value is missing */
                    602:             {
                    603:               attr = TtaNewAttribute (attrType);
                    604:               TtaAttachAttribute (el, attr, doc);
                    605:               desc = TtaGetFirstChild (child);
                    606:               length = TtaGetTextLength (desc) + 1;
1.37      cvs       607:               text = TtaGetMemory (length);
1.6       cvs       608:               TtaGiveTextContent (desc, text, &length, &lang);
                    609:               TtaSetAttributeText (attr, text, el, doc);
                    610:               TtaFreeMemory (text);
                    611:             }
                    612:         }
                    613:        /* insert a Frame element */
                    614:        newElType.ElTypeNum = HTML_EL_Frame;
                    615:        constElem = TtaNewTree (doc, newElType, "");
                    616:        TtaInsertSibling (constElem, child, FALSE, doc);
                    617:        break;
                    618:        
                    619:      case HTML_EL_Radio_Input:
                    620:      case HTML_EL_Checkbox_Input:
                    621:        /* put an attribute Checked if it is missing */
                    622:        attrType.AttrSSchema = docSSchema;
                    623:        attrType.AttrTypeNum = HTML_ATTR_Checked;
                    624:        if (TtaGetAttribute (el, attrType) == NULL)
                    625:         /* attribute Checked is missing */
                    626:         {
                    627:           attr = TtaNewAttribute (attrType);
                    628:           TtaAttachAttribute (el, attr, doc);
                    629:           TtaSetAttributeValue (attr, HTML_ATTR_Checked_VAL_No_, el, doc);
                    630:         }
                    631:        break;
                    632:        
                    633:      case HTML_EL_Option_Menu:
                    634:        /* Check that at least one option has a SELECTED attribute */
                    635:        OnlyOneOptionSelected (el, doc, TRUE);
                    636:        break;
                    637: 
                    638:      case HTML_EL_PICTURE_UNIT:
                    639:        break;
                    640:        
                    641:      case HTML_EL_LINK:
                    642:        CheckCSSLink (el, doc, docSSchema);
                    643:        break;
                    644:        
                    645:      case HTML_EL_Data_cell:
                    646:      case HTML_EL_Heading_cell:
                    647:        /* insert a pseudo paragraph into empty cells */
                    648:        child = TtaGetFirstChild (el);
                    649:        if (child == NULL)
                    650:         {
                    651:           elType.ElTypeNum = HTML_EL_Pseudo_paragraph;
                    652:           child = TtaNewTree (doc, elType, "");
                    653:           if (child != NULL)
                    654:               TtaInsertFirstChild (&child, el, doc);
                    655:         }
                    656:        
1.80      cvs       657:        /* detect whether we are parsing a whole table or just a cell */
1.63      cvs       658:        if (DocumentMeta[doc]->xmlformat)
                    659:         {
                    660:           if (IsWithinXmlTable ())
                    661:             NewCell (el, doc, FALSE);
                    662:         }
                    663:        else
                    664:         {
                    665:           if (IsWithinHtmlTable ())
                    666:             NewCell (el, doc, FALSE);
                    667:         }
1.6       cvs       668:        break;
                    669:        
                    670:      case HTML_EL_Table:
                    671:        CheckTable (el, doc);
                    672:        SubWithinTable ();
                    673:        break;
                    674:        
                    675:      case HTML_EL_TITLE:
                    676:        /* show the TITLE in the main window */
                    677:        UpdateTitle (el, doc);
                    678:        break;
1.41      cvs       679: 
                    680:      case HTML_EL_rbc:
                    681:        /* an rbc element has been read. Its parent should be a complex_ruby.
                    682:          Change the type of the parent, as simple_ruby are created by
                    683:          default */
                    684:        parent = TtaGetParent (el);
                    685:        if (parent)
                    686:         {
                    687:           newElType = TtaGetElementType (parent);
                    688:           if (newElType.ElSSchema == elType.ElSSchema &&
                    689:               newElType.ElTypeNum == HTML_EL_simple_ruby)
                    690:              ChangeElementType (parent, HTML_EL_complex_ruby);
                    691:         }
                    692:        break;
                    693: 
                    694:      case HTML_EL_rtc1:
                    695:        /* an rtc element has been parsed. If it has already a rtc1 sibling,
                    696:          change its type to rtc2 */
                    697:        prev = el;
                    698:        do
                    699:         {
                    700:           TtaPreviousSibling(&prev);
                    701:           if (prev)
                    702:             {
                    703:               newElType = TtaGetElementType (prev);
                    704:               if (newElType.ElSSchema == elType.ElSSchema &&
                    705:                   newElType.ElTypeNum == HTML_EL_rtc1)
                    706:                 {
                    707:                   ChangeElementType (el, HTML_EL_rtc2);
                    708:                   prev = NULL;
                    709:                 }
                    710:             }
                    711:         }
                    712:        while (prev);
                    713:        break;
                    714: 
1.6       cvs       715:      default:
                    716:        break;
                    717:      }
                    718: }
1.1       cvs       719: 
                    720: /*----------------------------------------------------------------------
1.30      cvs       721:    PutInContent    
                    722:    Put the string ChrString in the leaf of current element.
                    723:   ----------------------------------------------------------------------*/
1.39      cvs       724: Element         PutInContent (char *ChrString, ParserData *context)
1.30      cvs       725: 
                    726: {
                    727:    Element      el, child;
                    728:    ElementType  elType;
                    729:    int          length;
                    730: 
                    731:    el = NULL;
                    732:    if (context->lastElement != NULL)
                    733:      {
                    734:        /* search first leaf of current element */
                    735:        el = context->lastElement;
                    736:        do
                    737:          {
                    738:             child = TtaGetFirstChild (el);
                    739:             if (child != NULL)
                    740:                el = child;
                    741:          }
                    742:        while (child != NULL);
                    743:        elType = TtaGetElementType (el);
                    744:        length = 0;
                    745:        if (elType.ElTypeNum == 1)
                    746:           length = TtaGetTextLength (el);
                    747:        if (length == 0)
                    748:           TtaSetTextContent (el, ChrString, context->language, context->doc);
                    749:        else
                    750:           TtaAppendTextContent (el, ChrString, context->doc);
                    751:      }
                    752:    return el;
                    753: }
                    754: 
                    755: /*----------------------------------------------------------------------
1.51      cvs       756:    UnknownXhtmlNameSpace
1.65      cvs       757:    The element doesn't belong to a supported namespace
1.51      cvs       758:   ----------------------------------------------------------------------*/
1.65      cvs       759: void               UnknownXhtmlNameSpace (ParserData *context,
                    760:                                          Element *unknownEl,
                    761:                                          char* content)
1.51      cvs       762: {
                    763:    ElementType     elType;
1.65      cvs       764:    Element         elText;
1.51      cvs       765: 
                    766:    /* Create a new Invalid_element */
                    767:    elType.ElSSchema = GetXMLSSchema (XHTML_TYPE, context->doc);
                    768:    elType.ElTypeNum = HTML_EL_Unknown_namespace;
1.65      cvs       769:    *unknownEl = TtaNewElement (context->doc, elType);
                    770:    if (*unknownEl != NULL)
1.51      cvs       771:      {
1.65      cvs       772:        XmlSetElemLineNumber (*unknownEl);
                    773:        InsertXmlElement (unknownEl);
1.51      cvs       774:        context->lastElementClosed = TRUE;
                    775:        elType.ElTypeNum = HTML_EL_TEXT_UNIT;
                    776:        elText = TtaNewElement (context->doc, elType);
                    777:        XmlSetElemLineNumber (elText);
1.65      cvs       778:        TtaInsertFirstChild (&elText, *unknownEl, context->doc);
1.51      cvs       779:        TtaSetTextContent (elText, content, context->language, context->doc);
                    780:        TtaSetAccessRight (elText, ReadOnly, context->doc);
                    781:      }
                    782: }
                    783: 
                    784: /*----------------------------------------------------------------------
1.30      cvs       785:    CreateHTMLAttribute
                    786:    create an attribute of type attrType for the element el.
                    787:   ----------------------------------------------------------------------*/
                    788: void           CreateHTMLAttribute (Element       el,
                    789:                                    AttributeType attrType,
1.46      cvs       790:                                    char*         text,
1.30      cvs       791:                                    ThotBool      isInvalid,
                    792:                                    Document      doc,
                    793:                                    Attribute    *lastAttribute,
                    794:                                    Element      *lastAttrElement)
                    795:      
                    796: {
                    797:    int         attrKind;
                    798:    int         length;
1.39      cvs       799:    char       *buffer;
1.30      cvs       800:    Attribute   attr, oldAttr;
                    801: 
                    802:    if (attrType.AttrTypeNum != 0)
                    803:      {
                    804:        oldAttr = TtaGetAttribute (el, attrType);
                    805:        if (oldAttr != NULL)
                    806:         /* this attribute already exists */
                    807:         attr = oldAttr;
                    808:        else
                    809:         /* create a new attribute and attach it to the element */
                    810:         {
                    811:           attr = TtaNewAttribute (attrType);
                    812:           TtaAttachAttribute (el, attr, doc);
                    813:         }
                    814:        *lastAttribute = attr;
                    815:        *lastAttrElement = el;
                    816: 
                    817:        TtaGiveAttributeType (attr, &attrType, &attrKind);
                    818:        if (attrKind == 0)      /* enumerate */
                    819:         TtaSetAttributeValue (attr, 1, el, doc);
                    820: 
                    821:        /* attribute BORDER without any value (ThotBool attribute) is */
                    822:        /* considered as BORDER=1 */
                    823:        if (attrType.AttrTypeNum == HTML_ATTR_Border)
                    824:         TtaSetAttributeValue (attr, 1, el, doc);
                    825: 
                    826:        if (isInvalid)
                    827:         /* Copy the name of the invalid attribute as the content */
                    828:         /* of the Invalid_attribute attribute. */
                    829:         {
1.37      cvs       830:           length = strlen (text) + 2;
1.30      cvs       831:           length += TtaGetTextAttributeLength (attr);
1.37      cvs       832:           buffer = TtaGetMemory (length + 1);
1.30      cvs       833:           TtaGiveTextAttributeValue (attr, buffer, &length);
1.37      cvs       834:           strcat (buffer, " ");
                    835:           strcat (buffer, text);
1.30      cvs       836:           TtaSetAttributeText (attr, buffer, el, doc);
                    837:           TtaFreeMemory (buffer);
                    838:         }
                    839:      }
                    840: }
                    841: 
                    842: /*----------------------------------------------------------------------
                    843:    HTMLTypeAttrValue
                    844:    Value val has been read for the HTML attribute TYPE.
                    845:    Create a child for the current Thot element INPUT accordingly.
                    846:   ----------------------------------------------------------------------*/
1.46      cvs       847: void               HTMLTypeAttrValue (char       *val,
1.30      cvs       848:                                      Attribute   lastAttribute,
                    849:                                      Element     lastAttrElement,
                    850:                                      ParserData *context)
                    851: 
                    852: {
                    853:   ElementType      elType;
                    854:   Element          newChild;
                    855:   AttributeType    attrType;
                    856:   Attribute        attr;
1.39      cvs       857:   char             msgBuffer[MaxMsgLength];
1.30      cvs       858:   int              value;
                    859:   int              numberOfLinesRead;
                    860: 
                    861:   value = MapAttrValue (DummyAttribute, val);
                    862:   if (value < 0)
                    863:     {
1.37      cvs       864:       if (strlen (val) > MaxMsgLength - 40)
                    865:          val[MaxMsgLength - 40] = EOS;
                    866:       sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val);
1.42      cvs       867:       HTMLParseError (context->doc, msgBuffer);
1.30      cvs       868:       attrType.AttrSSchema = TtaGetDocumentSSchema (context->doc);
                    869:       attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute;
1.37      cvs       870:       sprintf (msgBuffer, "type=%s", val);
1.30      cvs       871:       CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
                    872:                           context->doc, &lastAttribute, &lastAttrElement);
                    873:     }
                    874:   else
                    875:     {
                    876:       elType = TtaGetElementType (context->lastElement);
                    877:       if (elType.ElTypeNum != HTML_EL_Input)
                    878:        {
1.37      cvs       879:          if (strlen (val) > MaxMsgLength - 40)
                    880:            val[MaxMsgLength - 40] = EOS;
                    881:          sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
1.30      cvs       882:        }
                    883:       else
                    884:        {
                    885:          elType.ElSSchema = TtaGetDocumentSSchema (context->doc);
                    886:          elType.ElTypeNum = value;
                    887:          newChild = TtaNewTree (context->doc, elType, "");
                    888:          numberOfLinesRead = 0;
                    889:          TtaSetElementLineNumber (newChild, numberOfLinesRead);
                    890:          TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
                    891:          if (value == HTML_EL_PICTURE_UNIT)
                    892:            {
                    893:              /* add the attribute IsInput to input pictures */
                    894:              attrType.AttrSSchema = elType.ElSSchema;
                    895:              attrType.AttrTypeNum = HTML_ATTR_IsInput;
                    896:              attr = TtaNewAttribute (attrType);
                    897:              TtaAttachAttribute (newChild, attr, context->doc);
                    898:            }
                    899:        }
                    900:     }
                    901: }
                    902: 
                    903: /*----------------------------------------------------------------------
                    904:    XhtmlTypeAttrValue 
                    905:    Value val has been read for the HTML attribute TYPE.
                    906:    Create a child for the current Thot element INPUT accordingly.
                    907:   ----------------------------------------------------------------------*/
1.46      cvs       908: void              XhtmlTypeAttrValue (char       *val,
1.30      cvs       909:                                      Attribute   currentAttribute,
                    910:                                      Element     lastAttrElement,
                    911:                                      ParserData *context)
                    912: 
                    913: {
                    914:   ElementType     elType;
                    915:   Element         newChild;
                    916:   AttributeType   attrType;
                    917:   Attribute       attr;
1.39      cvs       918:   char            msgBuffer[MaxMsgLength];
1.30      cvs       919:   int             value;
                    920:   ThotBool        level;
                    921: 
                    922:   attrType.AttrTypeNum = DummyAttribute;
                    923:   MapHTMLAttributeValue (val, attrType, &value);
                    924:   if (value < 0)
                    925:     {
1.37      cvs       926:       sprintf (msgBuffer, "Unknown attribute value \"type=%s\"", val);
1.30      cvs       927:       XmlParseError (errorParsing, msgBuffer, 0);
1.36      cvs       928:       MapHTMLAttribute ("unknown_attr", &attrType, NULL,
1.30      cvs       929:                        &level, context->doc);
1.37      cvs       930:       sprintf (msgBuffer, "type=%s", val);
1.30      cvs       931:       CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
                    932:                           context->doc, &currentAttribute, &lastAttrElement);
                    933:     }
                    934:   else
                    935:     {
                    936:       elType = TtaGetElementType (context->lastElement);
                    937:       if (elType.ElTypeNum != HTML_EL_Input)
                    938:        {
1.37      cvs       939:          sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
1.30      cvs       940:          XmlParseError (errorParsing, msgBuffer, 0);
                    941:        }
                    942:       else
                    943:        {
                    944:          elType.ElTypeNum = value;
                    945:          newChild = TtaNewTree (context->doc, elType, "");
                    946:          XmlSetElemLineNumber (newChild);
                    947:          TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
                    948:          if (value == HTML_EL_PICTURE_UNIT)
                    949:            {
                    950:              /* add the attribute IsInput to input pictures */
                    951:              attrType.AttrSSchema = elType.ElSSchema;
                    952:              attrType.AttrTypeNum = HTML_ATTR_IsInput;
                    953:              attr = TtaNewAttribute (attrType);
                    954:              TtaAttachAttribute (newChild, attr, context->doc);
                    955:            }
                    956:        }
                    957:     }
                    958: }
                    959: 
                    960: /*----------------------------------------------------------------------
                    961:    CreateAttrWidthPercentPxl
1.79      quint     962:    an HTML attribute "width" has been created for a Table, an image,
                    963:    an Object of a HR.
1.30      cvs       964:    Create the corresponding attribute IntWidthPercent or IntWidthPxl.
                    965:    oldWidth is -1 or the old image width.
                    966:   ----------------------------------------------------------------------*/
1.58      vatton    967: void CreateAttrWidthPercentPxl (char *buffer, Element el,
                    968:                                Document doc, int oldWidth)
1.30      cvs       969: {
                    970:   AttributeType   attrTypePxl, attrTypePercent;
                    971:   Attribute       attrOld, attrNew;
                    972:   int             length, val;
1.39      cvs       973:   char            msgBuffer[MaxMsgLength];
1.79      quint     974:   ElementType    elType, childType;
                    975:   Element         origEl, child;
1.30      cvs       976:   int             w, h;
                    977:   ThotBool        isImage;
                    978: 
1.79      quint     979:   origEl = el;
1.30      cvs       980:   elType = TtaGetElementType (el);
                    981:   isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
                    982:             elType.ElTypeNum == HTML_EL_Data_cell ||
1.79      quint     983:             elType.ElTypeNum == HTML_EL_Heading_cell ||
                    984:             elType.ElTypeNum == HTML_EL_Object);
                    985:   if (elType.ElTypeNum == HTML_EL_Object)
                    986:     /* the width attribute is attached to an Object element */
                    987:     {
                    988:       child = TtaGetFirstChild (el);
                    989:       if (child)
                    990:        {
                    991:          childType = TtaGetElementType (child);
                    992:          if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
                    993:            /* the Object element is of type image. apply the width
                    994:               attribute to the actual image element */
                    995:            el = child;
                    996:        }
                    997:     }
1.30      cvs       998:   /* remove trailing spaces */
1.37      cvs       999:   length = strlen (buffer) - 1;
1.30      cvs      1000:   while (length > 0 && buffer[length] <= SPACE)
                   1001:     length--;
                   1002:   attrTypePxl.AttrSSchema = TtaGetDocumentSSchema (doc);
                   1003:   attrTypePercent.AttrSSchema = TtaGetDocumentSSchema (doc);
                   1004:   attrTypePxl.AttrTypeNum = HTML_ATTR_IntWidthPxl;
                   1005:   attrTypePercent.AttrTypeNum = HTML_ATTR_IntWidthPercent;
                   1006:   /* is the last character a '%' ? */
                   1007:   if (buffer[length] == '%')
                   1008:     {
                   1009:       /* remove IntWidthPxl */
                   1010:       attrOld = TtaGetAttribute (el, attrTypePxl);
                   1011:       /* update IntWidthPercent */
                   1012:       attrNew = TtaGetAttribute (el, attrTypePercent);
                   1013:       if (attrNew == NULL)
                   1014:        {
                   1015:          attrNew = TtaNewAttribute (attrTypePercent);
                   1016:          TtaAttachAttribute (el, attrNew, doc);
                   1017:        }
                   1018:       else if (isImage && oldWidth == -1)
                   1019:        {
                   1020:          if (attrOld == NULL)
                   1021:            oldWidth = TtaGetAttributeValue (attrNew);
                   1022:          else
                   1023:            oldWidth = TtaGetAttributeValue (attrOld);
                   1024:        }
                   1025:     }
                   1026:   else
                   1027:     {
                   1028:       /* remove IntWidthPercent */
                   1029:       attrOld = TtaGetAttribute (el, attrTypePercent);
                   1030:       /* update IntWidthPxl */
                   1031:       attrNew = TtaGetAttribute (el, attrTypePxl);
                   1032:       if (attrNew == NULL)
                   1033:        {
                   1034:          attrNew = TtaNewAttribute (attrTypePxl);
                   1035:          TtaAttachAttribute (el, attrNew, doc);
                   1036:        }
                   1037:       else if (isImage && oldWidth == -1)
                   1038:        {
                   1039:          TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
                   1040:          if (attrOld == NULL)
                   1041:            oldWidth = w * TtaGetAttributeValue (attrNew) / 100;
                   1042:          else
                   1043:            oldWidth = w * TtaGetAttributeValue (attrOld) / 100;          
                   1044:        }
                   1045:     }
                   1046: 
                   1047:   if (attrOld != NULL)
                   1048:     TtaRemoveAttribute (el, attrOld, doc);
1.43      cvs      1049:   if (sscanf (buffer, "%d", &val))
1.30      cvs      1050:     TtaSetAttributeValue (attrNew, val, el, doc);
                   1051:   else
                   1052:     /* its not a number. Delete attribute and send an error message */
                   1053:     {
                   1054:     TtaRemoveAttribute (el, attrNew, doc);
1.37      cvs      1055:     if (strlen (buffer) > MaxMsgLength - 30)
1.30      cvs      1056:         buffer[MaxMsgLength - 30] = EOS;
1.37      cvs      1057:     sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
1.42      cvs      1058:     HTMLParseError (doc, msgBuffer);
1.30      cvs      1059:     }
                   1060:   if (isImage)
1.79      quint    1061:     UpdateImageMap (origEl, doc, oldWidth, -1);
1.30      cvs      1062: }
                   1063: 
                   1064: /*----------------------------------------------------------------------
1.58      vatton   1065:    CreateAttrHeightPercentPxl
1.79      quint    1066:    an HTML attribute "width" has been created for a Table, an image,
                   1067:    an Object or a HR.
1.58      vatton   1068:    Create the corresponding attribute IntHeightPercent or IntHeightPxl.
                   1069:    oldHeight is -1 or the old image width.
                   1070:   ----------------------------------------------------------------------*/
                   1071: void CreateAttrHeightPercentPxl (char *buffer, Element el,
                   1072:                                Document doc, int oldHeight)
                   1073: {
                   1074:   AttributeType   attrTypePxl, attrTypePercent;
                   1075:   Attribute       attrOld, attrNew;
                   1076:   int             length, val;
                   1077:   char            msgBuffer[MaxMsgLength];
1.79      quint    1078:   ElementType    elType, childType;
                   1079:   Element         origEl, child;
1.58      vatton   1080:   int             w, h;
                   1081:   ThotBool        isImage;
                   1082: 
1.79      quint    1083:   origEl = el;
1.58      vatton   1084:   elType = TtaGetElementType (el);
                   1085:   isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
                   1086:             elType.ElTypeNum == HTML_EL_Data_cell ||
1.79      quint    1087:             elType.ElTypeNum == HTML_EL_Heading_cell ||
                   1088:             elType.ElTypeNum == HTML_EL_Object);
                   1089:   if (elType.ElTypeNum == HTML_EL_Object)
                   1090:     /* the height attribute is attached to an Object element */
                   1091:     {
                   1092:       child = TtaGetFirstChild (el);
1.81      cvs      1093:       if (!child)
                   1094:        return;
                   1095:       else
1.79      quint    1096:        {
                   1097:          childType = TtaGetElementType (child);
                   1098:          if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
                   1099:            /* the Object element is of type image. apply the width
                   1100:               attribute to the actual image element */
                   1101:            el = child;
1.81      cvs      1102:          else
                   1103:            return;
1.79      quint    1104:        }
                   1105:     }
1.58      vatton   1106:   /* remove trailing spaces */
                   1107:   length = strlen (buffer) - 1;
                   1108:   while (length > 0 && buffer[length] <= SPACE)
                   1109:     length--;
                   1110:   attrTypePxl.AttrSSchema = TtaGetDocumentSSchema (doc);
                   1111:   attrTypePercent.AttrSSchema = TtaGetDocumentSSchema (doc);
                   1112:   attrTypePxl.AttrTypeNum = HTML_ATTR_IntHeightPxl;
                   1113:   attrTypePercent.AttrTypeNum = HTML_ATTR_IntHeightPercent;
                   1114:   /* is the last character a '%' ? */
                   1115:   if (buffer[length] == '%')
                   1116:     {
                   1117:       /* remove IntHeightPxl */
                   1118:       attrOld = TtaGetAttribute (el, attrTypePxl);
                   1119:       /* update IntHeightPercent */
                   1120:       attrNew = TtaGetAttribute (el, attrTypePercent);
                   1121:       if (attrNew == NULL)
                   1122:        {
                   1123:          attrNew = TtaNewAttribute (attrTypePercent);
                   1124:          TtaAttachAttribute (el, attrNew, doc);
                   1125:        }
                   1126:       else if (isImage && oldHeight == -1)
                   1127:        {
                   1128:          if (attrOld == NULL)
                   1129:            oldHeight = TtaGetAttributeValue (attrNew);
                   1130:          else
                   1131:            oldHeight = TtaGetAttributeValue (attrOld);
                   1132:        }
                   1133:     }
                   1134:   else
                   1135:     {
                   1136:       /* remove IntHeightPercent */
                   1137:       attrOld = TtaGetAttribute (el, attrTypePercent);
                   1138:       /* update IntHeightPxl */
                   1139:       attrNew = TtaGetAttribute (el, attrTypePxl);
                   1140:       if (attrNew == NULL)
                   1141:        {
                   1142:          attrNew = TtaNewAttribute (attrTypePxl);
                   1143:          TtaAttachAttribute (el, attrNew, doc);
                   1144:        }
                   1145:       else if (isImage && oldHeight == -1)
                   1146:        {
                   1147:          TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
                   1148:          if (attrOld == NULL)
                   1149:            oldHeight = w * TtaGetAttributeValue (attrNew) / 100;
                   1150:          else
                   1151:            oldHeight = w * TtaGetAttributeValue (attrOld) / 100;         
                   1152:        }
                   1153:     }
                   1154: 
                   1155:   if (attrOld != NULL)
                   1156:     TtaRemoveAttribute (el, attrOld, doc);
                   1157:   if (sscanf (buffer, "%d", &val))
                   1158:     TtaSetAttributeValue (attrNew, val, el, doc);
                   1159:   else
                   1160:     /* its not a number. Delete attribute and send an error message */
                   1161:     {
                   1162:     TtaRemoveAttribute (el, attrNew, doc);
                   1163:     if (strlen (buffer) > MaxMsgLength - 30)
                   1164:         buffer[MaxMsgLength - 30] = EOS;
                   1165:     sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
                   1166:     HTMLParseError (doc, msgBuffer);
                   1167:     }
                   1168:   if (isImage)
1.79      quint    1169:     UpdateImageMap (origEl, doc, oldHeight, -1);
1.58      vatton   1170: }
                   1171: 
                   1172: /*----------------------------------------------------------------------
1.30      cvs      1173:    CreateAttrIntSize
                   1174:    an HTML attribute "size" has been created for a Font element.
                   1175:    Create the corresponding internal attribute.
                   1176:   ----------------------------------------------------------------------*/
1.46      cvs      1177: void              CreateAttrIntSize (char *buffer, Element el, Document doc)
1.30      cvs      1178: 
                   1179: {
                   1180:    AttributeType  attrType;
                   1181:    int            val, ind, factor, delta;
                   1182:    Attribute      attr;
1.37      cvs      1183:    char         msgBuffer[MaxMsgLength];
1.30      cvs      1184: 
                   1185:    /* is the first character a '+' or a '-' ? */
                   1186:    ind = 0;
                   1187:    factor = 1;
                   1188:    delta = 0;
                   1189:    if (buffer[0] == '+')
                   1190:      {
                   1191:        attrType.AttrTypeNum = HTML_ATTR_IntSizeIncr;
                   1192:        ind++;
                   1193:        factor = 2;
                   1194:      }
                   1195:    else if (buffer[0] == '-')
                   1196:      {
                   1197:        attrType.AttrTypeNum = HTML_ATTR_IntSizeDecr;
                   1198:        ind++;
                   1199:        factor = 2;
                   1200:      }
                   1201:    else
                   1202:      {
                   1203:        attrType.AttrTypeNum = HTML_ATTR_IntSizeRel;
                   1204:        delta = 1;
                   1205:      }
                   1206:    attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
                   1207:    attr = TtaGetAttribute (el, attrType);
1.43      cvs      1208:    if (sscanf (&buffer[ind], "%d", &val))
1.30      cvs      1209:      {
                   1210:        val = val * factor + delta;
                   1211:        if (attr == NULL)
                   1212:         {
                   1213:           /* this attribute doesn't exist, create it */
                   1214:           attr = TtaNewAttribute (attrType);
                   1215:           TtaAttachAttribute (el, attr, doc);
                   1216:         }
                   1217:        TtaSetAttributeValue (attr, val, el, doc);
                   1218:      }
                   1219:    else
                   1220:      /* its not a number. Delete attribute and send an error message */
                   1221:      {
                   1222:        if (attr)
                   1223:          TtaRemoveAttribute (el, attr, doc);
1.37      cvs      1224:        if (strlen (buffer) > MaxMsgLength - 30)
1.30      cvs      1225:          buffer[MaxMsgLength - 30] = EOS;
1.37      cvs      1226:        sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
1.42      cvs      1227:        HTMLParseError (doc, msgBuffer);
1.30      cvs      1228:      }
                   1229: }
                   1230: /*----------------------------------------------------------------------
                   1231:    EndOfHTMLAttributeValue
                   1232:    Filling of an HTML attribute value
                   1233:   ----------------------------------------------------------------------*/
1.48      vatton   1234: void EndOfHTMLAttributeValue (char *attrValue,
                   1235:                              AttributeMapping *lastMappedAttr,
                   1236:                              Attribute currentAttribute,
                   1237:                              Element lastAttrElement,
                   1238:                              ThotBool UnknownAttr,
                   1239:                              ParserData *context,
                   1240:                              ThotBool isXML)
1.30      cvs      1241: {
1.48      vatton   1242:   AttributeType   attrType, attrType1;
                   1243:   Attribute       attr;
1.79      quint    1244:   ElementType    elType;
1.48      vatton   1245:   Element         child, root;
                   1246:   Language        lang;
                   1247:   char            translation;
                   1248:   char            shape;
                   1249:   char           *buffer;
                   1250:   char           *attrName;
                   1251:   char            msgBuffer[MaxMsgLength];
                   1252:   int             val;
                   1253:   int             length;
                   1254:   int             attrKind;
                   1255:   ThotBool        done = FALSE;
1.30      cvs      1256: 
1.48      vatton   1257:   /* treatments of some particular HTML attributes */
                   1258:   if (!strcmp (lastMappedAttr->XMLattribute, "style"))
                   1259:     {
                   1260:       TtaSetAttributeText (currentAttribute, attrValue,
                   1261:                           lastAttrElement, context->doc);
                   1262:       ParseHTMLSpecificStyle (context->lastElement, attrValue,
1.61      quint    1263:                              context->doc, 100, FALSE);
1.48      vatton   1264:       done = TRUE;
                   1265:     }
                   1266:   else
                   1267:     {
                   1268:       if (!strcmp (lastMappedAttr->XMLattribute, "link"))
                   1269:        HTMLSetAlinkColor (context->doc, attrValue);
                   1270:       else if (!strcmp (lastMappedAttr->XMLattribute, "alink"))
                   1271:        HTMLSetAactiveColor (context->doc, attrValue);
                   1272:       else if (!strcmp (lastMappedAttr->XMLattribute, "vlink"))
                   1273:        HTMLSetAvisitedColor (context->doc, attrValue);
                   1274:     }
1.30      cvs      1275: 
1.48      vatton   1276:   if (!done)
                   1277:     {
                   1278:       val = 0;
                   1279:       translation = lastMappedAttr->AttrOrContent;
                   1280:       switch (translation)
                   1281:        {
                   1282:        case 'C':       /* Content */
                   1283:          child = PutInContent (attrValue, context);
                   1284:          if (child != NULL)
                   1285:            TtaAppendTextContent (child, "\" ", context->doc);
                   1286:          break;
                   1287:          
                   1288:        case 'A':
                   1289:          if (currentAttribute != NULL)
                   1290:            {
                   1291:              TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
                   1292:              switch (attrKind)
                   1293:                {
                   1294:                case 0: /* enumerate */
                   1295:                  if (isXML)
                   1296:                    MapHTMLAttributeValue (attrValue, attrType, &val);
                   1297:                  else
                   1298:                    val = MapAttrValue (lastMappedAttr->ThotAttribute,
1.40      cvs      1299:                                        attrValue);
1.48      vatton   1300:                  if (val < 0)
                   1301:                    {
                   1302:                      TtaGiveAttributeType (currentAttribute,
                   1303:                                            &attrType, &attrKind);
                   1304:                      attrName = TtaGetAttributeName (attrType);
                   1305:                      sprintf (msgBuffer,
1.51      cvs      1306:                               "Invalid attribute value \"%s = %s\"",
1.48      vatton   1307:                               attrName, attrValue);
                   1308:                      if (isXML)
                   1309:                        XmlParseError (errorParsing, msgBuffer, 0);
                   1310:                      else
1.84      quint    1311:                        /* we are parsing an HTML file, not an XHTML file */
1.51      cvs      1312:                        {
1.84      quint    1313:                          /* generate an error message in the log */
1.51      cvs      1314:                          HTMLParseError (context->doc, msgBuffer);
1.84      quint    1315:                          /* special case for value POLYGON of attribute 
                   1316:                             shape (AREA element) */
                   1317:                          if (attrType.AttrTypeNum == HTML_ATTR_shape &&
                   1318:                              strcasecmp (attrValue, "POLYGON") == 0)
                   1319:                            {
                   1320:                              val = HTML_ATTR_shape_VAL_polygon;
                   1321:                              /* interpret it as if it were "poly" */
                   1322:                              TtaSetAttributeValue (currentAttribute, val,
                   1323:                                          lastAttrElement, context->doc);
                   1324:                            }
                   1325:                          else
                   1326:                            /* remove the attribute and replace it by an */
                   1327:                            /* Invalid_attribute (not for XHTML) */
                   1328:                            {
                   1329:                              TtaRemoveAttribute (lastAttrElement,
1.51      cvs      1330:                                              currentAttribute, context->doc);
1.84      quint    1331:                              attrType.AttrSSchema = 
                   1332:                                         TtaGetDocumentSSchema (context->doc);
                   1333:                              attrType.AttrTypeNum =
                   1334:                                       pHTMLAttributeMapping[0].ThotAttribute;
                   1335:                              sprintf (msgBuffer, "%s=%s", attrName,attrValue);
                   1336:                              CreateHTMLAttribute (lastAttrElement, attrType,
                   1337:                                         msgBuffer, TRUE, context->doc,
                   1338:                                         &currentAttribute, &lastAttrElement);
                   1339:                            }
1.48      vatton   1340:                        }
                   1341:                    }
                   1342:                  else
                   1343:                    TtaSetAttributeValue (currentAttribute, val,
                   1344:                                          lastAttrElement, context->doc);
                   1345:                  break;
                   1346:                case 1: /* integer */
                   1347:                  if (attrType.AttrTypeNum == HTML_ATTR_Border &&
                   1348:                      !strcasecmp (attrValue, "border"))
                   1349:                    {
                   1350:                      /* border="border" for a table */
                   1351:                      val = 1;
                   1352:                      TtaSetAttributeValue (currentAttribute, val,
1.30      cvs      1353:                                            lastAttrElement, context->doc);
1.48      vatton   1354:                    }
                   1355:                  else if (sscanf (attrValue, "%d", &val))
                   1356:                    TtaSetAttributeValue (currentAttribute, val,
                   1357:                                          lastAttrElement, context->doc);
                   1358:                  else
                   1359:                    {
                   1360:                      TtaRemoveAttribute (lastAttrElement, currentAttribute,
                   1361:                                          context->doc);
                   1362:                      sprintf (msgBuffer,
                   1363:                               "Unknown attribute value \"%s\"",
                   1364:                               attrValue);
                   1365:                      if (isXML)
                   1366:                        XmlParseError (errorParsing, msgBuffer, 0);
                   1367:                      else
                   1368:                        HTMLParseError (context->doc, msgBuffer);
                   1369:                    }
                   1370:                  break;
                   1371:                case 2: /* text */
                   1372:                  if (!UnknownAttr)
                   1373:                    {
                   1374:                      TtaSetAttributeText (currentAttribute, attrValue,
                   1375:                                           lastAttrElement, context->doc);
1.55      cvs      1376:                      if (attrType.AttrTypeNum == HTML_ATTR_Language)
1.48      vatton   1377:                        {
                   1378:                          /* it's a LANG attribute value */
                   1379:                          lang = TtaGetLanguageIdFromName (attrValue);
1.70      vatton   1380:                          if (lang < 0)
1.48      vatton   1381:                            {
                   1382:                              sprintf (msgBuffer,
                   1383:                                       "warning - unsupported language: %s",
                   1384:                                       attrValue);
                   1385:                              if (isXML)
                   1386:                                XmlParseError (errorParsing, msgBuffer, 0);
                   1387:                              else
                   1388:                                HTMLParseError (context->doc, msgBuffer);
                   1389:                            }
                   1390:                          else
                   1391:                            {
                   1392:                              /* change current language */
                   1393:                              context->language = lang;
                   1394:                              if (isXML)
                   1395:                                SetLanguagInXmlStack (lang);
                   1396:                              else
                   1397:                                SetLanguagInHTMLStack (lang);
                   1398:                            }
                   1399:                          root = TtaGetRootElement (context->doc);
                   1400:                          if (lastAttrElement == root)
                   1401:                            /* it's a LANG attribute on the root element */
                   1402:                            /* set the RealLang attribute */
                   1403:                            {
                   1404:                              attrType1.AttrSSchema = TtaGetDocumentSSchema (context->doc);
                   1405:                              attrType1.AttrTypeNum = HTML_ATTR_RealLang;
                   1406:                              /* this attribute could be already present,
                   1407:                                 (lang and xml:lang attributes) */
                   1408:                              if (!TtaGetAttribute (lastAttrElement,
                   1409:                                                    attrType1))
                   1410:                                /* it's not present. Add it */
                   1411:                                {
                   1412:                                  attr = TtaNewAttribute (attrType1);
                   1413:                                  TtaAttachAttribute (lastAttrElement,
                   1414:                                                      attr, context->doc);
                   1415:                                  TtaSetAttributeValue (attr,
                   1416:                                                        HTML_ATTR_RealLang_VAL_Yes_,
                   1417:                                                        lastAttrElement,
                   1418:                                                        context->doc);
                   1419:                                }
                   1420:                            }
                   1421:                        }
                   1422:                      else if (attrType.AttrTypeNum == HTML_ATTR_accesskey)
                   1423:                        TtaAddAccessKey (context->doc, (unsigned int)attrValue[0],
                   1424:                                         lastAttrElement);
                   1425:                    }
                   1426:                  else
                   1427:                    {
1.51      cvs      1428:                      /* this is the content of an invalid attribute */
                   1429:                      /* append it to the current Invalid_attribute */
                   1430:                      if (!isXML)
                   1431:                        {
                   1432:                          length = strlen (attrValue) + 2;
                   1433:                          length += TtaGetTextAttributeLength (currentAttribute);
                   1434:                          buffer = TtaGetMemory (length + 1);
                   1435:                          TtaGiveTextAttributeValue (currentAttribute,
                   1436:                                                     buffer, &length);
                   1437:                          strcat (buffer, "=");
                   1438:                          strcat (buffer, attrValue);
                   1439:                          TtaSetAttributeText (currentAttribute, buffer,
                   1440:                                               lastAttrElement, context->doc);
                   1441:                          TtaFreeMemory (buffer);
                   1442:                        }
1.48      vatton   1443:                    }
                   1444:                  break;
                   1445:                case 3: /* reference */
                   1446:                  break;
                   1447:                }
                   1448:            }
                   1449:          break;
                   1450:          
                   1451:        case SPACE:
                   1452:          if (isXML)
                   1453:            XhtmlTypeAttrValue (attrValue, currentAttribute,
1.30      cvs      1454:                                lastAttrElement, context);
1.48      vatton   1455:          else
                   1456:            HTMLTypeAttrValue (attrValue, currentAttribute,
                   1457:                               lastAttrElement, context);
                   1458:          break;
                   1459:          
1.30      cvs      1460:         default:
                   1461:           break;
1.48      vatton   1462:        }
1.30      cvs      1463: 
                   1464:       if (lastMappedAttr->ThotAttribute == HTML_ATTR_Width__)
1.79      quint    1465:        /* HTML attribute "width" */
                   1466:        {
                   1467:          /* if it's an Object element, wait until all attributes are handled,
                   1468:             especially the data attribute that may generate the image to
                   1469:             which the width has to be applied */
                   1470:          elType = TtaGetElementType (lastAttrElement);
                   1471:          if (elType.ElTypeNum != HTML_EL_Object)
                   1472:            /* create the corresponding attribute IntWidthPercent or */
                   1473:            /* IntWidthPxl */
                   1474:            CreateAttrWidthPercentPxl (attrValue, lastAttrElement,
                   1475:                                       context->doc, -1);
                   1476:        }
1.58      vatton   1477:       else if (lastMappedAttr->ThotAttribute == HTML_ATTR_Height_)
1.79      quint    1478:        /* HTML attribute "height" */
                   1479:        {
                   1480:          /* if it's an Object element, wait until all attributes are handled,
                   1481:             especially the data attribute that may generate the image to
                   1482:             which the height has to be applied */
                   1483:          elType = TtaGetElementType (lastAttrElement);
                   1484:          if (elType.ElTypeNum != HTML_EL_Object)
                   1485:            /* create the corresponding attribute IntHeightPercent or */
                   1486:            /* IntHeightPxl */
                   1487:            CreateAttrHeightPercentPxl (attrValue, lastAttrElement,
                   1488:                                        context->doc, -1);
                   1489:        }
1.48      vatton   1490:       else if (!strcmp (lastMappedAttr->XMLattribute, "size"))
                   1491:        {
                   1492:          TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
                   1493:          if (attrType.AttrTypeNum == HTML_ATTR_Font_size)
                   1494:            CreateAttrIntSize (attrValue, lastAttrElement, context->doc);
                   1495:        }
                   1496:       else if (!strcmp (lastMappedAttr->XMLattribute, "shape"))
                   1497:        {
                   1498:          child = TtaGetFirstChild (lastAttrElement);
                   1499:          if (child != NULL)
                   1500:            {
                   1501:              switch (val)
                   1502:                {
                   1503:                case HTML_ATTR_shape_VAL_rectangle:
                   1504:                  shape = 'R';
                   1505:                  break;
                   1506:                case HTML_ATTR_shape_VAL_circle:
                   1507:                  shape = 'a';
                   1508:                  break;
                   1509:                case HTML_ATTR_shape_VAL_polygon:
                   1510:                  shape = 'p';
                   1511:                  break;
                   1512:                default:
                   1513:                  shape = SPACE;
                   1514:                  break;
                   1515:                }
                   1516:              TtaSetGraphicsShape (child, shape, context->doc);
                   1517:            }
                   1518:        }
                   1519:       else if (!strcmp (lastMappedAttr->XMLattribute, "value"))
                   1520:        {
                   1521:          elType = TtaGetElementType (lastAttrElement);
                   1522:          if (elType.ElTypeNum == HTML_EL_Text_Input ||
                   1523:              elType.ElTypeNum == HTML_EL_Password_Input ||
                   1524:              elType.ElTypeNum == HTML_EL_File_Input ||
                   1525:              elType.ElTypeNum == HTML_EL_Input)
                   1526:            /* create a Default_Value attribute with the same content */
                   1527:            {
                   1528:              attrType1.AttrSSchema = attrType.AttrSSchema;
                   1529:              attrType1.AttrTypeNum = HTML_ATTR_Default_Value;
                   1530:              attr = TtaNewAttribute (attrType1);
                   1531:              TtaAttachAttribute (lastAttrElement, attr, context->doc);
                   1532:              TtaSetAttributeText (attr, attrValue,
                   1533:                                   lastAttrElement, context->doc);
                   1534:            }
                   1535:        }
1.30      cvs      1536:       else
1.48      vatton   1537:        {
                   1538:          /* Some HTML attributes are equivalent to a CSS property:      */
                   1539:          /*      background     ->                   background         */
                   1540:          /*      bgcolor        ->                   background         */
                   1541:          /*      text           ->                   color              */
                   1542:          /*      color          ->                   color              */
                   1543:          if (!strcmp (lastMappedAttr->XMLattribute, "background"))
                   1544:            {
                   1545:              if (strlen (attrValue) > MaxMsgLength - 30)
                   1546:                attrValue[MaxMsgLength - 30] = EOS;
1.76      vatton   1547:              HTMLSetBackgroundImage (context->doc, context->lastElement,
1.85      vatton   1548:                                      REPEAT, attrValue, FALSE);
1.48      vatton   1549:            }
                   1550:          else if (!strcmp (lastMappedAttr->XMLattribute, "bgcolor"))
1.76      vatton   1551:            HTMLSetBackgroundColor (context->doc, context->lastElement,
                   1552:                                    attrValue);
1.48      vatton   1553:          else if (!strcmp (lastMappedAttr->XMLattribute, "text") ||
                   1554:                   !strcmp (lastMappedAttr->XMLattribute, "color"))
                   1555:            HTMLSetForegroundColor (context->doc,
                   1556:                                    context->lastElement, attrValue);
                   1557:        }
                   1558:     }
1.30      cvs      1559: }
                   1560: 
                   1561: /*----------------------------------------------------------------------
1.16      cvs      1562:    MapHTMLAttributeValue
1.2       cvs      1563:    Search in the Attribute Value Mapping Table the entry for the attribute
1.66      vatton   1564:    ThotAtt and its value attVal. Returns the corresponding Thot value.
1.1       cvs      1565:   ----------------------------------------------------------------------*/
1.66      vatton   1566: void MapHTMLAttributeValue (char *attVal, AttributeType attrType, int *value)
1.1       cvs      1567: {
1.66      vatton   1568:   MapXMLAttributeValue (XHTML_TYPE, attVal, attrType, value);
1.1       cvs      1569: }

Webmaster