static void parse_rss_cloud (GrssFeedChannel *feed, xmlNodePtr cur) { gchar *domain; gchar *path; gchar *protocol; gchar *completepath; domain = (gchar*) xmlGetNsProp (cur, BAD_CAST"domain", NULL); path = (gchar*) xmlGetNsProp (cur, BAD_CAST"path", NULL); protocol = (gchar*) xmlGetNsProp (cur, BAD_CAST"protocol", NULL); if (domain != NULL && path != NULL && protocol != NULL) { if (strncmp (domain, "http://", 7) != 0) completepath = g_strdup_printf ("http://%s%s", domain, path); else completepath = g_strdup_printf ("%s%s", domain, path); grss_feed_channel_set_rsscloud (feed, completepath, protocol); g_free (domain); g_free (path); g_free (protocol); g_free (completepath); } }
/** * xlinkIsLink: * @doc: the document containing the node * @node: the node pointer itself * * Check whether the given node carries the attributes needed * to be a link element (or is one of the linking elements issued * from the (X)HTML DtDs). * This routine don't try to do full checking of the link validity * but tries to detect and return the appropriate link type. * * Returns the xlinkType of the node (XLINK_TYPE_NONE if there is no * link detected. */ xlinkType xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) { xmlChar *type = NULL, *role = NULL; xlinkType ret = XLINK_TYPE_NONE; if (node == NULL) return(XLINK_TYPE_NONE); if (doc == NULL) doc = node->doc; if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { /* * This is an HTML document. */ } else if ((node->ns != NULL) && (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) { /* * !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@ */ /* * This is an XHTML element within an XML document * Check whether it's one of the element able to carry links * and in that case if it holds the attributes. */ } /* * We don't prevent a-priori having XML Linking constructs on * XHTML elements */ type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE); if (type != NULL) { if (xmlStrEqual(type, BAD_CAST "simple")) { ret = XLINK_TYPE_SIMPLE; } if (xmlStrEqual(type, BAD_CAST "extended")) { role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE); if (role != NULL) { xmlNsPtr xlink; xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE); if (xlink == NULL) { /* Humm, fallback method */ if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) ret = XLINK_TYPE_EXTENDED_SET; } else { xmlChar buf[200]; snprintf((char *) buf, sizeof(buf), "%s:external-linkset", (char *) xlink->prefix); buf[sizeof(buf) - 1] = 0; if (xmlStrEqual(role, buf)) ret = XLINK_TYPE_EXTENDED_SET; } } ret = XLINK_TYPE_EXTENDED; } } if (type != NULL) xmlFree(type); if (role != NULL) xmlFree(role); return(ret); }
static xmlChar *getNodeURI(xmlNode *node) { if (!node) return NULL; xmlChar *uri; // assume this is a normal node uri = xmlGetNsProp(node, BAD_CAST NODENAME_ABOUT, BAD_CAST NSURL_RDF); if (!uri) // nope, hopefully it's a reference node then uri = xmlGetNsProp(node, BAD_CAST NODENAME_RESOURCE, BAD_CAST NSURL_RDF); return uri; }
static inline xmlChar* get_dt_type(xmlNodePtr xdr) { xmlChar* str = xmlGetNsProp(xdr, xs_type, DT_href); if (!str) { xmlNodePtr datatype = get_child(xdr, xs_datatype); if (datatype) str = xmlGetNsProp(datatype, xs_type, DT_href); } return str; }
WsXmlAttrH xml_parser_attr_add(WsXmlNodeH node, const char *uri, const char *name, const char *value) { xmlNodePtr xmlNode = (xmlNodePtr) node; xmlNsPtr xmlNs = (xmlNsPtr) xml_parser_ns_find(node, uri, NULL, 1, 1); xmlAttrPtr xmlAttr = (xmlAttrPtr) ws_xml_find_node_attr(node, uri, name); if (xmlAttr != NULL) ws_xml_remove_node_attr((WsXmlAttrH) xmlAttr); if (xmlNs == NULL) xmlAttr = xmlNewProp(xmlNode, BAD_CAST name, BAD_CAST value); else xmlAttr = xmlNewNsProp(xmlNode, xmlNs, BAD_CAST name, BAD_CAST value); if (xmlAttr != NULL) { if (xmlNs == NULL) xmlAttr->_private = xmlGetProp(xmlNode, BAD_CAST name); else xmlAttr->_private = xmlGetNsProp(xmlNode, BAD_CAST name, xmlNs->href); } return (WsXmlAttrH) xmlAttr; }
/** * Returns the value of the attribute with the specified name and namespace URI, * or null if this element does not have such an attribute. * @param localName the name of the attribute. * @param namespaceURI the namespace of the attribute. * @return the value of the attribute of this element with the specified name * and namespace. */ Option<String> Element::getAttributeValue(String localName, String ns) { xmlChar *result = xmlGetNsProp(NODE(node), localName, ns); if(!result) return none; else return some(String(result)); }
/* * Extend the existing value for an attribute, appending the given value. */ static void slaxNodeAttribExtend (slax_data_t *sdp, xmlNodePtr nodep, const char *attrib, const char *value, const char *uri) { const xmlChar *uattrib = (const xmlChar *) attrib; xmlChar *current = uri ? xmlGetProp(nodep, uattrib) : xmlGetNsProp(nodep, uattrib, (const xmlChar *) uri); int clen = current ? xmlStrlen(current) + 1 : 0; int vlen = strlen(value) + 1; unsigned char *newp = alloca(clen + vlen); if (newp == NULL) { xmlParserError(sdp->sd_ctxt, "%s:%d: out of memory", sdp->sd_filename, sdp->sd_line); return; } if (clen) { memcpy(newp, current, clen - 1); newp[clen - 1] = ' '; xmlFree(current); } memcpy(newp + clen, value, vlen); if (uri == NULL) xmlSetProp(nodep, uattrib, newp); else { xmlNsPtr nsp = xmlSearchNsByHref(sdp->sd_docp, nodep, (const xmlChar *) uri); xmlSetNsProp(nodep, nsp, uattrib, newp); } }
XDR_DT SchemaCache_get_node_dt(IXMLDOMSchemaCollection2* iface, xmlNodePtr node) { schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface); xmlSchemaPtr schema = get_node_schema(This, node); XDR_DT dt = DT_INVALID; TRACE("(%p, %p)\n", This, node); if (node->ns && xmlStrEqual(node->ns->href, DT_nsURI)) { dt = str_to_dt(node->name, -1); } else if (schema) { xmlChar* str; xmlNodePtr schema_node = lookup_schema_element(schema, node); str = xmlGetNsProp(schema_node, BAD_CAST "dt", DT_nsURI); if (str) { dt = str_to_dt(str, -1); xmlFree(str); } } return dt; }
static inline xmlNodePtr get_child_with_attr(xmlNodePtr node, xmlChar const* name, xmlChar const* attr_ns, xmlChar const* attr_name, xmlChar const* attr_val) { xmlChar* str; if (node) { FOREACH_CHILD(node, node) { if (xmlStrEqual(node->name, name)) { str = (attr_ns != NULL)? xmlGetNsProp(node, attr_name, attr_ns) : xmlGetProp(node, attr_name); if (str) { if (xmlStrEqual(str, attr_val)) { xmlFree(str); return node; } xmlFree(str); } } } } return NULL; }
int exclude_namespace(elcgen *gen, expression *expr, const char *uri) { int found = 0; expression *xp; if (!strcmp(uri,XSLT_NS)) return 1; for (xp = expr; xp && !found; xp = xp->parent) { char *str; if (xp->xmlnode->ns && !strcmp((char*)xp->xmlnode->ns->href,XSLT_NS)) str = xmlGetNsProp(xp->xmlnode,"exclude-result-prefixes",NULL); else str = xmlGetNsProp(xp->xmlnode,"exclude-result-prefixes",XSLT_NS); if (str) { int end = 0; char *start = str; char *c; for (c = str; !found && !end; c++) { end = ('\0' == *c); if (end || isspace(*c)) { if (c > start) { xmlNsPtr ns; *c = '\0'; if (!strcmp(start,"#all")) { found = (NULL != xmlSearchNsByHref(gen->parse_doc,xp->xmlnode,(xmlChar*)uri)); } else if (!strcmp(start,"#default")) { found = ((NULL != xp->xmlnode->ns) && !strcmp((char*)xp->xmlnode->ns->href,uri)); } else { ns = xmlSearchNs(gen->parse_doc,xp->xmlnode,(xmlChar*)start); found = ((NULL != ns) && !strcmp((char*)ns->href,uri)); } } start = c+1; } } free(str); } } return found; }
xlinkType xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) { xmlChar *type = NULL, *role = NULL; xlinkType ret = XLINK_TYPE_NONE; if (node == NULL) return(XLINK_TYPE_NONE); if (doc == NULL) doc = node->doc; if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) { } else if ((node->ns != NULL) && (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) { } type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE); if (type != NULL) { if (xmlStrEqual(type, BAD_CAST "simple")) { ret = XLINK_TYPE_SIMPLE; } if (xmlStrEqual(type, BAD_CAST "extended")) { role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE); if (role != NULL) { xmlNsPtr xlink; xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE); if (xlink == NULL) { if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) ret = XLINK_TYPE_EXTENDED_SET; } else { xmlChar buf[200]; snprintf((char *) buf, sizeof(buf), "%s:external-linkset", (char *) xlink->prefix); buf[sizeof(buf) - 1] = 0; if (xmlStrEqual(role, buf)) ret = XLINK_TYPE_EXTENDED_SET; } } ret = XLINK_TYPE_EXTENDED; } } if (type != NULL) xmlFree(type); if (role != NULL) xmlFree(role); return(ret); }
string wsNode::getNsProperty(string propName,string ns){ xmlChar * name= xmlGetNsProp(this->thisNode,(xmlChar *)propName.c_str(),(xmlChar *)ns.c_str()); string sName; if(name!=0) sName=(const char*)name; xmlFree(name); return sName; }
static void scanterm(xmlNode *term) { xmlAttrPtr rsrc; xmlNode *n=NULL; xmlChar * acn=NULL; for(n=term->children; n!=NULL; n=n->next) { if (n->type != XML_ELEMENT_NODE) continue; if(strcmp(n->name,"accession")==0 && n->ns!=NULL && n->ns->href!=NULL && strcmp(n->ns->href,GO_NS)==0) { acn= xmlNodeGetContent(n); break; } } if(acn==NULL) return; for(n=term->children; n!=NULL; n=n->next) { if (n->type != XML_ELEMENT_NODE) continue; if(strcmp(n->name,"is_a")==0 && n->ns!=NULL && n->ns->href!=NULL && strcmp(n->ns->href,GO_NS)==0 ) { xmlChar* is_a=xmlGetNsProp(n,"resource",RDF_NS); if(is_a!=NULL) { char* p=strstr(is_a,"#GO:"); if(p!=NULL) { ++p; termdb.terms=(TermPtr)realloc(termdb.terms,sizeof(Term)*(termdb.n_terms+1)); if(termdb.terms==NULL) { fprintf(stderr,"out of memory\n"); exit(EXIT_FAILURE); } strncpy(termdb.terms[termdb.n_terms].parent,p,MAX_TERM_LENGTH); strncpy(termdb.terms[termdb.n_terms].child,acn,MAX_TERM_LENGTH); //fprintf(stdout,"%s\t%s\n",termdb.terms[termdb.n_terms].child,termdb.terms[termdb.n_terms].parent); ++termdb.n_terms; } xmlFree(is_a); } else { //fprintf("); } } } xmlFree(acn); }
// DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); static void _getAttributeNS(Request& r, MethodParams& params) { xmlChar* namespaceURI=as_xmlnsuri(r, params, 0); xmlChar* localName=as_xmlname(r, params, 1); VXnode& vnode=GET_SELF(r, VXnode); xmlNode& element=get_self_element(vnode); // todo: when name="xmlns" xmlChar* attribute_value=xmlGetNsProp(&element, localName, namespaceURI); // write out result r.write_pass_lang(r.transcode(attribute_value)); }
/** * Retrieve a KML propertie from a node or NULL otherwise * Respect namespaces if presents in the node element */ static xmlChar *kmlGetProp(xmlNodePtr xnode, xmlChar *prop) { xmlChar *value; if (!is_kml_namespace(xnode, true)) return xmlGetProp(xnode, prop); value = xmlGetNsProp(xnode, prop, (xmlChar *) KML_NS); /* In last case try without explicit namespace */ if (value == NULL) value = xmlGetNoNsProp(xnode, prop); return value; }
std::string utils::get_prop(xmlNode * node, const char * prop, const char * ns) { std::string retval; if (node) { xmlChar * value; if (ns) value = xmlGetProp(node, (xmlChar *)prop); else value = xmlGetNsProp(node, (xmlChar *)prop, (xmlChar *)ns); if (value) { retval = (const char*)value; xmlFree(value); } } return retval; }
static void readDNAComponentContent(xmlNode *node) { DNAComponent *com; xmlChar *com_uri; xmlChar *path; xmlChar *type_property; xmlNode *type_node; xmlNode *child_node; // structured xml annotation PointerArray *results; int i; // create DNAComponent com_uri = getNodeURI(node); com = createDNAComponent(DESTINATION, (char *)com_uri); xmlFree(com_uri); // add displayID, name, description readSBOLCompoundObject(com->base, node); // add type path = (unsigned char*)NSPREFIX_RDF ":" NODENAME_TYPE; if ((results = getNodesMatchingXPath(node, path))) { type_node = (xmlNode *)getNthPointerInArray(results, 0); type_property = xmlGetNsProp(type_node, BAD_CAST NODENAME_RESOURCE, BAD_CAST NSURL_RDF); setDNAComponentType(com, (char *)type_property); xmlFree(results); } // scan other xml nodes attached to this DNAComponent for structured xml annotations // @TODO factor out this block of code. This routine is generally used by each of the SBOL core objects // but it requires some custom knowledge of the calling object (in this case, DNAComponent) child_node = node->children; while (child_node) { if (child_node->ns && !isSBOLNamespace(child_node->ns->href)) { // copy xml tree and save it in the SBOLDocument object as a structural annotation xmlNode* node_copy = xmlDocCopyNode(child_node, com->doc->xml_doc, 1); node_copy = xmlAddChild(xmlDocGetRootElement(com->doc->xml_doc), node_copy); i = xmlReconciliateNs(com->doc->xml_doc, xmlDocGetRootElement(com->doc->xml_doc)); insertPointerIntoArray(com->base->base->xml_annotations, node_copy); } child_node = child_node->next; } }
/* * Class: org_xmlsoft_Node * Method: getNsPropImpl * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_xmlsoft_Node_getNsPropImpl (JNIEnv *env, jobject obj, jstring jName, jstring jHref) { xmlNode *node = findNode(env, obj); xmlChar *value; jstring jValue; const char *name = (*env)->GetStringUTFChars(env, jName, NULL); const char *href = (*env)->GetStringUTFChars(env, jHref, NULL); value = xmlGetNsProp(node, (const xmlChar*)name, (const xmlChar*)href); (*env)->NewStringUTF(env, (const char*)value); (*env)->ReleaseStringUTFChars(env, jName, name); (*env)->ReleaseStringUTFChars(env, jHref, href); jValue = (*env)->NewStringUTF(env, (const char*)value); xmlFree(value); return jValue; }
std::string rss_parser::get_prop(xmlNode * node, const std::string& prop, const std::string& ns) { std::string retval; if (node) { xmlChar * value = nullptr; if (ns.empty()) { value = xmlGetProp( node, reinterpret_cast<const xmlChar *>(prop.c_str())); } else { value = xmlGetNsProp( node, reinterpret_cast<const xmlChar *>(prop.c_str()), reinterpret_cast<const xmlChar *>(ns.c_str())); } if (value) { retval = reinterpret_cast<const char*>(value); xmlFree(value); } } return retval; }
string Node::AttributeValue(const string& name, const string& nsURI) const { xmlChar * ch = nullptr; if ( !nsURI.empty() ) { ch = xmlGetNsProp(_xml, name.xml_str(), nsURI.xml_str()); } if ( ch == nullptr ) { ch = xmlGetProp(_xml, name.xml_str()); } if ( ch == nullptr ) return string::EmptyString; string result(ch); xmlFree(ch); return result; }
static int get_node_namespace(struct ns_pair ns_mapping[], xmlNodePtr node, char** prefix, char** uri) { int i; (*prefix) = NULL; if (((*uri) = (char*)xmlGetNsProp(node, BAD_CAST "ns", BAD_CAST "libnetconf")) == NULL) { return(EXIT_FAILURE); } else { for (i=0; ns_mapping[i].href != NULL; i++) { if (strcmp(ns_mapping[i].href, (*uri)) == 0) { (*prefix) = strdup(ns_mapping[i].prefix); break; } } if ((*prefix) == NULL) { return(EXIT_FAILURE); } } return(EXIT_SUCCESS); }
/* Create from the direct children of a parent node; any children that match the given element are used to populate the container, based on their xml:lang value */ CongPerLanguageData* cong_per_language_data_new_from_xml (xmlDocPtr xml_doc, CongNodePtr parent_node, const gchar *ns_uri, const gchar *element_name, gpointer (make_data_callback) (xmlDocPtr xml_doc, CongNodePtr node), GDestroyNotify value_destroy_func) { CongPerLanguageData *per_lang; CongNodePtr child_iter; g_return_val_if_fail (xml_doc, NULL); g_return_val_if_fail (parent_node, NULL); g_return_val_if_fail (element_name, NULL); g_return_val_if_fail (make_data_callback, NULL); per_lang = cong_per_language_data_new (value_destroy_func); for (child_iter=parent_node->children; child_iter; child_iter=child_iter->next) { if (cong_node_is_element (child_iter, ns_uri, element_name)) { gpointer data = (*make_data_callback) (xml_doc, child_iter); xmlChar *lang = xmlGetNsProp (child_iter, BAD_CAST "lang", XML_XML_NAMESPACE); if (lang) { cong_per_language_set_data_for_lang (per_lang, g_strdup ((const gchar*)lang), data); xmlFree (lang); } else { cong_per_language_set_data_for_lang (per_lang, NULL, data); } } } return per_lang; }
static int node_get_attr(lua_State *L) { xmlNodePtr node = lua_touserdata(L, 1); const char *name = luaL_checkstring(L, 2); const char *ns = lua_tostring(L, 3); xmlChar *prop; if (node == NULL) return luaL_error(L, "attribute: Invalid node"); if (node->type != XML_ELEMENT_NODE) return luaL_error(L, "attribute: Invalid node type (not element node)"); if (name == NULL) return luaL_error(L, "attribute: Specify attribute name"); if (ns) { prop = xmlGetNsProp(node, BAD_CAST name, BAD_CAST ns); } else { prop = xmlGetNoNsProp(node, BAD_CAST name); } lua_pushstring(L, (char *) prop); xmlFree(prop); return 1; }
char *xml_parser_attr_query(WsXmlAttrH attr, int what) { char *ptr = NULL; xmlAttrPtr xmlAttr = (xmlAttrPtr) attr; switch (what) { case XML_LOCAL_NAME: ptr = (char *) xmlAttr->name; break; case XML_NS_URI: if (xmlAttr->ns != NULL) ptr = (char *) xmlAttr->ns->href; break; case XML_NS_PREFIX: if (xmlAttr->ns != NULL) ptr = (char *) xmlAttr->ns->prefix; break; case XML_TEXT_VALUE: if (xmlAttr->_private == NULL) { if (xmlAttr->ns == NULL) xmlAttr->_private = xmlGetProp(xmlAttr->parent, xmlAttr->name); else xmlAttr->_private = xmlGetNsProp(xmlAttr->parent, xmlAttr->name, xmlAttr->ns->href); } ptr = (char *) xmlAttr->_private; break; default: assert(what == XML_LOCAL_NAME); break; } return ptr; }
osrfHash* oilsIDLInit( const char* idl_filename ) { if (idlHash) return idlHash; char* prop_str = NULL; idlHash = osrfNewHash(); osrfHash* class_def_hash = NULL; osrfLogInfo(OSRF_LOG_MARK, "Parsing the IDL XML..."); idlDoc = xmlReadFile( idl_filename, NULL, XML_PARSE_XINCLUDE ); if (!idlDoc) { osrfLogError(OSRF_LOG_MARK, "Could not load or parse the IDL XML file!"); return NULL; } osrfLogDebug(OSRF_LOG_MARK, "Initializing the Fieldmapper IDL..."); xmlNodePtr docRoot = xmlDocGetRootElement(idlDoc); xmlNodePtr kid = docRoot->children; while (kid) { if (!strcmp( (char*)kid->name, "class" )) { class_def_hash = osrfNewHash(); char* current_class_name = (char*) xmlGetProp(kid, BAD_CAST "id"); osrfHashSet( class_def_hash, current_class_name, "classname" ); osrfHashSet( class_def_hash, xmlGetNsProp(kid, BAD_CAST "fieldmapper", BAD_CAST OBJECT_NS), "fieldmapper" ); osrfHashSet( class_def_hash, xmlGetNsProp(kid, BAD_CAST "readonly", BAD_CAST PERSIST_NS), "readonly" ); osrfHashSet( idlHash, class_def_hash, current_class_name ); if ((prop_str = (char*)xmlGetNsProp(kid, BAD_CAST "tablename", BAD_CAST PERSIST_NS))) { osrfLogDebug(OSRF_LOG_MARK, "Using table '%s' for class %s", prop_str, current_class_name ); osrfHashSet( class_def_hash, prop_str, "tablename" ); } if ((prop_str = (char*)xmlGetNsProp(kid, BAD_CAST "restrict_primary", BAD_CAST PERSIST_NS))) { osrfLogDebug(OSRF_LOG_MARK, "Delete restriction policy set at '%s' for pkey of class %s", prop_str, current_class_name ); osrfHashSet( class_def_hash, prop_str, "restrict_primary" ); } if ((prop_str = (char*)xmlGetNsProp(kid, BAD_CAST "virtual", BAD_CAST PERSIST_NS))) { osrfHashSet( class_def_hash, prop_str, "virtual" ); } // Tokenize controller attribute into an osrfStringArray prop_str = (char*) xmlGetProp(kid, BAD_CAST "controller"); if( prop_str ) osrfLogDebug(OSRF_LOG_MARK, "Controller list is %s", prop_str ); osrfStringArray* controller = osrfStringArrayTokenize( prop_str, ' ' ); xmlFree( prop_str ); osrfHashSet( class_def_hash, controller, "controller"); osrfHash* current_links_hash = osrfNewHash(); osrfHash* current_fields_hash = osrfNewHash(); osrfHashSet( class_def_hash, current_fields_hash, "fields" ); osrfHashSet( class_def_hash, current_links_hash, "links" ); xmlNodePtr _cur = kid->children; while (_cur) { if (!strcmp( (char*)_cur->name, "fields" )) { if( (prop_str = (char*)xmlGetNsProp(_cur, BAD_CAST "primary", BAD_CAST PERSIST_NS)) ) { osrfHashSet( class_def_hash, prop_str, "primarykey" ); } if( (prop_str = (char*)xmlGetNsProp(_cur, BAD_CAST "sequence", BAD_CAST PERSIST_NS)) ) { osrfHashSet( class_def_hash, prop_str, "sequence" ); } unsigned int array_pos = 0; char array_pos_buf[ 7 ]; // For up to 1,000,000 fields per class xmlNodePtr _f = _cur->children; while(_f) { if (strcmp( (char*)_f->name, "field" )) { _f = _f->next; continue; } // Get the field name. If it's one of the three standard // fields that we always generate, ignore it. char* field_name = (char*)xmlGetProp(_f, BAD_CAST "name"); if( field_name ) { osrfLogDebug(OSRF_LOG_MARK, "Found field %s for class %s", field_name, current_class_name ); if( !strcmp( field_name, "isnew" ) || !strcmp( field_name, "ischanged" ) || !strcmp( field_name, "isdeleted" ) ) { free( field_name ); _f = _f->next; continue; } } else { osrfLogDebug(OSRF_LOG_MARK, "Found field with no name for class %s", current_class_name ); _f = _f->next; continue; } osrfHash* field_def_hash = osrfNewHash(); // Insert array_position snprintf( array_pos_buf, sizeof( array_pos_buf ), "%u", array_pos++ ); osrfHashSet( field_def_hash, strdup( array_pos_buf ), "array_position" ); if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "i18n", BAD_CAST PERSIST_NS)) ) { osrfHashSet( field_def_hash, prop_str, "i18n" ); } if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "virtual", BAD_CAST PERSIST_NS)) ) { osrfHashSet( field_def_hash, prop_str, "virtual" ); } else { // default to virtual osrfHashSet( field_def_hash, "false", "virtual" ); } if( (prop_str = (char*)xmlGetNsProp(_f, BAD_CAST "primitive", BAD_CAST PERSIST_NS)) ) { osrfHashSet( field_def_hash, prop_str, "primitive" ); } osrfHashSet( field_def_hash, field_name, "name" ); osrfHashSet( current_fields_hash, field_def_hash, field_name ); _f = _f->next; } // Create three standard, stereotyped virtual fields for every class add_std_fld( current_fields_hash, "isnew", array_pos++ ); add_std_fld( current_fields_hash, "ischanged", array_pos++ ); add_std_fld( current_fields_hash, "isdeleted", array_pos ); } if (!strcmp( (char*)_cur->name, "links" )) { xmlNodePtr _l = _cur->children; while(_l) { if (strcmp( (char*)_l->name, "link" )) { _l = _l->next; continue; } osrfHash* link_def_hash = osrfNewHash(); if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "reltype")) ) { osrfHashSet( link_def_hash, prop_str, "reltype" ); osrfLogDebug(OSRF_LOG_MARK, "Adding link with reltype %s", prop_str ); } else osrfLogDebug(OSRF_LOG_MARK, "Adding link with no reltype" ); if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "key")) ) { osrfHashSet( link_def_hash, prop_str, "key" ); osrfLogDebug(OSRF_LOG_MARK, "Link fkey is %s", prop_str ); } else osrfLogDebug(OSRF_LOG_MARK, "Link with no fkey" ); if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "class")) ) { osrfHashSet( link_def_hash, prop_str, "class" ); osrfLogDebug(OSRF_LOG_MARK, "Link fclass is %s", prop_str ); } else osrfLogDebug(OSRF_LOG_MARK, "Link with no fclass" ); // Tokenize map attribute into an osrfStringArray prop_str = (char*) xmlGetProp(_l, BAD_CAST "map"); if( prop_str ) osrfLogDebug(OSRF_LOG_MARK, "Link mapping list is %s", prop_str ); osrfStringArray* map = osrfStringArrayTokenize( prop_str, ' ' ); osrfHashSet( link_def_hash, map, "map"); xmlFree( prop_str ); if( (prop_str = (char*)xmlGetProp(_l, BAD_CAST "field")) ) { osrfHashSet( link_def_hash, prop_str, "field" ); osrfLogDebug(OSRF_LOG_MARK, "Link fclass is %s", prop_str ); } else osrfLogDebug(OSRF_LOG_MARK, "Link with no fclass" ); osrfHashSet( current_links_hash, link_def_hash, prop_str ); _l = _l->next; } } /**** Structure of permacrud in memory **** { create : { permission : [ x, y, z ], global_required : "true", -- anything else, or missing, is false local_context : [ f1, f2 ], foreign_context : { class1 : { fkey : local_class_key, field : class1_field, context : [ a, b, c ] }, ...} }, retrieve : null, -- no perm check, or structure similar to the others update : -- like create ... delete : -- like create ... } **** Structure of permacrud in memory ****/ if (!strcmp( (char*)_cur->name, "permacrud" )) { osrfHash* pcrud = osrfNewHash(); osrfHashSet( class_def_hash, pcrud, "permacrud" ); xmlNodePtr _l = _cur->children; while(_l) { if (strcmp( (char*)_l->name, "actions" )) { _l = _l->next; continue; } xmlNodePtr _a = _l->children; while(_a) { const char* action_name = (const char*) _a->name; if ( strcmp( action_name, "create" ) && strcmp( action_name, "retrieve" ) && strcmp( action_name, "update" ) && strcmp( action_name, "delete" ) ) { _a = _a->next; continue; } osrfLogDebug(OSRF_LOG_MARK, "Found Permacrud action %s for class %s", action_name, current_class_name ); osrfHash* action_def_hash = osrfNewHash(); osrfHashSet( pcrud, action_def_hash, action_name ); // Tokenize permission attribute into an osrfStringArray prop_str = (char*) xmlGetProp(_a, BAD_CAST "permission"); if( prop_str ) osrfLogDebug(OSRF_LOG_MARK, "Permacrud permission list is %s", prop_str ); osrfStringArray* map = osrfStringArrayTokenize( prop_str, ' ' ); osrfHashSet( action_def_hash, map, "permission"); xmlFree( prop_str ); osrfHashSet( action_def_hash, (char*)xmlGetNoNsProp(_a, BAD_CAST "global_required"), "global_required"); // Tokenize context_field attribute into an osrfStringArray prop_str = (char*) xmlGetProp(_a, BAD_CAST "context_field"); if( prop_str ) osrfLogDebug(OSRF_LOG_MARK, "Permacrud context_field list is %s", prop_str ); map = osrfStringArrayTokenize( prop_str, ' ' ); osrfHashSet( action_def_hash, map, "local_context"); xmlFree( prop_str ); osrfHash* foreign_context = osrfNewHash(); osrfHashSet( action_def_hash, foreign_context, "foreign_context"); xmlNodePtr _f = _a->children; while(_f) { if ( strcmp( (char*)_f->name, "context" ) ) { _f = _f->next; continue; } if( (prop_str = (char*)xmlGetNoNsProp(_f, BAD_CAST "link")) ) { osrfLogDebug(OSRF_LOG_MARK, "Permacrud context link definition is %s", prop_str ); osrfHash* _tmp_fcontext = osrfNewHash(); // Store pointers to elements already stored // from the <link> aggregate osrfHash* _flink = osrfHashGet( current_links_hash, prop_str ); osrfHashSet( _tmp_fcontext, osrfHashGet(_flink, "field"), "fkey" ); osrfHashSet( _tmp_fcontext, osrfHashGet(_flink, "key"), "field" ); xmlFree( prop_str ); if( (prop_str = (char*)xmlGetNoNsProp(_f, BAD_CAST "jump")) ) osrfHashSet( _tmp_fcontext, osrfStringArrayTokenize( prop_str, '.' ), "jump" ); xmlFree( prop_str ); // Tokenize field attribute into an osrfStringArray char * field_list = (char*) xmlGetProp(_f, BAD_CAST "field"); if( field_list ) osrfLogDebug(OSRF_LOG_MARK, "Permacrud foreign context field list is %s", field_list ); map = osrfStringArrayTokenize( field_list, ' ' ); osrfHashSet( _tmp_fcontext, map, "context"); xmlFree( field_list ); // Insert the new hash into a hash attached to the parent node osrfHashSet( foreign_context, _tmp_fcontext, osrfHashGet( _flink, "class" ) ); } else { if( (prop_str = (char*)xmlGetNoNsProp(_f, BAD_CAST "field") )) { char* map_list = prop_str; osrfLogDebug(OSRF_LOG_MARK, "Permacrud local context field list is %s", prop_str ); if (strlen( map_list ) > 0) { char* st_tmp = NULL; char* _map_class = strtok_r(map_list, " ", &st_tmp); osrfStringArrayAdd( osrfHashGet( action_def_hash, "local_context"), _map_class); while ((_map_class = strtok_r(NULL, " ", &st_tmp))) { osrfStringArrayAdd( osrfHashGet( action_def_hash, "local_context"), _map_class); } } xmlFree(map_list); } } _f = _f->next; } _a = _a->next; } _l = _l->next; } } if (!strcmp( (char*)_cur->name, "source_definition" )) { char* content_str; if( (content_str = (char*)xmlNodeGetContent(_cur)) ) { osrfLogDebug(OSRF_LOG_MARK, "Using source definition '%s' for class %s", content_str, current_class_name ); osrfHashSet( class_def_hash, content_str, "source_definition" ); } } _cur = _cur->next; } // end while } kid = kid->next; } // end while osrfLogInfo(OSRF_LOG_MARK, "...IDL XML parsed"); return idlHash; }
static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name, VARIANT *value) { static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 }; xmlelem *This = impl_from_IXMLElement(iface); xmlChar *val = NULL; TRACE("(%p)->(%s, %p)\n", This, debugstr_w(name), value); if (!value) return E_INVALIDARG; VariantInit(value); V_BSTR(value) = NULL; if (!name) return E_INVALIDARG; /* case for xml:lang attribute */ if (!lstrcmpiW(name, xmllangW)) { xmlNsPtr ns; ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml"); val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href); } else { xmlAttrPtr attr; xmlChar *xml_name; xml_name = xmlchar_from_wchar(name); attr = This->node->properties; while (attr) { BSTR attr_name; attr_name = bstr_from_xmlChar(attr->name); if (!lstrcmpiW(name, attr_name)) { val = xmlNodeListGetString(attr->doc, attr->children, 1); SysFreeString(attr_name); break; } attr = attr->next; SysFreeString(attr_name); } heap_free(xml_name); } if (val) { V_VT(value) = VT_BSTR; V_BSTR(value) = bstr_from_xmlChar(val); } xmlFree(val); TRACE("returning %s\n", debugstr_w(V_BSTR(value))); return (val) ? S_OK : S_FALSE; }
void xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { const xmlChar *ncname; const xmlChar *prefix; const xmlChar *nsUri = NULL; xmlChar *value; xmlNodePtr child; xsltAttrSetPtr set; if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE)) return; value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL); if ((value == NULL) || (*value == 0)) { xsltGenericError(xsltGenericErrorContext, "xsl:attribute-set : name is missing\n"); if (value) xmlFree(value); return; } if (xmlValidateQName(value, 0)) { xsltTransformError(NULL, style, cur, "xsl:attribute-set : The name '%s' is not a valid QName.\n", value); style->errors++; xmlFree(value); return; } ncname = xsltSplitQName(style->dict, value, &prefix); xmlFree(value); value = NULL; if (prefix != NULL) { xmlNsPtr ns = xmlSearchNs(style->doc, cur, prefix); if (ns == NULL) { xsltTransformError(NULL, style, cur, "xsl:attribute-set : No namespace found for QName '%s:%s'\n", prefix, ncname); style->errors++; return; } nsUri = ns->href; } if (style->attributeSets == NULL) { #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "creating attribute set table\n"); #endif style->attributeSets = xmlHashCreate(10); } if (style->attributeSets == NULL) return; set = xmlHashLookup2(style->attributeSets, ncname, nsUri); if (set == NULL) { set = xsltNewAttrSet(); if (set == NULL) return; xmlHashAddEntry2(style->attributeSets, ncname, nsUri, set); } /* * Parse the content. Only xsl:attribute elements are allowed. */ child = cur->children; while (child != NULL) { /* * Report invalid nodes. */ if ((child->type != XML_ELEMENT_NODE) || (child->ns == NULL) || (! IS_XSLT_ELEM(child))) { if (child->type == XML_ELEMENT_NODE) xsltTransformError(NULL, style, child, "xsl:attribute-set : unexpected child %s\n", child->name); else xsltTransformError(NULL, style, child, "xsl:attribute-set : child of unexpected type\n"); } else if (!IS_XSLT_NAME(child, "attribute")) { xsltTransformError(NULL, style, child, "xsl:attribute-set : unexpected child xsl:%s\n", child->name); } else { #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "add attribute to list %s\n", ncname); #endif if (child->psvi == NULL) { xsltTransformError(NULL, style, child, "xsl:attribute-set : internal error, attribute %s not " "compiled\n", child->name); } else { set->attrs = xsltAddAttrElemList(set->attrs, child); } } child = child->next; } /* * Process attribute "use-attribute-sets". */ value = xmlGetNsProp(cur, BAD_CAST "use-attribute-sets", NULL); if (value != NULL) { const xmlChar *curval, *endval; curval = value; while (*curval != 0) { while (IS_BLANK(*curval)) curval++; if (*curval == 0) break; endval = curval; while ((*endval != 0) && (!IS_BLANK(*endval))) endval++; curval = xmlDictLookup(style->dict, curval, endval - curval); if (curval) { const xmlChar *ncname2 = NULL; const xmlChar *prefix2 = NULL; const xmlChar *nsUri2 = NULL; #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "xsl:attribute-set : %s adds use %s\n", ncname, curval); #endif if (xmlValidateQName(curval, 0)) { xsltTransformError(NULL, style, cur, "xsl:attribute-set : The name '%s' in " "use-attribute-sets is not a valid QName.\n", curval); style->errors++; xmlFree(value); return; } ncname2 = xsltSplitQName(style->dict, curval, &prefix2); if (prefix2 != NULL) { xmlNsPtr ns2 = xmlSearchNs(style->doc, cur, prefix2); if (ns2 == NULL) { xsltTransformError(NULL, style, cur, "xsl:attribute-set : No namespace found for QName " "'%s:%s' in use-attribute-sets\n", prefix2, ncname2); style->errors++; xmlFree(value); return; } nsUri2 = ns2->href; } set->useAttrSets = xsltAddUseAttrSetList(set->useAttrSets, ncname2, nsUri2); } curval = endval; } xmlFree(value); value = NULL; } #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "updated attribute list %s\n", ncname); #endif }
/** * xsltNamespaceAlias: * @style: the XSLT stylesheet * @node: the xsl:namespace-alias node * * Read the stylesheet-prefix and result-prefix attributes, register * them as well as the corresponding namespace. */ void xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) { xmlChar *resultPrefix = NULL; xmlChar *stylePrefix = NULL; xmlNsPtr literalNs = NULL; xmlNsPtr targetNs = NULL; #ifdef XSLT_REFACTORED xsltNsAliasPtr alias; if ((style == NULL) || (node == NULL)) return; /* * SPEC XSLT 1.0: * "If a namespace URI is declared to be an alias for multiple * different namespace URIs, then the declaration with the highest * import precedence is used. It is an error if there is more than * one such declaration. An XSLT processor may signal the error; * if it does not signal the error, it must recover by choosing, * from amongst the declarations with the highest import precedence, * the one that occurs last in the stylesheet." * * SPEC TODO: Check for the errors mentioned above. */ /* * NOTE that the XSLT 2.0 also *does* use the NULL namespace if * "#default" is used and there's no default namespace is scope. * I.e., this is *not* an error. * Most XSLT 1.0 implementations work this way. * The XSLT 1.0 spec has nothing to say on the subject. */ /* * Attribute "stylesheet-prefix". */ stylePrefix = xmlGetNsProp(node, (const xmlChar *)"stylesheet-prefix", NULL); if (stylePrefix == NULL) { xsltTransformError(NULL, style, node, "The attribute 'stylesheet-prefix' is missing.\n"); return; } if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default")) literalNs = xmlSearchNs(node->doc, node, NULL); else { literalNs = xmlSearchNs(node->doc, node, stylePrefix); if (literalNs == NULL) { xsltTransformError(NULL, style, node, "Attribute 'stylesheet-prefix': There's no namespace " "declaration in scope for the prefix '%s'.\n", stylePrefix); goto error; } } /* * Attribute "result-prefix". */ resultPrefix = xmlGetNsProp(node, (const xmlChar *)"result-prefix", NULL); if (resultPrefix == NULL) { xsltTransformError(NULL, style, node, "The attribute 'result-prefix' is missing.\n"); goto error; } if (xmlStrEqual(resultPrefix, (const xmlChar *)"#default")) targetNs = xmlSearchNs(node->doc, node, NULL); else { targetNs = xmlSearchNs(node->doc, node, resultPrefix); if (targetNs == NULL) { xsltTransformError(NULL, style, node, "Attribute 'result-prefix': There's no namespace " "declaration in scope for the prefix '%s'.\n", stylePrefix); goto error; } } /* * * Same alias for multiple different target namespace URIs: * TODO: The one with the highest import precedence is used. * Example: * <xsl:namespace-alias stylesheet-prefix="foo" * result-prefix="bar"/> * * <xsl:namespace-alias stylesheet-prefix="foo" * result-prefix="zar"/> * * Same target namespace URI for multiple different aliases: * All alias-definitions will be used. * Example: * <xsl:namespace-alias stylesheet-prefix="bar" * result-prefix="foo"/> * * <xsl:namespace-alias stylesheet-prefix="zar" * result-prefix="foo"/> * Cases using #default: * <xsl:namespace-alias stylesheet-prefix="#default" * result-prefix="#default"/> * TODO: Has this an effect at all? * * <xsl:namespace-alias stylesheet-prefix="foo" * result-prefix="#default"/> * From namespace to no namespace. * * <xsl:namespace-alias stylesheet-prefix="#default" * result-prefix="foo"/> * From no namespace to namespace. */ /* * Store the ns-node in the alias-object. */ alias = xsltNewNsAlias(XSLT_CCTXT(style)); if (alias == NULL) return; alias->literalNs = literalNs; alias->targetNs = targetNs; XSLT_CCTXT(style)->hasNsAliases = 1; #else /* XSLT_REFACTORED */ const xmlChar *literalNsName; const xmlChar *targetNsName; if ((style == NULL) || (node == NULL)) return; stylePrefix = xmlGetNsProp(node, (const xmlChar *)"stylesheet-prefix", NULL); if (stylePrefix == NULL) { xsltTransformError(NULL, style, node, "namespace-alias: stylesheet-prefix attribute missing\n"); return; } resultPrefix = xmlGetNsProp(node, (const xmlChar *)"result-prefix", NULL); if (resultPrefix == NULL) { xsltTransformError(NULL, style, node, "namespace-alias: result-prefix attribute missing\n"); goto error; } if (xmlStrEqual(stylePrefix, (const xmlChar *)"#default")) { literalNs = xmlSearchNs(node->doc, node, NULL); if (literalNs == NULL) { literalNsName = NULL; } else literalNsName = literalNs->href; /* Yes - set for nsAlias table */ } else { literalNs = xmlSearchNs(node->doc, node, stylePrefix); if ((literalNs == NULL) || (literalNs->href == NULL)) { xsltTransformError(NULL, style, node, "namespace-alias: prefix %s not bound to any namespace\n", stylePrefix); goto error; } else literalNsName = literalNs->href; } /* * When "#default" is used for result, if a default namespace has not * been explicitly declared the special value UNDEFINED_DEFAULT_NS is * put into the nsAliases table */ if (xmlStrEqual(resultPrefix, (const xmlChar *)"#default")) { targetNs = xmlSearchNs(node->doc, node, NULL); if (targetNs == NULL) { targetNsName = UNDEFINED_DEFAULT_NS; } else targetNsName = targetNs->href; } else { targetNs = xmlSearchNs(node->doc, node, resultPrefix); if ((targetNs == NULL) || (targetNs->href == NULL)) { xsltTransformError(NULL, style, node, "namespace-alias: prefix %s not bound to any namespace\n", resultPrefix); goto error; } else targetNsName = targetNs->href; } /* * Special case: if #default is used for * the stylesheet-prefix (literal namespace) and there's no default * namespace in scope, we'll use style->defaultAlias for this. */ if (literalNsName == NULL) { if (targetNs != NULL) { /* * BUG TODO: Is it not sufficient to have only 1 field for * this, since subsequently alias declarations will * overwrite this. * Example: * <xsl:namespace-alias result-prefix="foo" * stylesheet-prefix="#default"/> * <xsl:namespace-alias result-prefix="bar" * stylesheet-prefix="#default"/> * The mapping for "foo" won't be visible anymore. */ style->defaultAlias = targetNs->href; } } else { if (style->nsAliases == NULL) style->nsAliases = xmlHashCreate(10); if (style->nsAliases == NULL) { xsltTransformError(NULL, style, node, "namespace-alias: cannot create hash table\n"); goto error; } xmlHashAddEntry((xmlHashTablePtr) style->nsAliases, literalNsName, (void *) targetNsName); } #endif /* else of XSLT_REFACTORED */ error: if (stylePrefix != NULL) xmlFree(stylePrefix); if (resultPrefix != NULL) xmlFree(resultPrefix); }
void xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { const xmlChar *ncname; const xmlChar *prefix; xmlChar *value; xmlNodePtr child; xsltAttrElemPtr attrItems; if ((cur == NULL) || (style == NULL) || (cur->type != XML_ELEMENT_NODE)) return; value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL); if ((value == NULL) || (*value == 0)) { xsltGenericError(xsltGenericErrorContext, "xsl:attribute-set : name is missing\n"); if (value) xmlFree(value); return; } ncname = xsltSplitQName(style->dict, value, &prefix); xmlFree(value); value = NULL; if (style->attributeSets == NULL) { #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "creating attribute set table\n"); #endif style->attributeSets = xmlHashCreate(10); } if (style->attributeSets == NULL) return; attrItems = xmlHashLookup2(style->attributeSets, ncname, prefix); /* * Parse the content. Only xsl:attribute elements are allowed. */ child = cur->children; while (child != NULL) { /* * Report invalid nodes. */ if ((child->type != XML_ELEMENT_NODE) || (child->ns == NULL) || (! IS_XSLT_ELEM(child))) { if (child->type == XML_ELEMENT_NODE) xsltTransformError(NULL, style, child, "xsl:attribute-set : unexpected child %s\n", child->name); else xsltTransformError(NULL, style, child, "xsl:attribute-set : child of unexpected type\n"); } else if (!IS_XSLT_NAME(child, "attribute")) { xsltTransformError(NULL, style, child, "xsl:attribute-set : unexpected child xsl:%s\n", child->name); } else { #ifdef XSLT_REFACTORED xsltAttrElemPtr nextAttr, curAttr; /* * Process xsl:attribute * --------------------- */ #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "add attribute to list %s\n", ncname); #endif /* * The following was taken over from * xsltAddAttrElemList(). */ if (attrItems == NULL) { attrItems = xsltNewAttrElem(child); } else { curAttr = attrItems; while (curAttr != NULL) { nextAttr = curAttr->next; if (curAttr->attr == child) { /* * URGENT TODO: Can somebody explain * why attrItems is set to curAttr * here? Is this somehow related to * avoidance of recursions? */ attrItems = curAttr; goto next_child; } if (curAttr->next == NULL) curAttr->next = xsltNewAttrElem(child); curAttr = nextAttr; } } /* * Parse the xsl:attribute and its content. */ xsltParseAnyXSLTElem(XSLT_CCTXT(style), child); #else #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "add attribute to list %s\n", ncname); #endif /* * OLD behaviour: */ attrItems = xsltAddAttrElemList(attrItems, child); #endif } #ifdef XSLT_REFACTORED next_child: #endif child = child->next; } /* * Process attribue "use-attribute-sets". */ /* TODO check recursion */ value = xmlGetNsProp(cur, (const xmlChar *)"use-attribute-sets", NULL); if (value != NULL) { const xmlChar *curval, *endval; curval = value; while (*curval != 0) { while (IS_BLANK(*curval)) curval++; if (*curval == 0) break; endval = curval; while ((*endval != 0) && (!IS_BLANK(*endval))) endval++; curval = xmlDictLookup(style->dict, curval, endval - curval); if (curval) { const xmlChar *ncname2 = NULL; const xmlChar *prefix2 = NULL; xsltAttrElemPtr refAttrItems; #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "xsl:attribute-set : %s adds use %s\n", ncname, curval); #endif ncname2 = xsltSplitQName(style->dict, curval, &prefix2); refAttrItems = xsltNewAttrElem(NULL); if (refAttrItems != NULL) { refAttrItems->set = ncname2; refAttrItems->ns = prefix2; attrItems = xsltMergeAttrElemList(style, attrItems, refAttrItems); xsltFreeAttrElem(refAttrItems); } } curval = endval; } xmlFree(value); value = NULL; } /* * Update the value */ /* * TODO: Why is this dummy entry needed.? */ if (attrItems == NULL) attrItems = xsltNewAttrElem(NULL); xmlHashUpdateEntry2(style->attributeSets, ncname, prefix, attrItems, NULL); #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "updated attribute list %s\n", ncname); #endif }
char * xml_node_get_attr_value_ns(struct xml_node_ctx *ctx, xml_node_t *node, const char *ns_uri, char *name) { return (char *) xmlGetNsProp((xmlNodePtr) node, (const xmlChar *) name, (const xmlChar *) ns_uri); }