void endElement ( void *data, const xmlChar *fullname ) { // CHECK FOR TAGS if ( xmlStrEqual(fullname,forTag) == 1) { depth--; if ( DETAILS ) { std::cout << "----------------------------\n\nLoop " << loopCount << "\n\n"; fLoop->printArrayRefs(); } if ( depth == 0 ) { if ( fLoop->GCDTest() ) { if ( DETAILS ) { std::cout << "CANNOT be in parallel.\n\n"; } exit(1); } else { if ( DETAILS ) { std::cout << "CAN be in parallel.\n\n"; } } } delete fLoop; fLoop = new ForLoop; } else if ( xmlStrEqual(fullname,initTag) == 1 ) withinInit = false; else if ( xmlStrEqual(fullname,typeTag) == 1 ) withinType = false; else if ( xmlStrEqual(fullname,nameTag) == 1 ) withinName = false; // HAVE TO HAVE MORE BOOLEANS FOR THIS else if ( xmlStrEqual(fullname,exprTag) == 1 ) withinExpr = false; else if ( xmlStrEqual(fullname,exprStmtTag) == 1 ) withinExprStmt = false; else if ( xmlStrEqual(fullname,condTag) == 1 ) withinCond = false; else if ( xmlStrEqual(fullname,incrTag) == 1 ) { withinIncr = false; withinBlock = true; } else if ( xmlStrEqual(fullname,indexTag) == 1 ) withinIndex = false; }
template<typename I> static void pa_xmlNamedPreorderTraversal ( xmlNode *root, xmlChar *tagURI, xmlChar *tagName, void callback(xmlNode& node, I info), I info) { for(xmlNode *iter=root->children; iter; iter = iter->next) { if(iter->type == XML_ELEMENT_NODE && (xmlStrEqual(iter->name, tagName) || xmlStrEqual(tagName, (const xmlChar*)"*"))) { if(tagURI != NULL && (xmlStrEqual(pa_xmlGetNsURI(iter), tagURI) || xmlStrEqual(tagURI, (const xmlChar*)"*"))) callback(*iter, info); else if(tagURI == NULL) callback(*iter, info); } pa_xmlNamedPreorderTraversal(iter, tagURI, tagName, callback, info); } return; }
gate* winFlowJoWorkspace::getGate(wsPopNode & node){ xmlXPathObjectPtr resGate=node.xpathInNode("Gate/*"); wsNode gNode(resGate->nodesetval->nodeTab[0]); xmlXPathFreeObject(resGate); const xmlChar * gateType=gNode.getNodePtr()->name; if(xmlStrEqual(gateType,(const xmlChar *)"PolygonGate")) { wsPolyGateNode pGNode(gNode.getNodePtr()); if(g_loglevel>=GATE_LEVEL) COUT<<"parsing PolygonGate.."<<endl; return(getGate(pGNode)); } else if(xmlStrEqual(gateType,(const xmlChar *)"RectangleGate")) { wsRectGateNode rGNode(gNode.getNodePtr()); if(g_loglevel>=GATE_LEVEL) COUT<<"parsing RectangleGate.."<<endl; return(getGate(rGNode)); } else if(xmlStrEqual(gateType,(const xmlChar *)"EllipsoidGate")) { wsEllipseGateNode eGNode(gNode.getNodePtr()); if(g_loglevel>=GATE_LEVEL) COUT<<"parsing EllipsoidGate.."<<endl; return(getGate(eGNode)); } else { // COUT<<"gate type: "<<gateType<<" is not supported!"<<endl; throw(domain_error("invalid gate type!")); } }
static int xsltTestCompMatchCount(xsltTransformContextPtr context, xmlNodePtr node, xsltCompMatchPtr countPat, xmlNodePtr cur) { if (countPat != NULL) { return xsltTestCompMatchList(context, node, countPat); } else { /* * 7.7 Numbering * * If count attribute is not specified, then it defaults to the * pattern that matches any node with the same node type as the * current node and, if the current node has an expanded-name, with * the same expanded-name as the current node. */ if (node->type != cur->type) return 0; if (node->type == XML_NAMESPACE_DECL) /* * Namespace nodes have no preceding siblings and no parents * that are namespace nodes. This means that node == cur. */ return 1; /* TODO: Skip node types without expanded names like text nodes. */ if (!xmlStrEqual(node->name, cur->name)) return 0; if (node->ns == cur->ns) return 1; if ((node->ns == NULL) || (cur->ns == NULL)) return 0; return (xmlStrEqual(node->ns->href, cur->ns->href)); } }
int xmlStrQEqual(const xmlChar *pref, const xmlChar *name, const xmlChar *str) { if (pref == NULL) return(xmlStrEqual(name, str)); if (name == NULL) return(0); if (str == NULL) return(0); do { if (*pref++ != *str) return(0); } while ((*str++) && (*pref)); if (*str++ != ':') return(0); do { if (*name++ != *str) return(0); } while (*str++); return(1); }
bool Importer::parseLibraryCameras( const Asset& asset_parent, xmlNodePtr lib_cameras_node ) { Logger log = getLogger( "Scene.XML.parseLibraryCameras" ); if( !assertNode( lib_cameras_node, "library_cameras" ) ) { return false; } xmlNodePtr n = lib_cameras_node->children; if( n!=NULL && xmlStrEqual( n->name, BAD_CAST "asset" ) ) { Asset asset; if( parseAsset( asset, n ) ) { m_database.library<Camera>().setAsset( asset ); } else { SCENELOG_ERROR( log, "Failed to parse <asset>" ); return false; } n = n->next; } else { m_database.library<Camera>().setAsset( asset_parent ); } while( n!= NULL && xmlStrEqual( n->name, BAD_CAST "camera" ) ) { if( !parseCamera( m_database.library<Camera>().asset(), n ) ) { SCENELOG_ERROR( log, "Failed to parse <camera>" ); return false; } n = n->next; } ignoreExtraNodes( log, n ); nagAboutRemainingNodes( log, n ); return true; }
int xsltFindElemSpaceHandling(xsltTransformContextPtr ctxt, xmlNodePtr node) { xsltStylesheetPtr style; const xmlChar *val; if ((ctxt == NULL) || (node == NULL)) return(0); style = ctxt->style; while (style != NULL) { if (node->ns != NULL) { val = (const xmlChar *) xmlHashLookup2(style->stripSpaces, node->name, node->ns->href); if (val == NULL) { val = (const xmlChar *) xmlHashLookup2(style->stripSpaces, BAD_CAST "*", node->ns->href); } } else { val = (const xmlChar *) xmlHashLookup2(style->stripSpaces, node->name, NULL); } if (val != NULL) { if (xmlStrEqual(val, (xmlChar *) "strip")) return(1); if (xmlStrEqual(val, (xmlChar *) "preserve")) return(0); } if (style->stripAll == 1) return(1); if (style->stripAll == -1) return(0); style = xsltNextImport(style); } return(0); }
static xmlAttrPtr XDR_A_maxOccurs(xmlAttrPtr xdr_attr, xmlNodePtr node) { xmlChar* str = get_attr_val(xdr_attr); xmlAttrPtr attr; TRACE("(%p, %p)\n", xdr_attr, node); if (xmlStrEqual(str, BAD_CAST "*")) attr = xmlSetProp(node, xs_maxOccurs, xs_unbounded); else attr = copy_prop_ignore_ns(xdr_attr, node); xmlFree(str); return attr; }
/* returns TRUE is successfull */ gboolean gtodo_client_category_edit(GTodoClient *cl, gchar *old, gchar *newn) { if(cl == NULL || old == NULL || newn == NULL) return FALSE; if(gtodo_client_category_exists(cl, newn) && !gtodo_client_category_exists(cl, old)) return FALSE; else { xmlNodePtr cur = cl->root->xmlChildrenNode; while(cur != NULL){ if(xmlStrEqual(cur->name, (xmlChar *)"category")){ xmlChar *temp = xmlGetProp(cur, (const xmlChar *)"title"); if(xmlStrEqual(temp, (const xmlChar *)old)) { xmlSetProp(cur, (xmlChar *)"title", (xmlChar *)newn); cur = NULL; } else cur = cur->next; xmlFree(temp); } else cur = cur->next; } } gtodo_client_save_xml(cl,NULL); return TRUE; }
static inline xmlNsPtr get_dt_ns(xmlNodePtr node) { xmlNsPtr ns; node = get_schema(node); assert(node != NULL); FOREACH_NS(node, ns) { if (xmlStrEqual(ns->href, DT_href)) break; } return ns; }
static void plugin_read_config (Control *ctrl, xmlNodePtr node) { xmlChar *value; gui *plugin = ctrl->data; for (node = node->children; node; node = node->next) { if (xmlStrEqual(node->name, (const xmlChar *)"Windowlist")) { if ((value = xmlGetProp(node, (const xmlChar *)"includeAll"))) { plugin->includeAll = atoi(value); g_free(value); } break; } } }
/* * Public API */ Local::Heap::Heap (boost::shared_ptr<Ekiga::PresenceCore> _presence_core, boost::shared_ptr<Local::Cluster> _local_cluster): presence_core(_presence_core), local_cluster(_local_cluster), doc () { xmlNodePtr root; contacts_settings = boost::shared_ptr<Ekiga::Settings> (new Ekiga::Settings (CONTACTS_SCHEMA)); std::string raw = contacts_settings->get_string (ROSTER_KEY); // Build the XML document representing the contacts list from the configuration if (!raw.empty ()) { doc = boost::shared_ptr<xmlDoc> (xmlRecoverMemory (raw.c_str (), raw.length ()), xmlFreeDoc); if ( !doc) doc = boost::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlDocGetRootElement (doc.get ()); if (root == NULL) { root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); } for (xmlNodePtr child = root->children; child != NULL; child = child->next) if (child->type == XML_ELEMENT_NODE && child->name != NULL && xmlStrEqual (BAD_CAST ("entry"), child->name)) add (child); // Or create a new XML document } else { doc = boost::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); { // add 500, 501 and 520 at ekiga.net in this case! std::set<std::string> groups; groups.insert (_("Services")); add (_("Echo test"), "sip:[email protected]", groups); add (_("Conference room"), "sip:[email protected]", groups); add (_("Call back test"), "sip:[email protected]", groups); } } }
/** * xmlHashAddEntry3: * @table: the hash table * @name: the name of the userdata * @name2: a second name of the userdata * @name3: a third name of the userdata * @userdata: a pointer to the userdata * * Add the @userdata to the hash @table. This can later be retrieved * by using the tuple (@name, @name2, @name3). Duplicate entries generate * errors. * * Returns 0 the addition succeeded and -1 in case of error. */ int xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, void *userdata) { unsigned long key, len = 0; xmlHashEntryPtr entry; xmlHashEntryPtr insert; if ((table == NULL) || name == NULL) return(-1); /* * Check for duplicate and insertion location. */ key = xmlHashComputeKey(table, name, name2, name3); if (table->table[key] == NULL) { insert = NULL; } else { for (insert = table->table[key]; insert->next != NULL; insert = insert->next) { if ((xmlStrEqual(insert->name, name)) && (xmlStrEqual(insert->name2, name2)) && (xmlStrEqual(insert->name3, name3))) return(-1); len++; } if ((xmlStrEqual(insert->name, name)) && (xmlStrEqual(insert->name2, name2)) && (xmlStrEqual(insert->name3, name3))) return(-1); } entry = xmlMalloc(sizeof(xmlHashEntry)); if (entry == NULL) return(-1); entry->name = xmlStrdup(name); entry->name2 = xmlStrdup(name2); entry->name3 = xmlStrdup(name3); entry->payload = userdata; entry->next = NULL; if (insert == NULL) { table->table[key] = entry; } else { insert->next = entry; } table->nbElems++; if (len > MAX_HASH_LEN) xmlHashGrow(table, MAX_HASH_LEN * table->size); return(0); }
/* Find an element among siblings, and get the (one) text element within it */ static xmlNodePtr get_element_text(xmlNodePtr node, const xmlChar *element) { xmlNodePtr sib; for (sib = node; sib; sib = sib->next) { if (xmlStrEqual(sib->name, element)) { xmlNodePtr text; text = get_element(sib->children, TEXT_ELT); if (text == NULL) { fprintf(stderr, "unable to find text element for %s\n", (char *)element); } else { return text; } } } return NULL; }
/* * Public API */ Local::Heap::Heap (Ekiga::ServiceCore &_core): core (_core), doc () { xmlNodePtr root; gchar *c_raw = gm_conf_get_string (KEY); // Build the XML document representing the contacts list from the configuration if (c_raw != NULL) { const std::string raw = c_raw; doc = std::tr1::shared_ptr<xmlDoc> (xmlRecoverMemory (raw.c_str (), raw.length ()), xmlFreeDoc); if ( !doc) doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlDocGetRootElement (doc.get ()); if (root == NULL) { root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); } for (xmlNodePtr child = root->children; child != NULL; child = child->next) if (child->type == XML_ELEMENT_NODE && child->name != NULL && xmlStrEqual (BAD_CAST ("entry"), child->name)) add (child); g_free (c_raw); // Or create a new XML document } else { doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); { // add 500 and 501 at ekiga.net in this case! std::set<std::string> groups; groups.insert (_("Services")); add (_("Echo test"), "sip:[email protected]", groups); add (_("Conference room"), "sip:[email protected]", groups); } } }
static GPInstructProject * create_project_from_xml_document (xmlDocPtr doc) { xmlNode *current_node; if (doc) { current_node = xmlDocGetRootElement (doc); if (current_node && current_node->name && xmlStrEqual (current_node->name, BAD_CAST "project")) return parse_project (current_node); } return NULL; }
static void html_read_rows (htmlNodePtr cur, htmlDocPtr doc, Workbook *wb, GnmHtmlTableCtxt *tc) { htmlNodePtr ptr; for (ptr = cur->children; ptr != NULL ; ptr = ptr->next) { if (ptr->type != XML_ELEMENT_NODE) continue; if (xmlStrEqual (ptr->name, CC2XML ("tr"))) { tc->row++; if (tc->sheet == NULL) tc->sheet = html_get_sheet (NULL, wb); html_read_row (ptr, doc, tc); } } }
static void parse_item_list (EggToolbarEditor *t, xmlNodePtr child) { while (child) { if (xmlStrEqual (child->name, BAD_CAST "toolitem")) { xmlChar *name; name = xmlGetProp (child, BAD_CAST "name"); egg_toolbar_editor_add_action (t, (const char *)name); xmlFree (name); } child = child->next; } }
static void * threadRoutine1(void *data) { xmlDocPtr input; xmlDocPtr style; xmlDocPtr res; xmlChar *result; int len; xsltStylesheetPtr cur; int id = (int)(unsigned long) data; input = xmlReadMemory(doc, strlen(doc), "doc.xml", NULL, 0); if (input == NULL) { fprintf(stderr, "Thread id %d failed to parse input\n", id); exit(1); } style = xmlReadMemory(stylesheet, strlen(stylesheet), "doc.xsl", NULL, 0); if (style == NULL) { fprintf(stderr, "Thread id %d failed to parse stylesheet\n", id); exit(1); } cur = xsltParseStylesheetDoc(style); if (cur == NULL) { fprintf(stderr, "Thread id %d failed to compile stylesheet\n", id); exit(1); } res = xsltApplyStylesheet(cur, input, NULL); if (res == NULL) { fprintf(stderr, "Thread id %d failed to apply stylesheet\n", id); exit(1); } if (xsltSaveResultToString(&result, &len, res, cur) < 0) { fprintf(stderr, "Thread id %d failed to output result\n", id); exit(1); } if (!xmlStrEqual(BAD_CAST expect, result)) { fprintf(stderr, "Thread id %d output not conform\n", id); exit(1); } xsltFreeStylesheet(cur); xmlFreeDoc(input); xmlFreeDoc(res); xmlFree(result); return(0); }
OPENLDAP::Source::Source (Ekiga::ServiceCore &_core): core(_core), doc(), should_add_ekiga_net_book(false) { xmlNodePtr root; gchar *c_raw = gm_conf_get_string (KEY); if (c_raw != NULL && strcmp (c_raw, "")) { const std::string raw = c_raw; doc = std::tr1::shared_ptr<xmlDoc> (xmlRecoverMemory (raw.c_str (), raw.length ()), xmlFreeDoc); if ( !doc) doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlDocGetRootElement (doc.get ()); if (root == NULL) { root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); } migrate_from_3_0_0 (); for (xmlNodePtr child = root->children ; child != NULL ; child = child->next) if (child->type == XML_ELEMENT_NODE && child->name != NULL && xmlStrEqual (BAD_CAST "server", child->name)) add (child); g_free (c_raw); } else { doc = std::tr1::shared_ptr<xmlDoc> (xmlNewDoc (BAD_CAST "1.0"), xmlFreeDoc); root = xmlNewDocNode (doc.get (), NULL, BAD_CAST "list", NULL); xmlDocSetRootElement (doc.get (), root); should_add_ekiga_net_book = true; } if (should_add_ekiga_net_book) new_ekiga_net_book (); }
LM::Account::Account (boost::shared_ptr<Ekiga::PersonalDetails> details_, boost::shared_ptr<Dialect> dialect_, boost::shared_ptr<Cluster> cluster_, xmlNodePtr node_): details(details_), dialect(dialect_), cluster(cluster_), node(node_) { if (node == NULL) throw std::logic_error ("NULL node pointer received"); status = _("inactive"); xmlChar* xml_str = xmlGetProp (node, BAD_CAST "startup"); bool enable_on_startup = false; if (xml_str != NULL) { if (xmlStrEqual (xml_str, BAD_CAST "true")) { enable_on_startup = true; } else { enable_on_startup = false; } } xmlFree (xml_str); connection = lm_connection_new (NULL); LmMessageHandler* iq_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)iq_handler_c, this, NULL); lm_connection_register_message_handler (connection, iq_lm_handler, LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_NORMAL); lm_message_handler_unref (iq_lm_handler); LmMessageHandler* presence_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)presence_handler_c, this, NULL); lm_connection_register_message_handler (connection, presence_lm_handler, LM_MESSAGE_TYPE_PRESENCE, LM_HANDLER_PRIORITY_NORMAL); lm_message_handler_unref (presence_lm_handler); LmMessageHandler* message_lm_handler = lm_message_handler_new ((LmHandleMessageFunction)message_handler_c, this, NULL); lm_connection_register_message_handler (connection, message_lm_handler, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_NORMAL); lm_message_handler_unref (message_lm_handler); lm_connection_set_disconnect_function (connection, (LmDisconnectFunction)on_disconnected_c, this, NULL); if (enable_on_startup) { enable (); } }
/** * glista_storage_get_all_items: * @list: Pointer to a GList* to populate with GlistaItem objects * * Load all items from storage into a linked-list, which will be in turn used * to load the data into the GtkListStore of the UI. */ void glista_storage_load_all_items(GList **list) { xmlTextReaderPtr xml; gchar *storage_file; xmlChar *node_name; GlistaItem *item; // Build storage file path storage_file = g_build_filename(gl_globs->configdir, GL_XML_FILENAME, NULL); // Open XML file if ((xml = xmlReaderForFile(storage_file, GL_XML_ENCODING, 0)) != NULL) { // Read the XML root node if (xmlTextReaderRead(xml) == 1) { node_name = xmlTextReaderName(xml); if (xmlStrEqual(node_name, BAD_CAST GL_XNODE_ROOT)) { // Read all items while ((item = read_next_item(xml)) != NULL) { if (item->text != NULL) { *list = g_list_append(*list, item); } else { glista_item_free(item); } } } else { g_warning("Invalid XML file: unexpected root element '%s'\n", node_name); } xmlFree(node_name); } else { g_warning("Invalid XML file: unable to read root element\n"); } xmlFreeTextReader(xml); } g_free(storage_file); }
bool MMSXMLServerInterface::throughDoc(xmlDocPtr doc, string *answer) { if(!doc|| !answer) { DEBUGMSG("MMSXMLServerInterface","throughdoc, error in cmdline"); return false; } xmlNodePtr root = xmlDocGetRootElement(doc); if(!root) return false; if(xmlStrEqual(root->name, (const xmlChar*)"func")==0) { DEBUGMSG("MMSXMLServerInterface", "The root element must be <func> and not <%s>.", root->name); return false; } return throughFunc(root, answer); }
/** * lgl_xml_get_prop_boolean: * @node: the libxml2 #xmlNodePtr of the node * @property: the property name * @default_val: a default value to return if property not found * * Return value of property as a boolean. * * Returns: the property as a boolean. * */ gboolean lgl_xml_get_prop_boolean (xmlNodePtr node, const gchar *property, gboolean default_val) { gboolean val; xmlChar *string; string = xmlGetProp (node, (xmlChar *)property); if ( string != NULL ) { val = !((xmlStrcasecmp (string, (xmlChar *)"false") == 0) || xmlStrEqual (string, (xmlChar *)"0"));; xmlFree (string); return val; } return default_val; }
void Functionmodel::execute(fsm::Context * ctx){ //LOG4CPLUS_TRACE(log,m_strSession << ",execute starting..."); if (node == 0) return; bool bFindData = false; for (xmlNodePtr funNode = node->children ; funNode != NULL; funNode = funNode->next) { if(funNode->type != XML_ELEMENT_NODE || !xmlStrEqual(funNode->name, BAD_CAST("function"))) continue; bFindData = true; model::Function fun(funNode,m_strSession,m_strFilename); fun.execute(ctx); } if (!bFindData) { LOG4CPLUS_WARN(log,"not find data element in this functionmodel."); } //LOG4CPLUS_TRACE(log,m_strSession << ",execute end."); }
//----------------------------------------- void LegacyParser::processCreatorNode(xmlTextReaderPtr reader) { //----------------------------------------- int ret = xmlTextReaderRead(reader); if( ret == 1 ) { /* should be the text node */ const xmlChar* name = xmlTextReaderConstName(reader); if ( xmlStrEqual(name, xmlCharStrdup("#text")) == 1 ) { int hasVal = xmlTextReaderHasValue(reader); if(hasVal == 1) { const xmlChar *value = xmlTextReaderConstValue(reader); if(value != NULL) _gexf->getMetaData().setCreator( Conv::xmlCharToStr(value) ); } else if(hasVal == -1) { throw FileReaderException("An error occured in xmlTextReaderHasValue() for Creator node."); } } } }
bool CRLEDConfigFile::parseClientList( void *listPtr ) { xmlNode *nodePtr = NULL; // Traverse the document to pull out the items of interest for( nodePtr = ((xmlNode *)listPtr)->children; nodePtr; nodePtr = nodePtr->next ) { if( nodePtr->type == XML_ELEMENT_NODE ) { printf( "node type: Element, name: %s\n", nodePtr->name ); if( xmlStrEqual( nodePtr->name, (xmlChar *)"client" ) ) { parseClientNode( nodePtr ); } } } }
bool c_XMLReader::t_next(const String& localname /*= null_string*/) { if (m_ptr) { int ret = xmlTextReaderNext(m_ptr); while (!localname.empty() && ret == 1) { if (xmlStrEqual(xmlTextReaderConstLocalName(m_ptr), (xmlChar *)localname.data())) { return true; } ret = xmlTextReaderNext(m_ptr); } if (ret == -1) { raise_warning("An Error Occured while reading"); return false; } else { return ret; } } raise_warning("Load Data before trying to read"); return false; }
/** * xsltLoadDocument: * @ctxt: an XSLT transformation context * @URI: the computed URI of the document * * Try to load a document within the XSLT transformation context * * Returns the new xsltDocumentPtr or NULL in case of error */ xsltDocumentPtr xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) { xsltDocumentPtr ret; xmlDocPtr doc; if ((ctxt == NULL) || (URI == NULL)) return(NULL); /* * Walk the context list to find the document if preparsed */ ret = ctxt->docList; while (ret != NULL) { if ((ret->doc != NULL) && (ret->doc->URL != NULL) && (xmlStrEqual(ret->doc->URL, URI))) return(ret); ret = ret->next; } doc = xmlParseFile((const char *) URI); if (doc == NULL) return(NULL); if (ctxt->xinclude != 0) { #ifdef LIBXML_XINCLUDE_ENABLED xmlXIncludeProcess(doc); #else xsltPrintErrorContext(ctxt, NULL, NULL); xsltGenericError(xsltGenericErrorContext, "xsltLoadDocument(%s) : XInclude processing not compiled in\n", URI); #endif } /* * Apply white-space stripping if asked for */ if (xsltNeedElemSpaceHandling(ctxt)) xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc)); ret = xsltNewDocument(ctxt, doc); return(ret); }
xsltStylesheetPtr parse_xsl( char* xsl, int iXslType ) { xsltStylesheetPtr tParsedXslt = NULL; xmlDocPtr tXSLDocument = NULL; /** Rem: For encoding */ xmlCharEncodingHandlerPtr encoder = NULL; const xmlChar *encoding = NULL; /** Act: Encoding support */ xmlInitCharEncodingHandlers( ); /** Act: Parse XSL */ if( iXslType == RUBY_XSLT_XSLSRC_TYPE_STR ) { tXSLDocument = xmlParseMemory( xsl, strlen( xsl ) ); if( tXSLDocument == NULL ) { rb_raise( eXSLTParsingError, "XSL parsing error" ); return( NULL ); } tParsedXslt = xsltParseStylesheetDoc( tXSLDocument ); } else if( iXslType == RUBY_XSLT_XSLSRC_TYPE_FILE ) { tParsedXslt = xsltParseStylesheetFile( BAD_CAST xsl ); } if( tParsedXslt == NULL ) { rb_raise( eXSLTParsingError, "XSL Stylesheet parsing error" ); return( NULL ); } /** Act: Get encoding */ XSLT_GET_IMPORT_PTR( encoding, tParsedXslt, encoding ) encoder = xmlFindCharEncodingHandler((char *)encoding); if( encoding != NULL ) { encoder = xmlFindCharEncodingHandler((char *)encoding); if( (encoder != NULL) && (xmlStrEqual((const xmlChar *)encoder->name, (const xmlChar *) "UTF-8")) ) { encoder = NULL; } } return( tParsedXslt ); }