static void TextHnd(void *userData, const char *s, int len) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxString str = CharToString(ctx->conv, s, len); if (ctx->lastAsText) { ctx->lastAsText->SetContent(ctx->lastAsText->GetContent() + str); } else { bool whiteOnly = false; if (ctx->removeWhiteOnlyNodes) whiteOnly = wxIsWhiteOnly(str); if (!whiteOnly) { wxXmlNode *textnode = new wxXmlNode(wxXML_TEXT_NODE, wxT("text"), str); ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(textnode, ctx->lastChild); ctx->lastChild= ctx->lastAsText = textnode; } } }
static void StartElementHnd(void *userData, const char *name, const char **atts) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, CharToString(ctx->conv, name)); const char **a = atts; while (*a) { node->AddProperty(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1])); a += 2; } if (ctx->root == NULL) { ctx->root = node; } else { ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(node, ctx->lastChild); } ctx->lastAsText = NULL; ctx->lastChild = NULL; // our new node "node" has no children yet ctx->node = node; }
static void StartCdataHnd(void *userData) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxXmlNode *textnode = new wxXmlNode(wxXML_CDATA_SECTION_NODE, wxT("cdata"),wxT("")); ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(textnode, ctx->lastChild); ctx->lastChild= ctx->lastAsText = textnode; }
static void PIHnd(void *userData, const char *target, const char *data) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxXmlNode *pinode = new wxXmlNode(wxXML_PI_NODE, CharToString(ctx->conv, target), CharToString(ctx->conv, data), XML_GetCurrentLineNumber(ctx->parser)); ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(pinode, ctx->lastChild); ctx->lastChild = pinode; ctx->lastAsText = NULL; }
static void CommentHnd(void *userData, const char *data) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxXmlNode *commentnode = new wxXmlNode(wxXML_COMMENT_NODE, wxS("comment"), CharToString(ctx->conv, data), XML_GetCurrentLineNumber(ctx->parser)); ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(commentnode, ctx->lastChild); ctx->lastChild = commentnode; ctx->lastAsText = NULL; }
static void CommentHnd(void *userData, const char *data) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; if (ctx->node) { // VS: ctx->node == NULL happens if there is a comment before // the root element (e.g. wxDesigner's output). We ignore such // comments, no big deal... wxXmlNode *commentnode = new wxXmlNode(wxXML_COMMENT_NODE, wxT("comment"), CharToString(ctx->conv, data)); ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(commentnode, ctx->lastChild); ctx->lastChild = commentnode; } ctx->lastAsText = NULL; }
static void StartElementHnd(void *userData, const char *name, const char **atts) { wxXmlParsingContext *ctx = (wxXmlParsingContext*)userData; wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, CharToString(ctx->conv, name), wxEmptyString, XML_GetCurrentLineNumber(ctx->parser)); const char **a = atts; // add node attributes while (*a) { node->AddAttribute(CharToString(ctx->conv, a[0]), CharToString(ctx->conv, a[1])); a += 2; } ASSERT_LAST_CHILD_OK(ctx); ctx->node->InsertChildAfter(node, ctx->lastChild); ctx->lastAsText = NULL; ctx->lastChild = NULL; // our new node "node" has no children yet ctx->node = node; }