void BEXMLTextReader::move_to_element() { int return_code = xmlTextReaderMoveToElement ( reader ); if ( return_code == kBE_XMLReaderError ) { throw BEXMLReaderInterface_Exception ( last_error() ); } }
bool XMLReader::processNode() { if (m_reader == NULL) { std::cout << "error" << std::endl ; } if (xmlTextReaderRead(m_reader) != 1) { return false ; } m_attributes.clear() ; if (xmlTextReaderHasAttributes(m_reader) == 1) { int count = xmlTextReaderAttributeCount(m_reader) ; for (int i = 0 ; i < count ; i++) { xmlTextReaderMoveToAttributeNo(m_reader, i) ; m_attributes.insert( std::pair<std::string, std::string>( (char*) xmlTextReaderConstLocalName( m_reader), (char*) xmlTextReaderConstValue( m_reader))) ; } xmlTextReaderMoveToElement(m_reader) ; } // std::cout << print() << std::endl ; return true ; }
gboolean xml_reader_move_to_element (XmlReader *reader) { g_return_val_if_fail (XML_IS_READER (reader), FALSE); return (xmlTextReaderMoveToElement (reader->xml) == 1); }
gboolean xml_reader_read_to_next_sibling (XmlReader *reader) { g_return_val_if_fail (XML_IS_READER (reader), FALSE); xmlTextReaderMoveToElement (reader->xml); return (xmlTextReaderNextSibling (reader->xml) == 1); }
bool next() { int res; if(first) { res = xmlTextReaderMoveToFirstAttribute(reader); } else { res = xmlTextReaderMoveToNextAttribute(reader); } if(res < 0) throw std::runtime_error("parse error."); if(res == 0) { last = true; xmlTextReaderMoveToElement(reader); return false; } first = false; return true; }
/* * call-seq: * reader.move_to_element -> code * * Move the position of the current instance to the node that contains the * current attribute node. */ static VALUE rxml_reader_move_to_element(VALUE self) { return INT2FIX(xmlTextReaderMoveToElement(rxml_text_reader_get(self))); }
~AttributeIterator() { if(!last) xmlTextReaderMoveToElement(reader); }
/* * call-seq: * reader.move_to_element -> code * * Move the position of the current instance to the node that contains the * current attribute node. */ static VALUE rxml_reader_move_to_element(VALUE self) { xmlTextReaderPtr xreader = rxml_text_reader_get(self); return INT2FIX(xmlTextReaderMoveToElement(xreader)); }
/* reader:move_to_element() */ static int xmlreader_move_to_element(lua_State *L) { xmlreader xr = check_xmlreader(L, 1); int ret = xmlTextReaderMoveToElement(xr); BOOL_OR_ERROR(L, ret); }
/******************************************************************** * FUNCTION get_all_attrs * * Copy all the attributes from the current node to * the xml_attrs_t queue * * INPUTS: * scb == session control block * errnode == element node to use for reporting errors * msghdr == msg hdr w/ Q to get any rpc-errors as found, * NULL if not used * nserr == TRUE if unknown namespace should cause the * function to fail and the attr not to be saved * This is the normal mode. * == FALSE and the namespace will be marked INVALID * but an error will not be returned * * OUTPUTS: * attrs Q contains 0 or more entries * *msghdr.errQ may have rpc-errors added to it * * RETURNS: * status of the operation * returns NO_ERR if all copied okay or even zero copied *********************************************************************/ static status_t get_all_attrs (ses_cb_t *scb, xml_node_t *errnode, xml_attrs_t *attrs, ncx_layer_t layer, xml_msg_hdr_t *msghdr, boolean nserr) { /* check the attribute count first */ int cnt = xmlTextReaderAttributeCount(scb->reader); if (cnt==0) { return NO_ERR; } const xmlChar *name = NULL; status_t res = NO_ERR; boolean xpatherror = FALSE; int ret = 0; /* move through the list of attributes */ int i = 0; boolean done = FALSE; for (; i < cnt && !done; i++) { xmlChar *value = NULL; const xmlChar *badns = NULL; uint32 plen = 0; xmlns_id_t nsid = 0; res = NO_ERR; name = NULL; /* get the next attribute */ if (i==0) { ret = xmlTextReaderMoveToFirstAttribute(scb->reader); } else { ret = xmlTextReaderMoveToNextAttribute(scb->reader); } if (ret != 1) { res = ERR_XML_READER_INTERNAL; done = TRUE; } else { /* get the attribute name */ name = xmlTextReaderConstName(scb->reader); if (!name) { res = ERR_XML_READER_NULLNAME; } else { res = xml_check_ns(scb->reader, name, &nsid, &plen, &badns); if (!nserr && res != NO_ERR) { /* mask invalid namespace as requested */ nsid = xmlns_inv_id(); plen = 0; res = NO_ERR; } /* get the attribute value even if a NS error */ value = xmlTextReaderValue(scb->reader); if (!value) { res = ERR_XML_READER_NULLVAL; } else { /* save the values as received, may be QName * only error that can occur is a malloc fail */ xml_attr_t *attr = xml_add_qattr(attrs, nsid, name, plen, value, &res); if (!attr) { res = ERR_INTERNAL_MEM; } else { /* special hack: do not know which * attributes within an XML node * are tagged as XPath strings at this point * To save resources, only the 'select' and * 'key' attributes are supported at this time. */ if (!xml_strcmp(&name[plen], NCX_EL_SELECT)) { res = NO_ERR; attr->attr_xpcb = agt_new_xpath_pcb(scb, value, &res); if (!attr->attr_xpcb) { ; /* res already set */ } else { /* do a first pass parsing to resolve all * the prefixes and check well-formed XPath */ xpath_result_t *result = xpath1_eval_xmlexpr(scb->reader, attr->attr_xpcb, NULL, NULL, FALSE, FALSE, &res); if (res != NO_ERR) { xpatherror = TRUE; } xpath_free_result(result); } } else if (!xml_strcmp(&name[plen], NCX_EL_KEY)) { res = NO_ERR; attr->attr_xpcb = agt_new_xpath_pcb(scb, value, &res); if (!attr->attr_xpcb) { ; /* res already set */ } else { res = xpath_yang_validate_xmlkey (scb->reader, attr->attr_xpcb, NULL, FALSE); if (res != NO_ERR) { xpatherror = TRUE; } } } } } } } /* check the result */ if (res != NO_ERR && msghdr) { /* need a dummy attribute struct to report this error */ xml_attr_t errattr; memset(&errattr, 0x0, sizeof(xml_attr_t)); errattr.attr_ns = xmlns_nc_id(); errattr.attr_qname = name; errattr.attr_name = name; errattr.attr_val = value; /* save the error info */ if (xpatherror) { res = ERR_NCX_INVALID_XPATH_EXPR; /* generate an invalid-value error */ agt_record_attr_error(scb, msghdr, layer, res, &errattr, errnode, NULL, NCX_NT_NONE, NULL); } else if (res==ERR_XML_READER_NULLVAL || res==ERR_NCX_UNKNOWN_NAMESPACE) { /* generate a bad namespace error */ agt_record_attr_error(scb, msghdr, layer, res, &errattr, errnode, badns, NCX_NT_NONE, NULL); } else { /* generate a generic error */ agt_record_attr_error(scb, msghdr, layer, res, &errattr, errnode, NULL, NCX_NT_NONE, NULL); } } if (value) { xmlFree(value); } } /* reset the current node to where we started */ ret = xmlTextReaderMoveToElement(scb->reader); if (ret != 1) { if (msghdr) { res = ERR_XML_READER_INTERNAL; agt_record_error(scb, msghdr, layer, res, errnode, NCX_NT_STRING, name, NCX_NT_NONE, NULL); } } return res; } /* get_all_attrs */
bool XmlTextReader::MoveToElement() const { return XmlCheck(xmlTextReaderMoveToElement(ToReader(m_p))); }
/* @method Boolean XmlReader.moveToElement() */ METHOD XmlReader_moveToElement(Ctx *ctx, knh_sfp_t *sfp) { xmlTextReaderPtr reader = (xmlTextReaderPtr) p_cptr(sfp[0]); int ret = xmlTextReaderMoveToElement(reader); KNH_RETURN_Boolean(ctx,sfp,ret); }
//## @Native boolean XmlReader.moveToElement(); static KMETHOD XmlReader_moveToElement(KonohaContext *kctx, KonohaStack *sfp) { xmlTextReaderPtr reader = getRawXmlReader(sfp[0]); int ret = (reader != NULL) ? xmlTextReaderMoveToElement(reader) : 0; KReturnUnboxValue(ret); }