Beispiel #1
0
Datei: xmlrole.c Projekt: 119/vdc
static int PTRCALL
prolog1(PROLOG_STATE *state,
        int tok,
        const char *ptr,
        const char *end,
        const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_PI:
    return XML_ROLE_PI;
  case XML_TOK_COMMENT:
    return XML_ROLE_COMMENT;
  case XML_TOK_BOM:
    return XML_ROLE_NONE;
  case XML_TOK_DECL_OPEN:
    if (!XmlNameMatchesAscii(enc,
                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
                             end,
                             KW_DOCTYPE))
      break;
    state->handler = doctype0;
    return XML_ROLE_DOCTYPE_NONE;
  case XML_TOK_INSTANCE_START:
    state->handler = error;
    return XML_ROLE_INSTANCE_START;
  }
  return common(state, tok);
}
Beispiel #2
0
static
int prolog0(PROLOG_STATE *state,
		int tok,
		const char *ptr,
		const char *end,
		const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
	state->handler = prolog1;
	return XML_ROLE_NONE;
  case XML_TOK_XML_DECL:
	state->handler = prolog1;
	return XML_ROLE_XML_DECL;
  case XML_TOK_PI:
	state->handler = prolog1;
	return XML_ROLE_NONE;
  case XML_TOK_COMMENT:
	state->handler = prolog1;
  case XML_TOK_BOM:
	return XML_ROLE_NONE;
  case XML_TOK_DECL_OPEN:
	if (!XmlNameMatchesAscii(enc,
				 ptr + 2 * MIN_BYTES_PER_CHAR(enc),
				 "DOCTYPE"))
	  break;
	state->handler = doctype0;
	return XML_ROLE_NONE;
  case XML_TOK_INSTANCE_START:
	state->handler = error;
	return XML_ROLE_INSTANCE_START;
  }
  return syntaxError(state);
}
Beispiel #3
0
static
int internalSubset(PROLOG_STATE *state,
		   int tok,
		   const char *ptr,
		   const char *end,
		   const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
	return XML_ROLE_NONE;
  case XML_TOK_DECL_OPEN:
	if (XmlNameMatchesAscii(enc,
				ptr + 2 * MIN_BYTES_PER_CHAR(enc),
				"ENTITY")) {
	  state->handler = entity0;
	  return XML_ROLE_NONE;
	}
	if (XmlNameMatchesAscii(enc,
				ptr + 2 * MIN_BYTES_PER_CHAR(enc),
				"ATTLIST")) {
	  state->handler = attlist0;
	  return XML_ROLE_NONE;
	}
	if (XmlNameMatchesAscii(enc,
				ptr + 2 * MIN_BYTES_PER_CHAR(enc),
				"ELEMENT")) {
	  state->handler = element0;
	  return XML_ROLE_NONE;
	}
	if (XmlNameMatchesAscii(enc,
				ptr + 2 * MIN_BYTES_PER_CHAR(enc),
				"NOTATION")) {
	  state->handler = notation0;
	  return XML_ROLE_NONE;
	}
	break;
  case XML_TOK_PI:
  case XML_TOK_COMMENT:
	return XML_ROLE_NONE;
  case XML_TOK_PARAM_ENTITY_REF:
	return XML_ROLE_PARAM_ENTITY_REF;
  case XML_TOK_CLOSE_BRACKET:
	state->handler = doctype5;
	return XML_ROLE_NONE;
  }
  return syntaxError(state);
}
Beispiel #4
0
static
int attlist2(PROLOG_STATE *state,
             int tok,
             const char *ptr,
             const char *end,
             const ENCODING *enc)
{
  cmExpatUnused(ptr);
  cmExpatUnused(end);
  cmExpatUnused(enc);
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_NAME:
    {
      static const char *types[] = {
        KW_CDATA,
        KW_ID,
        KW_IDREF,
        KW_IDREFS,
        KW_ENTITY,
        KW_ENTITIES,
        KW_NMTOKEN,
        KW_NMTOKENS,
      };
      int i;
      for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
        if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
          state->handler = attlist8;
          return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
        }
    }
    if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
      state->handler = attlist5;
      return XML_ROLE_NONE;
    }
    break;
  case XML_TOK_OPEN_PAREN:
    state->handler = attlist3;
    return XML_ROLE_NONE;
  }
  return common(state, tok);
}
Beispiel #5
0
/* default value */
static
int attlist8(PROLOG_STATE *state,
             int tok,
             const char *ptr,
             const char *end,
             const ENCODING *enc)
{
  cmExpatUnused(ptr);
  cmExpatUnused(end);
  cmExpatUnused(enc);
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_POUND_NAME:
    if (XmlNameMatchesAscii(enc,
                            ptr + MIN_BYTES_PER_CHAR(enc),
                            end,
                            KW_IMPLIED)) {
      state->handler = attlist1;
      return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
    }
    if (XmlNameMatchesAscii(enc,
                            ptr + MIN_BYTES_PER_CHAR(enc),
                            end,
                            KW_REQUIRED)) {
      state->handler = attlist1;
      return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
    }
    if (XmlNameMatchesAscii(enc,
                            ptr + MIN_BYTES_PER_CHAR(enc),
                            end,
                            KW_FIXED)) {
      state->handler = attlist9;
      return XML_ROLE_NONE;
    }
    break;
  case XML_TOK_LITERAL:
    state->handler = attlist1;
    return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
  }
  return common(state, tok);
}
Beispiel #6
0
static
int attlist2(PROLOG_STATE *state,
	     int tok,
	     const char *ptr,
	     const char *end,
	     const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_NAME:
    {
      static const char *types[] = {
	"CDATA",
        "ID",
        "IDREF",
        "IDREFS",
        "ENTITY",
        "ENTITIES",
        "NMTOKEN",
        "NMTOKENS",
      };
      int i;
      for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
	if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
	  state->handler = attlist8;
	  return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
	}
    }
    if (XmlNameMatchesAscii(enc, ptr, end, "NOTATION")) {
      state->handler = attlist5;
      return XML_ROLE_NONE;
    }
    break;
  case XML_TOK_OPEN_PAREN:
    state->handler = attlist3;
    return XML_ROLE_NONE;
  }
  return common(state, tok);
}
Beispiel #7
0
static int PTRCALL
notation1(PROLOG_STATE *state,
          int tok,
          const char *ptr,
          const char *end,
          const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NOTATION_NONE;
  case XML_TOK_NAME:
    if (XmlNameMatchesAscii(enc, ptr, end, KW_SYSTEM)) {
      state->handler = notation3;
      return XML_ROLE_NOTATION_NONE;
    }
    if (XmlNameMatchesAscii(enc, ptr, end, KW_PUBLIC)) {
      state->handler = notation2;
      return XML_ROLE_NOTATION_NONE;
    }
    break;
  }
  return common(state, tok);
}
Beispiel #8
0
static int PTRCALL
condSect0(PROLOG_STATE *state,
          int tok,
          const char *ptr,
          const char *end,
          const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_NAME:
    if (XmlNameMatchesAscii(enc, ptr, end, KW_INCLUDE)) {
      state->handler = condSect1;
      return XML_ROLE_NONE;
    }
    if (XmlNameMatchesAscii(enc, ptr, end, KW_IGNORE)) {
      state->handler = condSect2;
      return XML_ROLE_NONE;
    }
    break;
  }
  return common(state, tok);
}
Beispiel #9
0
static
int notation1(PROLOG_STATE *state,
		  int tok,
		  const char *ptr,
		  const char *end,
		  const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
	return XML_ROLE_NONE;
  case XML_TOK_NAME:
	if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
	  state->handler = notation3;
	  return XML_ROLE_NONE;
	}
	if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
	  state->handler = notation2;
	  return XML_ROLE_NONE;
	}
	break;
  }
  return syntaxError(state);
}
Beispiel #10
0
/* default value */
static
int attlist8(PROLOG_STATE *state,
		 int tok,
		 const char *ptr,
		 const char *end,
		 const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
	return XML_ROLE_NONE;
  case XML_TOK_POUND_NAME:
	if (XmlNameMatchesAscii(enc,
				ptr + MIN_BYTES_PER_CHAR(enc),
				"IMPLIED")) {
	  state->handler = attlist1;
	  return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
	}
	if (XmlNameMatchesAscii(enc,
				ptr + MIN_BYTES_PER_CHAR(enc),
				"REQUIRED")) {
	  state->handler = attlist1;
	  return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
	}
	if (XmlNameMatchesAscii(enc,
				ptr + MIN_BYTES_PER_CHAR(enc),
				"FIXED")) {
	  state->handler = attlist9;
	  return XML_ROLE_NONE;
	}
	break;
  case XML_TOK_LITERAL:
	state->handler = attlist1;
	return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
  }
  return syntaxError(state);
}
Beispiel #11
0
static
int element2(PROLOG_STATE *state,
             int tok,
             const char *ptr,
             const char *end,
             const ENCODING *enc)
{
  cmExpatUnused(ptr);
  cmExpatUnused(end);
  cmExpatUnused(enc);
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_POUND_NAME:
    if (XmlNameMatchesAscii(enc,
                            ptr + MIN_BYTES_PER_CHAR(enc),
                            end,
                            KW_PCDATA)) {
      state->handler = element3;
      return XML_ROLE_CONTENT_PCDATA;
    }
    break;
  case XML_TOK_OPEN_PAREN:
    state->level = 2;
    state->handler = element6;
    return XML_ROLE_GROUP_OPEN;
  case XML_TOK_NAME:
  case XML_TOK_PREFIXED_NAME:
    state->handler = element7;
    return XML_ROLE_CONTENT_ELEMENT;
  case XML_TOK_NAME_QUESTION:
    state->handler = element7;
    return XML_ROLE_CONTENT_ELEMENT_OPT;
  case XML_TOK_NAME_ASTERISK:
    state->handler = element7;
    return XML_ROLE_CONTENT_ELEMENT_REP;
  case XML_TOK_NAME_PLUS:
    state->handler = element7;
    return XML_ROLE_CONTENT_ELEMENT_PLUS;
  }
  return common(state, tok);
}
Beispiel #12
0
static int PTRCALL
entity5(PROLOG_STATE *state,
        int tok,
        const char *ptr,
        const char *end,
        const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_ENTITY_NONE;
  case XML_TOK_DECL_CLOSE:
    setTopLevel(state);
    return XML_ROLE_ENTITY_COMPLETE;
  case XML_TOK_NAME:
    if (XmlNameMatchesAscii(enc, ptr, end, KW_NDATA)) {
      state->handler = entity6;
      return XML_ROLE_ENTITY_NONE;
    }
    break;
  }
  return common(state, tok);
}
Beispiel #13
0
static
int entity5(PROLOG_STATE *state,
		int tok,
		const char *ptr,
		const char *end,
		const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
	return XML_ROLE_NONE;
  case XML_TOK_DECL_CLOSE:
	state->handler = internalSubset;
	return XML_ROLE_NONE;
  case XML_TOK_NAME:
	if (XmlNameMatchesAscii(enc, ptr, "NDATA")) {
	  state->handler = entity6;
	  return XML_ROLE_NONE;
	}
	break;
  }
  return syntaxError(state);
}
Beispiel #14
0
static int PTRCALL
prolog1(PROLOG_STATE *state,
        int tok,
        const char *ptr,
        const char *end,
        const ENCODING *enc)
{
  switch (tok) {
  case XML_TOK_PROLOG_S:
    return XML_ROLE_NONE;
  case XML_TOK_PI:
    return XML_ROLE_PI;
  case XML_TOK_COMMENT:
    return XML_ROLE_COMMENT;
  case XML_TOK_BOM:
    /* This case can never arise.  To reach this role function, the
     * parse must have passed through prolog0 and therefore have had
     * some form of input, even if only a space.  At that point, a
     * byte order mark is no longer a valid character (though
     * technically it should be interpreted as a non-breaking space),
     * so will be rejected by the tokenizing stages.
     */
    return XML_ROLE_NONE; /* LCOV_EXCL_LINE */
  case XML_TOK_DECL_OPEN:
    if (!XmlNameMatchesAscii(enc,
                             ptr + 2 * MIN_BYTES_PER_CHAR(enc),
                             end,
                             KW_DOCTYPE))
      break;
    state->handler = doctype0;
    return XML_ROLE_DOCTYPE_NONE;
  case XML_TOK_INSTANCE_START:
    state->handler = error;
    return XML_ROLE_INSTANCE_START;
  }
  return common(state, tok);
}