Diff for /Amaya/amaya/XHTMLbuilder.c between versions 1.108 and 1.109

version 1.108, 2004/04/07 11:10:19 version 1.109, 2004/05/03 15:32:23
Line 70  void ParseCharsetAndContentType (Element Line 70  void ParseCharsetAndContentType (Element
 {  {
    AttributeType attrType;     AttributeType attrType;
    Attribute     attr;     Attribute     attr;
    SSchema       docSSchema;     ElementType   elType;
    CHARSET       charset;     CHARSET       charset;
    char         *text, *text2, *ptrText, *str;     char         *text, *text2, *ptrText, *str;
    char          charsetname[MAX_LENGTH];     char          charsetname[MAX_LENGTH];
Line 82  void ParseCharsetAndContentType (Element Line 82  void ParseCharsetAndContentType (Element
        DocumentMeta[doc] && DocumentMeta[doc]->content_type)         DocumentMeta[doc] && DocumentMeta[doc]->content_type)
      return;       return;
   
    docSSchema = TtaGetDocumentSSchema (doc);     elType = TtaGetElementType (el);
    attrType.AttrSSchema = docSSchema;     attrType.AttrSSchema = elType.ElSSchema;
    attrType.AttrTypeNum = HTML_ATTR_http_equiv;     attrType.AttrTypeNum = HTML_ATTR_http_equiv;
    attr = TtaGetAttribute (el, attrType);     attr = TtaGetAttribute (el, attrType);
    if (attr != NULL)     if (attr != NULL)
Line 152  void ParseCharsetAndContentType (Element Line 152  void ParseCharsetAndContentType (Element
    XhtmlCannotContainText      XhtmlCannotContainText 
    Return TRUE if element el is a block element.     Return TRUE if element el is a block element.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 ThotBool      XhtmlCannotContainText (ElementType elType)  ThotBool XhtmlCannotContainText (ElementType elType)
   
 {  {
    int        i;     int        i;
Line 191  void XhtmlElementComplete (ParserData *c Line 191  void XhtmlElementComplete (ParserData *c
    char           lastChar[2];     char           lastChar[2];
    char           *name1, *data;     char           *name1, *data;
    int            length;     int            length;
    SSchema        docSSchema;     SSchema        htmlSchema;
    ThotBool       isImage, isInline;     ThotBool       isImage, isInline;
   
    *error = 0;     *error = 0;
    doc = context->doc;     doc = context->doc;
    docSSchema = TtaGetDocumentSSchema (doc);  
   
    elType = TtaGetElementType (el);     elType = TtaGetElementType (el);
      htmlSchema = elType.ElSSchema;
    isInline = IsXMLElementInline (elType, doc);     isInline = IsXMLElementInline (elType, doc);
    newElType.ElSSchema = elType.ElSSchema;     newElType.ElSSchema = elType.ElSSchema;
   
Line 515  void XhtmlElementComplete (ParserData *c Line 515  void XhtmlElementComplete (ParserData *c
                /* create the Frames element if it does not exist */                 /* create the Frames element if it does not exist */
                if (elFrames == NULL)                 if (elFrames == NULL)
                  {                   {
                    newElType.ElSSchema = docSSchema;                     newElType.ElSSchema = htmlSchema;
                    newElType.ElTypeNum = HTML_EL_Frames;                     newElType.ElTypeNum = HTML_EL_Frames;
                    elFrames = TtaNewElement (doc, newElType);                     elFrames = TtaNewElement (doc, newElType);
                    if (DocumentMeta[doc]->xmlformat)                     if (DocumentMeta[doc]->xmlformat)
Line 670  void XhtmlElementComplete (ParserData *c Line 670  void XhtmlElementComplete (ParserData *c
        else         else
          {           {
            /* save the text into Default_Value attribute */             /* save the text into Default_Value attribute */
            attrType.AttrSSchema = docSSchema;             attrType.AttrSSchema = htmlSchema;
            attrType.AttrTypeNum = HTML_ATTR_Default_Value;             attrType.AttrTypeNum = HTML_ATTR_Default_Value;
            if (TtaGetAttribute (el, attrType) == NULL)             if (TtaGetAttribute (el, attrType) == NULL)
              /* attribute Default_Value is missing */               /* attribute Default_Value is missing */
Line 697  void XhtmlElementComplete (ParserData *c Line 697  void XhtmlElementComplete (ParserData *c
      case HTML_EL_Radio_Input:       case HTML_EL_Radio_Input:
      case HTML_EL_Checkbox_Input:       case HTML_EL_Checkbox_Input:
        /* put an attribute Checked if it is missing */         /* put an attribute Checked if it is missing */
        attrType.AttrSSchema = docSSchema;         attrType.AttrSSchema = htmlSchema;
        attrType.AttrTypeNum = HTML_ATTR_Checked;         attrType.AttrTypeNum = HTML_ATTR_Checked;
        if (TtaGetAttribute (el, attrType) == NULL)         if (TtaGetAttribute (el, attrType) == NULL)
          /* attribute Checked is missing */           /* attribute Checked is missing */
Line 717  void XhtmlElementComplete (ParserData *c Line 717  void XhtmlElementComplete (ParserData *c
        break;         break;
                 
      case HTML_EL_LINK:       case HTML_EL_LINK:
        CheckCSSLink (el, doc, docSSchema);         CheckCSSLink (el, doc, htmlSchema);
        break;         break;
                 
      case HTML_EL_Data_cell:       case HTML_EL_Data_cell:
Line 925  void CreateHTMLAttribute (Element Line 925  void CreateHTMLAttribute (Element
    Value val has been read for the HTML attribute TYPE.     Value val has been read for the HTML attribute TYPE.
    Create a child for the current Thot element INPUT accordingly.     Create a child for the current Thot element INPUT accordingly.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void               HTMLTypeAttrValue (char       *val,  void HTMLTypeAttrValue (char *val, Attribute lastAttribute,
                                       Attribute   lastAttribute,                          Element lastAttrElement, ParserData *context)
                                       Element     lastAttrElement,  
                                       ParserData *context)  
   
 {  {
   ElementType      elType;    ElementType      elType;
   Element          newChild;    Element          newChild;
Line 940  void               HTMLTypeAttrValue (ch Line 937  void               HTMLTypeAttrValue (ch
   int              numberOfLinesRead;    int              numberOfLinesRead;
   
   value = MapAttrValue (DummyAttribute, val);    value = MapAttrValue (DummyAttribute, val);
     elType = TtaGetElementType (context->lastElement);
   if (value <= 0)    if (value <= 0)
     {      {
       if (strlen (val) > MaxMsgLength - 40)        if (strlen (val) > MaxMsgLength - 40)
          val[MaxMsgLength - 40] = EOS;           val[MaxMsgLength - 40] = EOS;
       sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val);        sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val);
       HTMLParseError (context->doc, msgBuffer);        HTMLParseError (context->doc, msgBuffer);
       attrType.AttrSSchema = TtaGetDocumentSSchema (context->doc);        attrType.AttrSSchema = elType.ElSSchema;
       attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute;        attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute;
       sprintf (msgBuffer, "type=%s", val);        sprintf (msgBuffer, "type=%s", val);
       CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,        CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
Line 954  void               HTMLTypeAttrValue (ch Line 952  void               HTMLTypeAttrValue (ch
     }      }
   else    else
     {      {
       elType = TtaGetElementType (context->lastElement);  
       if (elType.ElTypeNum != HTML_EL_Input)        if (elType.ElTypeNum != HTML_EL_Input)
         {          {
           if (strlen (val) > MaxMsgLength - 40)            if (strlen (val) > MaxMsgLength - 40)
Line 963  void               HTMLTypeAttrValue (ch Line 960  void               HTMLTypeAttrValue (ch
         }          }
       else        else
         {          {
           elType.ElSSchema = TtaGetDocumentSSchema (context->doc);  
           elType.ElTypeNum = value;            elType.ElTypeNum = value;
           newChild = TtaNewTree (context->doc, elType, "");            newChild = TtaNewTree (context->doc, elType, "");
           numberOfLinesRead = 0;            numberOfLinesRead = 0;
Line 1084  void CreateAttrWidthPercentPxl (char *bu Line 1080  void CreateAttrWidthPercentPxl (char *bu
   length = strlen (buffer) - 1;    length = strlen (buffer) - 1;
   while (length > 0 && buffer[length] <= SPACE)    while (length > 0 && buffer[length] <= SPACE)
     length--;      length--;
   attrTypePxl.AttrSSchema = TtaGetDocumentSSchema (doc);    attrTypePxl.AttrSSchema = elType.ElSSchema;
   attrTypePercent.AttrSSchema = TtaGetDocumentSSchema (doc);    attrTypePercent.AttrSSchema = elType.ElSSchema;
   attrTypePxl.AttrTypeNum = HTML_ATTR_IntWidthPxl;    attrTypePxl.AttrTypeNum = HTML_ATTR_IntWidthPxl;
   attrTypePercent.AttrTypeNum = HTML_ATTR_IntWidthPercent;    attrTypePercent.AttrTypeNum = HTML_ATTR_IntWidthPercent;
   /* is the last character a '%' ? */    /* is the last character a '%' ? */
Line 1192  void CreateAttrHeightPercentPxl (char *b Line 1188  void CreateAttrHeightPercentPxl (char *b
   length = strlen (buffer) - 1;    length = strlen (buffer) - 1;
   while (length > 0 && buffer[length] <= SPACE)    while (length > 0 && buffer[length] <= SPACE)
     length--;      length--;
   attrTypePxl.AttrSSchema = TtaGetDocumentSSchema (doc);    attrTypePxl.AttrSSchema = elType.ElSSchema;
   attrTypePercent.AttrSSchema = TtaGetDocumentSSchema (doc);    attrTypePercent.AttrSSchema = elType.ElSSchema;
   attrTypePxl.AttrTypeNum = HTML_ATTR_IntHeightPxl;    attrTypePxl.AttrTypeNum = HTML_ATTR_IntHeightPxl;
   attrTypePercent.AttrTypeNum = HTML_ATTR_IntHeightPercent;    attrTypePercent.AttrTypeNum = HTML_ATTR_IntHeightPercent;
   /* is the last character a '%' ? */    /* is the last character a '%' ? */
Line 1284  void CreateAttrIntAreaSize (int value, E Line 1280  void CreateAttrIntAreaSize (int value, E
    an HTML attribute "size" has been created for a Font element.     an HTML attribute "size" has been created for a Font element.
    Create the corresponding internal attribute.     Create the corresponding internal attribute.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void              CreateAttrIntSize (char *buffer, Element el, Document doc)  void CreateAttrIntSize (char *buffer, Element el, Document doc)
   
 {  {
      ElementType    elType;
    AttributeType  attrType;     AttributeType  attrType;
    int            val, ind, factor, delta;     int            val, ind, factor, delta;
    Attribute      attr;     Attribute      attr;
    char         msgBuffer[MaxMsgLength];     char         msgBuffer[MaxMsgLength];
   
    /* is the first character a '+' or a '-' ? */     /* is the first character a '+' or a '-' ? */
      elType = TtaGetElementType (el);
    ind = 0;     ind = 0;
    factor = 1;     factor = 1;
    delta = 0;     delta = 0;
Line 1313  void              CreateAttrIntSize (cha Line 1311  void              CreateAttrIntSize (cha
        attrType.AttrTypeNum = HTML_ATTR_IntSizeRel;         attrType.AttrTypeNum = HTML_ATTR_IntSizeRel;
        delta = 1;         delta = 1;
      }       }
    attrType.AttrSSchema = TtaGetDocumentSSchema (doc);     attrType.AttrSSchema = elType.ElSSchema;
    attr = TtaGetAttribute (el, attrType);     attr = TtaGetAttribute (el, attrType);
    if (sscanf (&buffer[ind], "%d", &val))     if (sscanf (&buffer[ind], "%d", &val))
      {       {
Line 1341  void              CreateAttrIntSize (cha Line 1339  void              CreateAttrIntSize (cha
    EndOfHTMLAttributeValue     EndOfHTMLAttributeValue
    Filling of an HTML attribute value     Filling of an HTML attribute value
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void EndOfHTMLAttributeValue (char *attrValue,  void EndOfHTMLAttributeValue (char *attrValue, AttributeMapping *lastMappedAttr,
                               AttributeMapping *lastMappedAttr,                                Attribute currentAttribute, Element lastAttrElement,
                               Attribute currentAttribute,                                ThotBool UnknownAttr, ParserData *context,
                               Element lastAttrElement,  
                               ThotBool UnknownAttr,  
                               ParserData *context,  
                               ThotBool isXML)                                ThotBool isXML)
 {  {
   AttributeType   attrType, attrType1;    AttributeType   attrType, attrType1;
Line 1389  void EndOfHTMLAttributeValue (char *attr Line 1384  void EndOfHTMLAttributeValue (char *attr
   
   if (!done)    if (!done)
     {      {
         elType = TtaGetElementType (lastAttrElement);
       val = 0;        val = 0;
       translation = lastMappedAttr->AttrOrContent;        translation = lastMappedAttr->AttrOrContent;
       switch (translation)        switch (translation)
Line 1398  void EndOfHTMLAttributeValue (char *attr Line 1394  void EndOfHTMLAttributeValue (char *attr
           if (child != NULL)            if (child != NULL)
             TtaAppendTextContent (child, (unsigned char *)"\" ", context->doc);              TtaAppendTextContent (child, (unsigned char *)"\" ", context->doc);
           break;            break;
             
         case 'A':          case 'A':
           if (currentAttribute != NULL)            if (currentAttribute != NULL)
             {              {
Line 1442  void EndOfHTMLAttributeValue (char *attr Line 1437  void EndOfHTMLAttributeValue (char *attr
                             {                              {
                               TtaRemoveAttribute (lastAttrElement,                                TtaRemoveAttribute (lastAttrElement,
                                               currentAttribute, context->doc);                                                currentAttribute, context->doc);
                               attrType.AttrSSchema =                                 attrType.AttrSSchema = elType.ElSSchema;
                                          TtaGetDocumentSSchema (context->doc);  
                               attrType.AttrTypeNum =                                attrType.AttrTypeNum =
                                        pHTMLAttributeMapping[0].ThotAttribute;                                         pHTMLAttributeMapping[0].ThotAttribute;
                               sprintf (msgBuffer, "%s=%s", attrName,attrValue);                                sprintf (msgBuffer, "%s=%s", attrName,attrValue);
Line 1515  void EndOfHTMLAttributeValue (char *attr Line 1509  void EndOfHTMLAttributeValue (char *attr
                             /* it's a LANG attribute on the root element */                              /* it's a LANG attribute on the root element */
                             /* set the RealLang attribute */                              /* set the RealLang attribute */
                             {                              {
                               attrType1.AttrSSchema = TtaGetDocumentSSchema (context->doc);                                attrType1.AttrSSchema = elType.ElSSchema;
                               attrType1.AttrTypeNum = HTML_ATTR_RealLang;                                attrType1.AttrTypeNum = HTML_ATTR_RealLang;
                               /* this attribute could be already present,                                /* this attribute could be already present,
                                  (lang and xml:lang attributes) */                                   (lang and xml:lang attributes) */
Line 1561  void EndOfHTMLAttributeValue (char *attr Line 1555  void EndOfHTMLAttributeValue (char *attr
                 }                  }
             }              }
           break;            break;
             
         case SPACE:          case SPACE:
           if (isXML)            if (isXML)
             XhtmlTypeAttrValue (attrValue, currentAttribute,              XhtmlTypeAttrValue (attrValue, currentAttribute,
Line 1569  void EndOfHTMLAttributeValue (char *attr Line 1562  void EndOfHTMLAttributeValue (char *attr
           else            else
             HTMLTypeAttrValue (attrValue, currentAttribute,              HTMLTypeAttrValue (attrValue, currentAttribute,
                                lastAttrElement, context);                                 lastAttrElement, context);
           break;            break;  
             
          default:           default:
            break;             break;
         }          }
Line 1581  void EndOfHTMLAttributeValue (char *attr Line 1573  void EndOfHTMLAttributeValue (char *attr
           /* if it's an Object element, wait until all attributes are handled,            /* if it's an Object element, wait until all attributes are handled,
              especially the data attribute that may generate the image to               especially the data attribute that may generate the image to
              which the width has to be applied */               which the width has to be applied */
           elType = TtaGetElementType (lastAttrElement);  
           if (elType.ElTypeNum != HTML_EL_Object)            if (elType.ElTypeNum != HTML_EL_Object)
             /* create the corresponding attribute IntWidthPercent or */              /* create the corresponding attribute IntWidthPercent or */
             /* IntWidthPxl */              /* IntWidthPxl */
Line 1594  void EndOfHTMLAttributeValue (char *attr Line 1585  void EndOfHTMLAttributeValue (char *attr
           /* if it's an Object element, wait until all attributes are handled,            /* if it's an Object element, wait until all attributes are handled,
              especially the data attribute that may generate the image to               especially the data attribute that may generate the image to
              which the height has to be applied */               which the height has to be applied */
           elType = TtaGetElementType (lastAttrElement);  
           if (elType.ElTypeNum != HTML_EL_Object)            if (elType.ElTypeNum != HTML_EL_Object)
             /* create the corresponding attribute IntHeightPercent or */              /* create the corresponding attribute IntHeightPercent or */
             /* IntHeightPxl */              /* IntHeightPxl */
Line 1635  void EndOfHTMLAttributeValue (char *attr Line 1625  void EndOfHTMLAttributeValue (char *attr
         }          }
       else if (!strcmp (lastMappedAttr->XMLattribute, "value"))        else if (!strcmp (lastMappedAttr->XMLattribute, "value"))
         {          {
           elType = TtaGetElementType (lastAttrElement);  
           if (elType.ElTypeNum == HTML_EL_Text_Input ||            if (elType.ElTypeNum == HTML_EL_Text_Input ||
               elType.ElTypeNum == HTML_EL_Password_Input ||                elType.ElTypeNum == HTML_EL_Password_Input ||
               elType.ElTypeNum == HTML_EL_File_Input ||                elType.ElTypeNum == HTML_EL_File_Input ||

Removed from v.1.108  
changed lines
  Added in v.1.109


Webmaster