static void startElement1_(ValueContext *ctx, xmlChar *name, xmlChar **atts) { xmlChar *vname, *p, *q; p = NextName(ctx); q = p; if ((vname = GetAttribute(atts, (xmlChar *)"name")) != NULL) { if ((char *)p != ctx->longname) { *p++ = '.'; } sprintf((char *)p, "%s", (char *)vname); } #ifdef DEBUG printf("startElement_(%s)[%s]\n", (char *)name, ctx->longname); #endif if (stricmp((char *)name, "lm:item") == 0) { ctx->value = GetItemLongName(ctx->root, ctx->longname); *q = 0; ctx->fStart = TRUE; } else if (stricmp((char *)name, "lm:record") == 0) { if (ctx->value == NULL) { *q = 0; } ctx->value = GetItemLongName(ctx->root, ctx->longname); ctx->fStart = FALSE; } else if (stricmp((char *)name, "lm:array") == 0) { *q = 0; ctx->fStart = FALSE; } else if (stricmp((char *)name, "lm:block") == 0) { ctx->value = NULL; ctx->fStart = FALSE; } }
static struct gl_list_t *RealFindInstancesPath(CONST struct Instance *i, CONST struct Name *n, enum find_errors *errval) { struct gl_list_t *result,*next; PAN *p; result = gl_create(NAMELISTSIZE); p = CreatePAN(i,NULL); /* in context of i, i has no name. */ gl_append_ptr(result,(VOIDPTR)p); while(n!=NULL){ next = FindNextNameElementPath(n,result,errval); DestroyPANList(&result); if (next!=NULL){ result = next; n = NextName(n); } else { return NULL; } } return result; }
bool FarXMLScanner::ParseAttribute (FarXMLNode *node) { FarString attrName = NextName(); if (attrName.IsEmpty()) return false; SkipWhitespace(); if (!NextExpectedChar ('=')) return false; SkipWhitespace(); char valueDelimiter = NextChar(); if (valueDelimiter != '\'' && valueDelimiter != '\"') { ReportError ("\" or \'"); return false; } FarString attrValue; while (1) { char c = NextChar(); if (c == valueDelimiter) break; else if (c == '&') { int entityValue = ParseEntity(); if (entityValue == -1) return false; attrValue += (char) entityValue; } else attrValue += c; } node->AddAttr (attrName, attrValue); return true; }
static void startElement2_(ValueContext *ctx, xmlChar *name, xmlChar **atts) { xmlChar *vname, *rname, *p, *q, *type; xmlChar buff[SIZE_LONGNAME + 1]; int count; Bool fArray; strcpy((char *)buff, (char *)name); if ((p = (xmlChar *)strchr((char *)buff, ':')) != NULL) { *p = 0; rname = buff; vname = p + 1; } else { rname = (xmlChar *)""; vname = buff; } if ((p = (xmlChar *)strchr((char *)vname, ':')) != NULL) { *p = 0; count = atoi((char *)p + 1); fArray = TRUE; } else { fArray = FALSE; count = 0; } p = NextName(ctx); q = p; if ((char *)p != ctx->longname) { *p++ = '.'; } if (fArray) { sprintf((char *)p, "%s[%d]", (char *)vname, count); } else { sprintf((char *)p, "%s", (char *)vname); } #ifdef DEBUG printf("startElement_(%s)[%s]\n", (char *)name, ctx->longname); #endif if (stricmp((char *)rname, ctx->opt->recname) == 0) { if (stricmp((char *)vname, "data") == 0) { *ctx->longname = 0; ctx->value = NULL; ctx->fStart = FALSE; } else { type = GetAttribute(atts, (xmlChar *)"type"); if (stricmp((char *)type, "record") == 0) { if (ctx->value == NULL) { *q = 0; } ctx->value = GetItemLongName(ctx->root, ctx->longname); ctx->fStart = FALSE; } else if (stricmp((char *)type, "array") == 0) { *q = 0; ctx->fStart = FALSE; } else { ctx->value = GetItemLongName(ctx->root, ctx->longname); ctx->fStart = TRUE; } } } else { *q = 0; ctx->fStart = FALSE; } }
FarXMLNode *FarXMLScanner::ParseChildNode() { SkipWhitespace(); int tagStartLine = fCurLine; int tagStartCol = GetCurColumn(); if (!NextExpectedChar ('<')) return NULL; FarString tagName = NextName(); if (tagName.IsEmpty()) return NULL; FarXMLNode *theNode = new FarXMLNode(); theNode->SetTag (tagName); theNode->SetStartPosition (tagStartLine, tagStartCol); while (1) { SkipWhitespace(); char c = PeekNextChar(); if (c == '/') { NextChar(); if (!NextExpectedChar ('>')) { delete theNode; return NULL; } break; } else if (c == '>') { NextChar(); SkipWhitespace(); while (1) { if (PeekNextChar() == '<' && PeekNextChar (1) == '/') break; FarXMLNode *nextChild = ParseChildNode(); if (!nextChild) { delete theNode; return NULL; } theNode->AddChild (nextChild); SkipWhitespace(); } NextChar(); // < NextChar(); // / FarString closeTagName = NextName(); if (closeTagName != tagName) { ReportError (tagName); delete theNode; return NULL; } SkipWhitespace(); if (!NextExpectedChar ('>')) { delete theNode; return NULL; } break; } else { if (!ParseAttribute (theNode)) { delete theNode; return NULL; } } } theNode->SetEndPosition (fCurLine, GetCurColumn()); SkipWhitespace(); return theNode; }