Diff for /Amaya/amaya/styleparser.c between versions 1.118 and 1.119

version 1.118, 2002/03/06 12:28:21 version 1.119, 2002/03/07 15:03:34
Line 3907  static char *ParseGenericSelector (char Line 3907  static char *ParseGenericSelector (char
 {  {
   ElementType        elType;    ElementType        elType;
   PSchema            tsch;    PSchema            tsch;
   /*AttributeType    attrType;*/    AttributeType      attrType;
   char               sel[MAX_ANCESTORS * 50];    char               sel[MAX_ANCESTORS * 50];
   char              *deb, *cur, c;    char              *deb, *cur, c;
   char              *schemaName, *mappedName;    char              *schemaName, *mappedName;
Line 3917  static char *ParseGenericSelector (char Line 3917  static char *ParseGenericSelector (char
   char              *pseudoclasses[MAX_ANCESTORS];    char              *pseudoclasses[MAX_ANCESTORS];
   char              *attrs[MAX_ANCESTORS];    char              *attrs[MAX_ANCESTORS];
   char              *attrvals[MAX_ANCESTORS];    char              *attrvals[MAX_ANCESTORS];
   char              *ptr;  
   int                i, j, k, max;    int                i, j, k, max;
   int                att, maxAttr;    int                att, maxAttr;
   int                specificity, xmlType;    int                specificity, xmlType;
Line 4096  static char *ParseGenericSelector (char Line 4095  static char *ParseGenericSelector (char
                   /* there is a value */                    /* there is a value */
                   if (*selector == '"')                    if (*selector == '"')
                     {                      {
                       *selector++;                        selector++;
                       *cur++ = EOS;                        *cur++ = EOS;
                       attrvals[0] = deb;                        attrvals[0] = deb;
                     }                      }
Line 4148  static char *ParseGenericSelector (char Line 4147  static char *ParseGenericSelector (char
   j = 0;    j = 0;
   maxAttr = 0;    maxAttr = 0;
   /* default schema name */    /* default schema name */
   ptr = "HTML";    ctxt->schema = NULL;
     elType.ElSSchema = TtaGetDocumentSSchema (doc);
     schemaName = TtaGetSSchemaName(elType.ElSSchema);
     if (!strcmp (schemaName, "HTML"))
       xmlType = XHTML_TYPE;
     else if (!strcmp (schemaName, "MathML"))
       xmlType = MATH_TYPE;
     else if (!strcmp (schemaName, "SVG"))
       xmlType = SVG_TYPE;
     else if (!strcmp (schemaName, "XLink"))
       xmlType = XLINK_TYPE;
     else if (!strcmp (schemaName, "Annot"))
       xmlType = ANNOT_TYPE;
     else
       xmlType = XML_TYPE;
   while (i <= max)    while (i <= max)
     {      {
       if (names[i])        if (names[i])
         {          {
           /* get the element type of this name in the current document */            /* get the element type of this name in the current document */
           elType.ElSSchema = TtaGetDocumentSSchema (doc);  
           schemaName = TtaGetSSchemaName(elType.ElSSchema);  
           if (!strcmp (schemaName, "HTML"))  
             xmlType = XHTML_TYPE;  
           else if (!strcmp (schemaName, "MathML"))  
             xmlType = MATH_TYPE;  
           else if (!strcmp (schemaName, "SVG"))  
             xmlType = SVG_TYPE;  
           else if (!strcmp (schemaName, "MathML"))  
             xmlType = XLINK_TYPE;  
           else  
             xmlType = XML_TYPE;  
           MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c, &level, doc);            MapXMLElementType (xmlType, names[i], &elType, &mappedName, &c, &level, doc);
           if (i == 0)            if (i == 0)
             {              {
               if (elType.ElSSchema == NULL)                if (elType.ElSSchema == NULL)
                 {                  {
                   /* Search in the list of loaded genereric schemas */                    /* Search in the list of loaded schemas */
                   TtaGetXmlElementType (names[i], &elType, NULL, doc);                    TtaGetXmlElementType (names[i], &elType, NULL, doc);
                     if (elType.ElSSchema)
                       {
                         /* the element type concerns an imprted nature */
                         schemaName = TtaGetSSchemaName(elType.ElSSchema);
                         if (!strcmp (schemaName, "HTML"))
                           xmlType = XHTML_TYPE;
                         else if (!strcmp (schemaName, "MathML"))
                           xmlType = MATH_TYPE;
                         else if (!strcmp (schemaName, "SVG"))
                           xmlType = SVG_TYPE;
                         else if (!strcmp (schemaName, "XLink"))
                           xmlType = XLINK_TYPE;
                         else if (!strcmp (schemaName, "Annot"))
                           xmlType = ANNOT_TYPE;
                         else
                           xmlType = XML_TYPE;
                       }
 #ifdef XML_GENERIC  #ifdef XML_GENERIC
                   if (elType.ElSSchema == NULL &&                    else if (xmlType == XML_TYPE)
                       strcmp (schemaName, "HTML") &&  
                       strcmp (schemaName, "MathML") &&  
                       strcmp (schemaName, "SVG") &&  
                       strcmp (schemaName, "XLink") &&  
                       strcmp (schemaName, "Annot"))  
                     {                      {
                       /* Creation of a new element type in the main schema */                        /* Creation of a new element type in the main schema */
                       elType.ElSSchema = TtaGetDocumentSSchema (doc);                        elType.ElSSchema = TtaGetDocumentSSchema (doc);
Line 4187  static char *ParseGenericSelector (char Line 4200  static char *ParseGenericSelector (char
                     }                      }
 #endif /* XML_GENERIC */  #endif /* XML_GENERIC */
                 }                  }
   
               if (elType.ElSSchema == NULL)                if (elType.ElSSchema == NULL)
                 /* cannot apply these CSS rules */                  /* cannot apply these CSS rules */
                 DoApply = FALSE;                  DoApply = FALSE;
Line 4197  static char *ParseGenericSelector (char Line 4211  static char *ParseGenericSelector (char
                   ctxt->name[0] = elType.ElTypeNum;                    ctxt->name[0] = elType.ElTypeNum;
                   ctxt->names_nb[0] = 0;                    ctxt->names_nb[0] = 0;
                   ctxt->schema = elType.ElSSchema;                    ctxt->schema = elType.ElSSchema;
                   ptr = TtaGetSSchemaName (elType.ElSSchema);  
                 }                  }
             }              }
           else if (elType.ElTypeNum != 0)            else if (elType.ElTypeNum != 0)
Line 4231  static char *ParseGenericSelector (char Line 4244  static char *ParseGenericSelector (char
       if (classes[i])        if (classes[i])
         {          {
           ctxt->attrText[j] = classes[i];            ctxt->attrText[j] = classes[i];
           if (!strcmp (ptr, "SVG"))            if (xmlType == SVG_TYPE)
             ctxt->attrType[j] = SVG_ATTR_class;              ctxt->attrType[j] = SVG_ATTR_class;
           else if (!strcmp (ptr, "MathML"))            else if (xmlType == MATH_TYPE)
             ctxt->attrType[j] = MathML_ATTR_class;              ctxt->attrType[j] = MathML_ATTR_class;
 #ifdef XML_GENERIC            else if (xmlType == XHTML_TYPE)
           else if (!strcmp (ptr, "HTML"))  
             ctxt->attrType[j] = HTML_ATTR_Class;              ctxt->attrType[j] = HTML_ATTR_Class;
           else            else
   #ifdef XML_GENERIC
             ctxt->attrType[j] = XML_ATTR_class;              ctxt->attrType[j] = XML_ATTR_class;
 #else /* XML_GENERIC */  #else /* XML_GENERIC */
           else  
             ctxt->attrType[j] = HTML_ATTR_Class;              ctxt->attrType[j] = HTML_ATTR_Class;
 #endif /* XML_GENERIC */  #endif /* XML_GENERIC */
           /* add a new entry */            /* add a new entry */
Line 4250  static char *ParseGenericSelector (char Line 4262  static char *ParseGenericSelector (char
       if (pseudoclasses[i])        if (pseudoclasses[i])
         {          {
           ctxt->attrText[j] = pseudoclasses[i];            ctxt->attrText[j] = pseudoclasses[i];
           if (!strcmp (ptr, "SVG"))            if (xmlType == SVG_TYPE)
             ctxt->attrType[j] = SVG_ATTR_PseudoClass;              ctxt->attrType[j] = SVG_ATTR_PseudoClass;
           else if (!strcmp (ptr, "MathML"))            else if (xmlType == MATH_TYPE)
             ctxt->attrType[j] = MathML_ATTR_PseudoClass;              ctxt->attrType[j] = MathML_ATTR_PseudoClass;
 #ifdef XML_GENERIC            else if (xmlType == XHTML_TYPE)
           else if (!strcmp (ptr, "HTML"))  
             ctxt->attrType[j] = HTML_ATTR_PseudoClass;              ctxt->attrType[j] = HTML_ATTR_PseudoClass;
           else            else
   #ifdef XML_GENERIC
             ctxt->attrType[j] = XML_ATTR_PseudoClass;              ctxt->attrType[j] = XML_ATTR_PseudoClass;
 #else /* XML_GENERIC */  #else /* XML_GENERIC */
           else  
             ctxt->attrType[j] = HTML_ATTR_PseudoClass;              ctxt->attrType[j] = HTML_ATTR_PseudoClass;
 #endif /* XML_GENERIC */  #endif /* XML_GENERIC */
           /* add a new entry */            /* add a new entry */
Line 4269  static char *ParseGenericSelector (char Line 4280  static char *ParseGenericSelector (char
       if (ids[i])        if (ids[i])
         {          {
           ctxt->attrText[j] = ids[i];            ctxt->attrText[j] = ids[i];
           if (!strcmp (ptr, "SVG"))            if (xmlType == SVG_TYPE)
             ctxt->attrType[j] = SVG_ATTR_id;              ctxt->attrType[j] = SVG_ATTR_id;
           else if (!strcmp (ptr, "MathML"))            else if (xmlType == MATH_TYPE)
             ctxt->attrType[j] = MathML_ATTR_id;              ctxt->attrType[j] = MathML_ATTR_id;
 #ifdef XML_GENERIC            else if (xmlType == XHTML_TYPE)
           else if (!strcmp (ptr, "HTML"))  
             ctxt->attrType[j] = HTML_ATTR_ID;              ctxt->attrType[j] = HTML_ATTR_ID;
           else            else
   #ifdef XML_GENERIC
             ctxt->attrType[j] = XML_ATTR_id;              ctxt->attrType[j] = XML_ATTR_id;
 #else /* XML_GENERIC */  #else /* XML_GENERIC */
           else  
             ctxt->attrType[j] = HTML_ATTR_ID;              ctxt->attrType[j] = HTML_ATTR_ID;
 #endif /* XML_GENERIC */  #endif /* XML_GENERIC */
           /* add a new entry */            /* add a new entry */
Line 4287  static char *ParseGenericSelector (char Line 4297  static char *ParseGenericSelector (char
         }          }
       if (attrs[i])        if (attrs[i])
         {          {
           if (!strcmp (ptr, "SVG"))            MapXMLAttribute (xmlType, attrs[i], names[i], &level, doc, &att);
             MapXMLAttribute (SVG_TYPE, attrs[i], names[i], &level, doc, &att);  
           else if (!strcmp (ptr, "MathML"))  
             MapXMLAttribute (MATH_TYPE, attrs[i], names[i], &level, doc, &att);  
           else  
             MapXMLAttribute (XHTML_TYPE, attrs[i], names[i], &level, doc, &att);  
           ctxt->attrText[j] = attrvals[i];  
           /* we should pass also the attribute schema in the context */  
           ctxt->attrType[j] = att;            ctxt->attrType[j] = att;
             if (i == 0 && att == 0 && ctxt->schema == NULL)
               {
                 /* Search in the list of loaded schemas */
                 attrType.AttrSSchema = NULL;
                 TtaGetXmlAttributeType (attrs[i], &attrType, doc);
                 ctxt->attrType[j] = attrType.AttrTypeNum;
                 if (attrType.AttrSSchema)
                   /* the element type concerns an imprted nature */
                   schemaName = TtaGetSSchemaName(elType.ElSSchema);
   #ifdef XML_GENERIC
                 else if (xmlType == XML_TYPE)
                   {
                     /* The attribute is not yet present in the tree */
                     /* Create a new global attribute */
                     attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
                     TtaAppendXmlAttribute (attrs[i], &attrType, doc);
                   }
   #endif /* XML_GENERIC */
   
                 if (attrType.AttrSSchema == NULL)
                   /* cannot apply these CSS rules */
                   DoApply = FALSE;
                 else
                   ctxt->schema = elType.ElSSchema;
               }
             ctxt->attrText[j] = attrvals[i];
             /* todo: store the attribute schema in the context */
           maxAttr = i + 1;            maxAttr = i + 1;
         }          }
       i++;        i++;
       /* add a new entry */        /* add a new entry */
       k++;        k++;
         if (i == 1 && ctxt->schema == NULL)
           /* use the document schema */
           ctxt->schema = TtaGetDocumentSSchema (doc);
     }      }
   /* set the selector specificity */    /* set the selector specificity */
   ctxt->cssSpecificity = specificity;    ctxt->cssSpecificity = specificity;
Line 4329  static char *ParseGenericSelector (char Line 4362  static char *ParseGenericSelector (char
     }      }
   
   /* Get the schema name of the main element */    /* Get the schema name of the main element */
   if (ctxt->schema != NULL)    schemaName = TtaGetSSchemaName (ctxt->schema);
     {    isHTML = (strcmp (schemaName, "HTML") == 0);
       schemaName = TtaGetSSchemaName (ctxt->schema);    tsch = GetPExtension (doc, ctxt->schema, css);
       isHTML = (strcmp (schemaName, "HTML") == 0);    if (tsch && cssRule)
       tsch = GetPExtension (doc, ctxt->schema, css);      ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);
       if (tsch && cssRule)  
         ParseCSSRule (NULL, tsch, (PresentationContext) ctxt, cssRule, css, isHTML);  
     }  
   /* future CSS rules should apply */    /* future CSS rules should apply */
   DoApply = TRUE;    DoApply = TRUE;
   return (selector);    return (selector);

Removed from v.1.118  
changed lines
  Added in v.1.119


Webmaster