Esempio n. 1
0
static void
exsltMathMaxFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    xmlNodeSetPtr ns;
    double ret;
    void *user = NULL;

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    
    if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
	user = ctxt->value->user;
	ctxt->value->boolval = 0;
	ctxt->value->user = 0;
    }
    ns = xmlXPathPopNodeSet(ctxt);
    if (xmlXPathCheckError(ctxt))
	return;

    ret = exsltMathMax(ns);

    xmlXPathFreeNodeSet(ns);

    if (user != NULL)
        xmlFreeNodeList((xmlNodePtr)user);
    xmlXPathReturnNumber(ctxt, ret);
}
Esempio n. 2
0
/**
 * exsltMathMinFunction:
 * @ctxt:  an XPath parser context
 * @nargs:  the number of arguments
 *
 * Wraps #exsltMathMin for use by the XPath processor.
 */
static void
exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    xmlNodeSetPtr ns;
    double ret;
    void *user = NULL;

    if (nargs != 1) {
	xsltGenericError(xsltGenericErrorContext,
			 "math:min: invalid number of arguments\n");
	ctxt->error = XPATH_INVALID_ARITY;
	return;
    }
    /* We need to delay the freeing of value->user */
    if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
        user = ctxt->value->user;
	ctxt->value->boolval = 0;
	ctxt->value->user = NULL;
    }
    ns = xmlXPathPopNodeSet(ctxt);
    if (xmlXPathCheckError(ctxt))
	return;

    ret = exsltMathMin(ns);

    xmlXPathFreeNodeSet(ns);
    if (user != NULL)
        xmlFreeNodeList((xmlNodePtr)user);

    xmlXPathReturnNumber(ctxt, ret);
}
Esempio n. 3
0
/**
 * exsltMathLowestFunction:
 * @ctxt:  an XPath parser context
 * @nargs:  the number of arguments
 *
 * Wraps #exsltMathLowest for use by the XPath processor
 */
static void
exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) {
    xmlNodeSetPtr ns, ret;
    void *user = NULL;
    

    if (nargs != 1) {
	xmlXPathSetArityError(ctxt);
	return;
    }

    /* We need to delay the freeing of value->user */
    if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
        user = ctxt->value->user;
	ctxt->value->boolval = 0;
	ctxt->value->user = NULL;
    }
    ns = xmlXPathPopNodeSet(ctxt);
    if (xmlXPathCheckError(ctxt))
	return;

    ret = exsltMathLowest(ns);

    xmlXPathFreeNodeSet(ns);
    if (user != NULL)
        xmlFreeNodeList((xmlNodePtr)user);

    xmlXPathReturnNodeSet(ctxt, ret);
}
Esempio n. 4
0
// -------------------------------------------------------------------------------------
// Sets new value of the attribute. Provided new value will be escaped as needed.
// 
// @param  aNewValue   A string value for the attribute
//
// The new value should not contain entity references. Entity references are not expanded,
// but used as text, because the ampersand (&) character of reference is escaped.
// 
// @see SetRawValueL(TDOMString)
// -------------------------------------------------------------------------------------
//
EXPORT_C void TXmlEngAttr::SetValueL(
    const TDesC8& aNewValue)
    {
    if (!LIBXML_ATTRIBUTE) 
    	{
    	User::Leave(KXmlEngErrNullNode);
    	}
    //
    xmlAttrPtr prop = LIBXML_ATTRIBUTE;
    xmlNodePtr new_ch;
    if (!aNewValue.Length())
        {
        new_ch = NULL;
        }
    else
        {
        xmlChar* value = xmlCharFromDesC8L(aNewValue);
        new_ch = xmlNewText(NULL);
        if(!new_ch)
            {
            delete value;
            OOM_HAPPENED;
            };
        new_ch->content = value;
        new_ch->parent = reinterpret_cast<xmlNodePtr>(prop);
        new_ch->doc = prop->doc;
        }   
    xmlFreeNodeList(prop->children);
    prop->children = new_ch;
    prop->last = new_ch;
    }
Esempio n. 5
0
// -------------------------------------------------------------------------------------
// Sets new value from escaped XML character data that may contain entity references.
//
// The value as if it is an escaped contents from XML file.
// If the value contains entity references, then the resulting
// content of the attribute is a list of TXmlEngTextNode and EntityRefeerence nodes.
// Predefined entities are converted into characters they represent.
//
// @see    TXmlEngAttr::SetValueL(TStringArg)
// -------------------------------------------------------------------------------------
//
EXPORT_C void TXmlEngAttr::SetEscapedValueL(
    const TDesC8& aNewValue)
    {
    if (!LIBXML_ATTRIBUTE) 
    	{
    	User::Leave(KXmlEngErrNullNode);
    	}
    //
    xmlAttrPtr prop = LIBXML_ATTRIBUTE;
    xmlNodePtr new_ch;
    if (!aNewValue.Length())
        {
        prop->last = NULL;
        new_ch = NULL;
        }
    else
        {
        xmlChar* value = xmlCharFromDesC8L(aNewValue);
        new_ch = xmlStringGetNodeList(LIBXML_ATTRIBUTE->doc, value);
        delete value;
        TEST_OOM_FLAG;

        // Set parent property on all child nodes and find pointer to the last node
        xmlNodePtr tmp = new_ch;
        while (tmp)
            {
            tmp->parent = (xmlNodePtr) prop;
            if (!(tmp->next))
                prop->last = tmp;
            tmp = tmp->next;
            }
        }   
    xmlFreeNodeList(prop->children);
    prop->children = new_ch;
    }
Esempio n. 6
0
// -------------------------------------------------------------------------------------
// Sets new attribute value exactly as presented in the string.
//
// Predefined entities are not converted into characters they represent.
//
// @see    TXmlEngAttr::SetValueL()
// -------------------------------------------------------------------------------------
//
EXPORT_C void TXmlEngAttr::SetValueNoEncL( const TDesC8& aNewValue )
    {
    if (!LIBXML_ATTRIBUTE) 
    	{
    	User::Leave(KXmlEngErrNullNode);
    	}
    //
    xmlAttrPtr prop = LIBXML_ATTRIBUTE;
    xmlNodePtr new_ch;
	if (!aNewValue.Length())
        {
        prop->last = NULL;
        new_ch = NULL;
        }
    else
        {
        xmlChar* value = xmlCharFromDesC8L(aNewValue);
        new_ch = xmlNewText(NULL);
        if(!new_ch)
            {
            delete value;
            OOM_HAPPENED;
            };

        new_ch->name = xmlStringTextNoenc;
        new_ch->content = value;
        new_ch->parent = (xmlNodePtr) prop;
       	prop->last = new_ch;
        }   
    xmlFreeNodeList(prop->children);
    prop->children = new_ch;
    }
Esempio n. 7
0
/*
 * call-seq:
 *  value=(content)
 *
 * Set the value for this Attr to +content+
 */
static VALUE set_value(VALUE self, VALUE content)
{
  xmlAttrPtr attr;
  Data_Get_Struct(self, xmlAttr, attr);

  if(attr->children) xmlFreeNodeList(attr->children);

  attr->children = attr->last = NULL;

  if(content) {
    xmlChar *buffer;
    xmlNode *tmp;

    /* Encode our content */
    buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValuePtr(content));

    attr->children = xmlStringGetNodeList(attr->doc, buffer);
    attr->last = NULL;
    tmp = attr->children;

    /* Loop through the children */
    for(tmp = attr->children; tmp; tmp = tmp->next) {
      tmp->parent = (xmlNode *)attr;
      tmp->doc = attr->doc;
      if(tmp->next == NULL) attr->last = tmp;
    }

    /* Free up memory */
    xmlFree(buffer);
  }

  return content;
}
Esempio n. 8
0
/**
 * xmlSecEncCtxReset:
 * @encCtx:             the pointer to <enc:EncryptedData/> processing context.
 *
 * Resets @encCtx object, user settings are not touched.
 */
void
xmlSecEncCtxReset(xmlSecEncCtxPtr encCtx) {
    xmlSecAssert(encCtx != NULL);

    xmlSecTransformCtxReset(&(encCtx->transformCtx));
    xmlSecKeyInfoCtxReset(&(encCtx->keyInfoReadCtx));
    xmlSecKeyInfoCtxReset(&(encCtx->keyInfoWriteCtx));

    encCtx->operation           = xmlSecTransformOperationNone;
    encCtx->result              = NULL;
    encCtx->resultBase64Encoded = 0;
    encCtx->resultReplaced      = 0;
    encCtx->encMethod           = NULL;

    if (encCtx->replacedNodeList != NULL) {
        xmlFreeNodeList(encCtx->replacedNodeList);
        encCtx->replacedNodeList = NULL;
    }

    if(encCtx->encKey != NULL) {
        xmlSecKeyDestroy(encCtx->encKey);
        encCtx->encKey = NULL;
    }

    if(encCtx->id != NULL) {
        xmlFree(encCtx->id);
        encCtx->id = NULL;
    }

    if(encCtx->type != NULL) {
        xmlFree(encCtx->type);
        encCtx->type = NULL;
    }

    if(encCtx->mimeType != NULL) {
        xmlFree(encCtx->mimeType);
        encCtx->mimeType = NULL;
    }

    if(encCtx->encoding != NULL) {
        xmlFree(encCtx->encoding);
        encCtx->encoding = NULL;
    }

    if(encCtx->recipient != NULL) {
        xmlFree(encCtx->recipient);
        encCtx->recipient = NULL;
    }

    if(encCtx->carriedKeyName != NULL) {
        xmlFree(encCtx->carriedKeyName);
        encCtx->carriedKeyName = NULL;
    }

    encCtx->encDataNode = encCtx->encMethodNode =
                              encCtx->keyInfoNode = encCtx->cipherValueNode = NULL;
}
Esempio n. 9
0
static void
free_childs(xmlNodePtr node)
{
  g_return_if_fail(node != NULL);
  
  if (node->xmlChildrenNode)
    xmlFreeNodeList(node->xmlChildrenNode);
  node->xmlChildrenNode = NULL;
  node->last = NULL;
}
Esempio n. 10
0
void XMLElement::setChildren(const XMLNodeList & list) const
{
    xmlNode *n = list.getRealNode();
    if (n && n->parent != node)
    {
        xmlNode *cpy = xmlCopyNodeList(n);
        xmlUnlinkNode(node->children);
        xmlFreeNodeList(node->children);
        node->children = 0;
        xmlAddChildList(node, cpy);
    }
}
Esempio n. 11
0
enum jal_status jal_create_reference_elem(
    const char *reference_uri,
    const char *digest_method,
    uint8_t *digest_buf,
    uint64_t len,
    xmlDocPtr doc,
    xmlNodePtr *elem)
{
    if(!doc || !elem || *elem || len <= 0 || !digest_method || !digest_buf) {
        return JAL_E_XML_CONVERSION;
    }

    xmlChar *namespace_uri = (xmlChar *)JAL_XMLDSIG_URI;
    xmlChar *xml_reference_uri = (xmlChar *)reference_uri;
    xmlChar *xml_digest_method = (xmlChar *)digest_method;

    xmlNodePtr reference_elem = xmlNewDocNode(doc, NULL, (xmlChar *) REFERENCE, NULL);
    xmlNodePtr digestmethod_elem = NULL;
    xmlNodePtr digestvalue_elem = NULL;

    enum jal_status ret = JAL_OK;

    if(reference_uri) {
        xmlURIPtr ret_uri = NULL;
        ret_uri = xmlParseURI(reference_uri);
        if (!ret_uri) {
            ret = JAL_E_INVAL_URI;
            goto err_out;
        }
        xmlFreeURI(ret_uri);
        xmlSetProp(reference_elem, (xmlChar *) URI, xml_reference_uri);
    }

    ret = jal_create_base64_element(doc, digest_buf, len, namespace_uri,
                                    (xmlChar *)DIGESTVALUE, &digestvalue_elem);
    if (ret != JAL_OK) {
        goto err_out;
    }

    digestmethod_elem = xmlNewChild(reference_elem, NULL, (xmlChar *) DIGESTMETHOD, NULL);
    xmlSetProp(digestmethod_elem, (xmlChar *)ALGORITHM, xml_digest_method);

    xmlAddChild(reference_elem, digestvalue_elem);

    *elem = reference_elem;

    return JAL_OK;

err_out:
    xmlFreeNodeList(reference_elem);
    return ret;
}
Esempio n. 12
0
static xmlNodePtr authkey_getxml(const char* username, xmlNsPtr ns, char** msg)
{
	FILE *authfile;
	char *line = NULL, *id, *data;
	xmlNodePtr firstnode = NULL, newnode;
	ssize_t len = 0;
	size_t n = 0;

	/* get authorized_keys file */
	if ((authfile = open_authfile(username, "r", NULL, msg)) == NULL) {
		return (NULL);
	}

	while((len = getline(&line, &n, authfile)) != -1) {
		/* get the second space to locate comment/id */
		id = strchr((data = strchr(line, ' ')) + 1, ' ');

		if (id == NULL) {
			free(line);
			xmlFreeNodeList(firstnode);
			*msg = strdup("Invalid authorized key format.");
			return (NULL);
		}

		/* divide comment/id from data... */
		id[0] = '\0';
		id++;
		/* ... and data from algorithm */
		data[0] = '\0';
		data++;
		/* remove the newline in the end if any */
		if (line[len - 1] == '\n') {
			line[len - 1] = '\0';
		}

		/* create xml data */
		newnode = xmlNewNode(ns, BAD_CAST "authorized-key");
		xmlNewChild(newnode, ns, BAD_CAST "name", BAD_CAST id);
		xmlNewChild(newnode, ns, BAD_CAST "key-data", BAD_CAST data);
		xmlNewChild(newnode, ns, BAD_CAST "algorithm", BAD_CAST line);

		/* prepare returning node list */
		if (firstnode == NULL) {
			firstnode = newnode;
		} else {
			xmlAddSibling(firstnode, newnode);
		}
	}
	free(line);

	return(firstnode);
}
Esempio n. 13
0
/*
 * xmlFreeEntity : clean-up an entity record.
 */
static void
xmlFreeEntity(xmlEntityPtr entity)
{
  xmlDictPtr dict = NULL;

  if (entity == NULL)
    return;

  if (entity->doc != NULL)
    dict = entity->doc->dict;


  if ((entity->children) && (entity->owner == 1) &&
      (entity == (xmlEntityPtr) entity->children->parent))
    xmlFreeNodeList(entity->children);
  if (dict != NULL)
  {
    if ((entity->name != NULL) && (!xmlDictOwns(dict, entity->name)))
      xmlFree((char *) entity->name);
    if ((entity->ExternalID != NULL) &&
        (!xmlDictOwns(dict, entity->ExternalID)))
      xmlFree((char *) entity->ExternalID);
    if ((entity->SystemID != NULL) &&
        (!xmlDictOwns(dict, entity->SystemID)))
      xmlFree((char *) entity->SystemID);
    if ((entity->URI != NULL) && (!xmlDictOwns(dict, entity->URI)))
      xmlFree((char *) entity->URI);
    if ((entity->content != NULL)
        && (!xmlDictOwns(dict, entity->content)))
      xmlFree((char *) entity->content);
    if ((entity->orig != NULL) && (!xmlDictOwns(dict, entity->orig)))
      xmlFree((char *) entity->orig);
  }
  else
  {
    if (entity->name != NULL)
      xmlFree((char *) entity->name);
    if (entity->ExternalID != NULL)
      xmlFree((char *) entity->ExternalID);
    if (entity->SystemID != NULL)
      xmlFree((char *) entity->SystemID);
    if (entity->URI != NULL)
      xmlFree((char *) entity->URI);
    if (entity->content != NULL)
      xmlFree((char *) entity->content);
    if (entity->orig != NULL)
      xmlFree((char *) entity->orig);
  }
  xmlFree(entity);
}
Esempio n. 14
0
/* clones a filter/search rule into a matching vfolder rule
 * (assuming the same system definitions) */
EFilterRule *
vfolder_clone_rule (EMailBackend *backend,
                    EFilterRule *in)
{
	EFilterRule *rule;
	xmlNodePtr xml;

	rule = em_vfolder_rule_new (backend);

	xml = e_filter_rule_xml_encode (in);
	e_filter_rule_xml_decode (rule, xml, (ERuleContext *) context);
	xmlFreeNodeList (xml);

	return rule;
}
Esempio n. 15
0
xmlNodePtr config_unlink_children4(xmlDocPtr pdoc, const char *f1,
					const char *f2, const char *f3, const char *f4)
{
	xmlNodePtr pnode;

	if ((pnode = config_search4(pdoc, f1, f2, f3, f4)) == NULL)
	{
		pnode = config_add_node4(pdoc, f1, f2, f3, f4);
	}
	else if (pnode->children)
	{
		xmlFreeNodeList(pnode->children);
		pnode->children = NULL;
	}
	return pnode;
}
Esempio n. 16
0
/*
 * xmlFreeEntity : clean-up an entity record.
 */
static void xmlFreeEntity(xmlEntityPtr entity) {
    if (entity == NULL) return;

    if ((entity->children) && (entity->owner == 1) &&
	(entity == (xmlEntityPtr) entity->children->parent))
	xmlFreeNodeList(entity->children);
    if (entity->name != NULL)
	xmlFree((char *) entity->name);
    if (entity->ExternalID != NULL)
        xmlFree((char *) entity->ExternalID);
    if (entity->SystemID != NULL)
        xmlFree((char *) entity->SystemID);
    if (entity->URI != NULL)
        xmlFree((char *) entity->URI);
    if (entity->content != NULL)
        xmlFree((char *) entity->content);
    if (entity->orig != NULL)
        xmlFree((char *) entity->orig);
    xmlFree(entity);
}
Esempio n. 17
0
str
BATXMLcontent(bat *ret, const bat *bid)
{
	BAT *b, *bn;
	BUN p, q;
	BATiter bi;
	xmlDocPtr doc;
	xmlNodePtr root;
	size_t size = BUFSIZ;
	str buf = GDKmalloc(size);
	const char *err = OPERATION_FAILED;
	xmlBufferPtr xbuf;

	if (buf == NULL)
		throw(MAL,"xml.content",MAL_MALLOC_FAIL);
	if ((b = BATdescriptor(*bid)) == NULL) {
		GDKfree(buf);
		throw(MAL, "xml.content", INTERNAL_BAT_ACCESS);
	}
	doc = xmlParseMemory("<doc/>", 6);
	root = xmlDocGetRootElement(doc);
	prepareResult(bn, b, TYPE_xml, "content", GDKfree(buf));
	bi = bat_iterator(b);
	xbuf = xmlBufferCreate();
	BATloop(b, p, q) {
		const char *t = (const char *) BUNtail(bi, p);
		size_t len;
		xmlNodePtr elem;
		xmlParserErrors xerr;
		const xmlChar *s;

		if (strNil(t)) {
			bunfastapp(bn, str_nil);
			bn->T->nonil = 0;
			continue;
		}
		len = strlen(t);
		xerr = xmlParseInNodeContext(root, t, (int) len, 0, &elem);
		if (xerr != XML_ERR_OK) {
			err = XML_PARSE_ERROR;
			goto bunins_failed;
		}
		xmlNodeDump(xbuf, doc, elem, 0, 0);
		s = xmlBufferContent(xbuf);
		len = strlen((const char *) s);
		if (len + 2 >= size) {
			GDKfree(buf);
			size = len + 128;
			buf = GDKmalloc(size);
			if (buf == NULL) {
				err = MAL_MALLOC_FAIL;
				goto bunins_failed;
			}
		}
		buf[0] = 'C';
		strcpy(buf + 1, (const char *) s);
		bunfastapp(bn, buf);
		xmlBufferEmpty(xbuf);
		xmlFreeNodeList(elem);
	}
	xmlBufferFree(xbuf);
	xmlFreeDoc(doc);
	GDKfree(buf);
	finalizeResult(ret, bn, b);
	return MAL_SUCCEED;
  bunins_failed:
	xmlBufferFree(xbuf);
	xmlFreeDoc(doc);
	if (buf != NULL)
		GDKfree(buf);
	BBPunfix(b->batCacheid);
	BBPunfix(bn->batCacheid);
	throw(MAL, "xml.document", "%s", err);
}
/**
 * \brief Serializes a \c LIGOTimeGPS structure into a VOTable XML %node
 *
 * This function takes a \c LIGOTimeGPS structure and serializes it into a VOTable
 * \c RESOURCE %node identified by the given name. The returned \c xmlNode can then be
 * embedded into an existing %node hierarchy or turned into a full VOTable document.
 *
 * \param ltg [in] Pointer to the \c LIGOTimeGPS structure to be serialized
 * \param name [in] Unique identifier of this particular \c LIGOTimeGPS structure instance
 *
 * \return A pointer to a \c xmlNode that holds the VOTable fragment that represents
 * the \c LIGOTimeGPS structure.
 * In case of an error, a null-pointer is returned.\n
 * \b Important: the caller is responsible to free the allocated memory (when the
 * fragment isn't needed anymore) using \c xmlFreeNode. Alternatively, \c xmlFreeDoc
 * can be used later on when the returned fragment has been embedded in a XML document.
 *
 * \sa XLALCreateVOTParamNode
 * \sa XLALCreateVOTResourceNode
 * \sa XLALCreateVOTDocumentFromTree
 *
 * \author Oliver Bock\n
 * Albert-Einstein-Institute Hannover, Germany
 */
xmlNodePtr XLALLIGOTimeGPS2VOTNode(const LIGOTimeGPS *const ltg, const char *name)
{
    /* set up local variables */
    xmlNodePtr xmlParentNode = NULL;
    xmlNodePtr xmlChildNode = NULL;
    xmlNodePtr xmlChildNodeList = NULL;

    CHAR gpsSecondsBuffer[INT4STR_MAXLEN] = {0};
    CHAR gpsNanoSecondsBuffer[INT4STR_MAXLEN] = {0};

    /* check and prepare input parameters */
    if(!ltg || snprintf(gpsSecondsBuffer, INT4STR_MAXLEN, "%i", ltg->gpsSeconds) < 0) {
        XLALPrintError("Invalid input parameter: LIGOTimeGPS->gpsSeconds\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    if(!ltg || snprintf(gpsNanoSecondsBuffer, INT4STR_MAXLEN, "%i", ltg->gpsNanoSeconds) < 0) {
        XLALPrintError("Invalid input parameter: LIGOTimeGPS->gpsNanoSeconds\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    if(!name || strlen(name) <= 0) {
        XLALPrintError("Invalid input parameter: name\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }

    /* set up RESOURCE node child (first PARAM) */
    xmlChildNode = XLALCreateVOTParamNode("gpsSeconds",
                                          "s",
                                          VOT_INT4,
                                          NULL,
                                          gpsSecondsBuffer);
    if(!xmlChildNode) {
        XLALPrintError("Couldn't create PARAM node: , %s.gpsSeconds\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* initialize child node list with first child */
    xmlChildNodeList = xmlChildNode;

    /* set up RESOURCE node child (second PARAM) */
    xmlChildNode = XLALCreateVOTParamNode("gpsNanoSeconds",
                                          "ns",
                                          VOT_INT4,
                                          NULL,
                                          gpsNanoSecondsBuffer);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.gpsNanoSeconds\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as first sibling to child node list */
    xmlChildNodeList->next = xmlChildNode;

    /* set up RESOURCE node*/
    xmlParentNode = XLALCreateVOTResourceNode("LIGOTimeGPS", name, xmlChildNodeList);
    if(!xmlParentNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create RESOURCE node: %s\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* return RESOURCE node (needs to be xmlFreeNode'd or xmlFreeDoc'd by caller!!!) */
    return xmlParentNode;
}
Esempio n. 19
0
/**
 * xsltAttrTemplateProcess:
 * @ctxt:  the XSLT transformation context
 * @target:  the element where the attribute will be grafted
 * @attr:  the attribute node of a literal result element
 *
 * Process one attribute of a Literal Result Element (in the stylesheet).
 * Evaluates Attribute Value Templates and copies the attribute over to
 * the result element.
 * This does *not* process attribute sets (xsl:use-attribute-set).
 * 
 *
 * Returns the generated attribute node.
 */
xmlAttrPtr
xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
	                xmlAttrPtr attr)
{
    const xmlChar *value;
    xmlAttrPtr ret;

    if ((ctxt == NULL) || (attr == NULL) || (target == NULL))
	return(NULL);
    
    if (attr->type != XML_ATTRIBUTE_NODE)
	return(NULL);

    /*
    * Skip all XSLT attributes.
    */
#ifdef XSLT_REFACTORED    
    if (attr->psvi == xsltXSLTAttrMarker)
	return(NULL);
#else
    if ((attr->ns != NULL) && xmlStrEqual(attr->ns->href, XSLT_NAMESPACE))
	return(NULL);
#endif
    /*
    * Get the value.
    */
    if (attr->children != NULL) {
	if ((attr->children->type != XML_TEXT_NODE) ||
	    (attr->children->next != NULL))
	{
	    xsltTransformError(ctxt, NULL, attr->parent,
		"Internal error: The children of an attribute node of a "
		"literal result element are not in the expected form.\n");
	    return(NULL);
	}
	value = attr->children->content;
	if (value == NULL)
	    value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
    } else
	value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
    /*
    * Overwrite duplicates.
    */
    ret = target->properties;
    while (ret != NULL) {
        if (((attr->ns != NULL) == (ret->ns != NULL)) &&
	    xmlStrEqual(ret->name, attr->name) &&
	    ((attr->ns == NULL) || xmlStrEqual(ret->ns->href, attr->ns->href)))
	{
	    break;
	}
        ret = ret->next;
    }
    if (ret != NULL) {	
        /* free the existing value */
	xmlFreeNodeList(ret->children);
	ret->children = ret->last = NULL;
	/*
	* Adjust ns-prefix if needed.
	*/
	if ((ret->ns != NULL) &&
	    (! xmlStrEqual(ret->ns->prefix, attr->ns->prefix)))
	{
	    ret->ns = xsltGetNamespace(ctxt, attr->parent, attr->ns, target);
	}
    } else {
        /* create a new attribute */
	if (attr->ns != NULL)
	    ret = xmlNewNsProp(target,
		xsltGetNamespace(ctxt, attr->parent, attr->ns, target),
		    attr->name, NULL);
	else
	    ret = xmlNewNsProp(target, NULL, attr->name, NULL);	
    }
    /*
    * Set the value.
    */
    if (ret != NULL) {
        xmlNodePtr text;

        text = xmlNewText(NULL);
	if (text != NULL) {
	    ret->last = ret->children = text;
	    text->parent = (xmlNodePtr) ret;
	    text->doc = ret->doc;

	    if (attr->psvi != NULL) {
		/*
		* Evaluate the Attribute Value Template.
		*/
		xmlChar *val;
		val = xsltEvalAVT(ctxt, attr->psvi, attr->parent);
		if (val == NULL) {
		    /*
		    * TODO: Damn, we need an easy mechanism to report
		    * qualified names!
		    */
		    if (attr->ns) {
			xsltTransformError(ctxt, NULL, attr->parent,
			    "Internal error: Failed to evaluate the AVT "
			    "of attribute '{%s}%s'.\n",
			    attr->ns->href, attr->name);
		    } else {
			xsltTransformError(ctxt, NULL, attr->parent,
			    "Internal error: Failed to evaluate the AVT "
			    "of attribute '%s'.\n",
			    attr->name);
		    }
		    text->content = xmlStrdup(BAD_CAST "");
		} else {
		    text->content = val;
		}
	    } else if ((ctxt->internalized) && (target != NULL) &&
	               (target->doc != NULL) &&
		       (target->doc->dict == ctxt->dict) &&
		       xmlDictOwns(ctxt->dict, value)) {
		text->content = (xmlChar *) value;
	    } else {
		text->content = xmlStrdup(value);
	    }
	}
    } else {
	if (attr->ns) {
	    xsltTransformError(ctxt, NULL, attr->parent,
	    	"Internal error: Failed to create attribute '{%s}%s'.\n",
		attr->ns->href, attr->name);
	} else {
	    xsltTransformError(ctxt, NULL, attr->parent,
	    	"Internal error: Failed to create attribute '%s'.\n",
		attr->name);
	}
    }
    return(ret);
}
Esempio n. 20
0
bool FArchiveXML::LoadFromExtraSceneNode(FCDSceneNode* sceneNode)
{
	bool status = true;

	FCDENodeList parameterNodes;
	StringList parameterNames;

	// Retrieve the extra information from the base entity class
	FCDExtra* extra = sceneNode->GetExtra();

	// List all the parameters
	size_t techniqueCount = extra->GetDefaultType()->GetTechniqueCount();
	for (size_t i = 0; i < techniqueCount; ++i)
	{
		FCDETechnique* technique = extra->GetDefaultType()->GetTechnique(i);
		technique->FindParameters(parameterNodes, parameterNames);
	}

	// Process the known parameters
	size_t parameterCount = parameterNodes.size();
	for (size_t i = 0; i < parameterCount; ++i)
	{
		FCDENode* parameterNode = parameterNodes[i];
		const fm::string& parameterName = parameterNames[i];
		FCDEAttribute* parameterType = parameterNode->FindAttribute(DAE_TYPE_ATTRIBUTE);
		if (parameterName == DAEMAYA_STARTTIME_PARAMETER)
		{
			sceneNode->GetDocument()->SetStartTime(FUStringConversion::ToFloat(parameterNode->GetContent()));
		}
		else if (parameterName == DAEMAYA_ENDTIME_PARAMETER)
		{
			sceneNode->GetDocument()->SetEndTime(FUStringConversion::ToFloat(parameterNode->GetContent()));
		}
		else if (parameterName == DAEFC_VISIBILITY_PARAMETER)
		{
			sceneNode->SetVisibility(FUStringConversion::ToBoolean(parameterNode->GetContent()));
			if (parameterNode->GetAnimated()->HasCurve())
			{
				parameterNode->GetAnimated()->Clone(sceneNode->GetVisibility().GetAnimated());
			}
		}
		else if (parameterName == DAEMAYA_LAYER_PARAMETER || (parameterType != NULL && FUStringConversion::ToString(parameterType->GetValue()) == DAEMAYA_LAYER_PARAMETER))
		{
			FCDEAttribute* nameAttribute = parameterNode->FindAttribute(DAE_NAME_ATTRIBUTE);
			if (nameAttribute == NULL) continue;

			// Create a new layer object list
			FCDLayerList& layers = sceneNode->GetDocument()->GetLayers();
			FCDLayer* layer = new FCDLayer(); layers.push_back(layer);

			// Parse in the layer
			layer->name = FUStringConversion::ToString(nameAttribute->GetValue());
			FUStringConversion::ToStringList(parameterNode->GetContent(), layer->objects);
		}
		else continue;

		SAFE_RELEASE(parameterNode);
	}

	// Read in the extra instances from the typed extra.
	FCDEType* instancesExtra = extra->FindType(DAEFC_INSTANCES_TYPE);
	if (instancesExtra != NULL)
	{
		FCDETechnique* fcolladaTechnique = instancesExtra->FindTechnique(DAE_FCOLLADA_PROFILE);
		if (fcolladaTechnique != NULL)
		{
			FCDENodeList nodesToRelease;
			size_t childNodeCount = fcolladaTechnique->GetChildNodeCount();
			for (size_t c = 0; c < childNodeCount; ++c)
			{
				FCDENode* node = fcolladaTechnique->GetChildNode(c);
				xmlNode* baseNode = FUXmlWriter::CreateNode("_temp_");
				xmlNode* instanceNode = FArchiveXML::LetWriteObject(node, baseNode);

				uint32 instanceType = FArchiveXML::GetEntityInstanceType(instanceNode);
				if (instanceType == (uint32) ~0)
				{
					status = false;
				}
				else
				{
					FCDEntityInstance* instance = sceneNode->AddInstance((FCDEntity::Type) instanceType);
					status &= (FArchiveXML::LoadSwitch(instance, &instance->GetObjectType(), instanceNode));
					nodesToRelease.push_back(node);
				}

				xmlFreeNodeList(baseNode);
			}
			CLEAR_POINTER_VECTOR(nodesToRelease);
		}
	}
 
	sceneNode->SetDirtyFlag();
	return status;
}
/**
 * \brief Serializes a \c PulsarDopplerParams structure into a VOTable XML %node
 *
 * This function takes a \c PulsarDopplerParams structure and serializes it into a VOTable
 * \c RESOURCE %node identified by the given name. The returned \c xmlNode can then be
 * embedded into an existing %node hierarchy or turned into a full VOTable document.
 *
 * \param pdp [in] Pointer to the \c PulsarDopplerParams structure to be serialized
 * \param name [in] Unique identifier of this particular \c PulsarDopplerParams structure instance
 *
 * \return A pointer to a \c xmlNode that holds the VOTable fragment that represents
 * the \c PulsarDopplerParams structure.
 * In case of an error, a null-pointer is returned.\n
 * \b Important: the caller is responsible to free the allocated memory (when the
 * fragment isn't needed anymore) using \c xmlFreeNode. Alternatively, \c xmlFreeDoc
 * can be used later on when the returned fragment has been embedded in a XML document.
 *
 * \sa XLALCreateVOTParamNode
 * \sa XLALCreateVOTResourceNode
 * \sa XLALCreateVOTDocumentFromTree
 *
 * \author Oliver Bock\n
 * Albert-Einstein-Institute Hannover, Germany
 */
xmlNodePtr XLALPulsarDopplerParams2VOTNode(const PulsarDopplerParams *const pdp, const char *name)
{
    /* set up local variables */
    xmlNodePtr xmlParentNode = NULL;
    xmlNodePtr xmlChildNode = NULL;
    xmlNodePtr xmlChildNodeList = NULL;
    xmlNodePtr xmlCurrentChildNode = NULL;

    /* check and convert input parameters */
    XLAL_CHECK_NULL ( pdp != NULL, XLAL_EINVAL );

    CHAR Alpha[REAL8STR_MAXLEN] = {0};
    if( snprintf(Alpha, REAL8STR_MAXLEN, "%g", pdp->Alpha) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->Alpha\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    CHAR Delta[REAL8STR_MAXLEN] = {0};
    if( snprintf(Delta, REAL8STR_MAXLEN, "%g", pdp->Delta) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->Delta\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    CHAR argp[REAL8STR_MAXLEN] = {0};
    if( snprintf(argp, REAL8STR_MAXLEN, "%g", pdp->argp) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->argp\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    CHAR asini[REAL8STR_MAXLEN] = {0};
    if( snprintf(asini, REAL8STR_MAXLEN, "%g", pdp->asini) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->asini\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    CHAR ecc[REAL8STR_MAXLEN] = {0};
    if( snprintf(ecc, REAL8STR_MAXLEN, "%g", pdp->ecc) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->ecc\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }
    CHAR period[REAL8STR_MAXLEN] = {0};
    if( snprintf(period, REAL8STR_MAXLEN, "%g", pdp->period) < 0) {
        XLALPrintError("Invalid input parameter: PulsarDopplerParams->period\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }

    if(!name || strlen(name) <= 0) {
        XLALPrintError("Invalid input parameter: name\n");
        XLAL_ERROR_NULL(XLAL_EINVAL);
    }

    /* ----- set up PARAM node (Alpha) */
    xmlChildNode = XLALCreateVOTParamNode("Alpha",
                                          "rad",
                                          VOT_REAL8,
                                          NULL,
                                          Alpha);
    if(!xmlChildNode) {
        XLALPrintError("Couldn't create PARAM node: %s.Alpha\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* initialize child node list with first child */
    xmlChildNodeList = xmlChildNode;
    xmlCurrentChildNode = xmlChildNodeList;

    /* ----- set up PARAM node (Delta) */
    xmlChildNode = XLALCreateVOTParamNode("Delta",
                                          "rad",
                                          VOT_REAL8,
                                          NULL,
                                          Delta);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.Delta\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    /* ----- set up PARAM node (fkdot) */
    xmlChildNode = XLALPulsarSpins2VOTNode(&pdp->fkdot, "fkdot");
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.fkdot\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    // ---------- handle binary-orbital parameters ----------
    /* ----- set up PARAM node (argp) */
    xmlChildNode = XLALCreateVOTParamNode("argp",
                                          "rad",
                                          VOT_REAL8,
                                          NULL,
                                          argp);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.argp\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    /* ----- set up PARAM node (asini) */
    xmlChildNode = XLALCreateVOTParamNode("asini",
                                          "s",
                                          VOT_REAL8,
                                          NULL,
                                          asini);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.asini\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }


    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    /* ----- set up PARAM node (ecc) */
    xmlChildNode = XLALCreateVOTParamNode("ecc",
                                          NULL,
                                          VOT_REAL8,
                                          NULL,
                                          ecc);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.ecc\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    /* ----- set up PARAM node (period) */
    xmlChildNode = XLALCreateVOTParamNode("period",
                                          "s",
                                          VOT_REAL8,
                                          NULL,
                                          period);
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create PARAM node: %s.period\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;

    /* ----- set up RESOURCE node (refTime)*/
    xmlChildNode = XLALLIGOTimeGPS2VOTNode(&pdp->refTime, "refTime" );
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create RESOURCE node: %s.refTime\n", name );
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;


     /* ----- set up RESOURCE node (tp)*/
    xmlChildNode = XLALLIGOTimeGPS2VOTNode(&pdp->tp, "tp");
    if(!xmlChildNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create RESOURCE node: tp\n");
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* add child as next sibling to child node list */
    xmlCurrentChildNode->next = xmlChildNode;
    xmlCurrentChildNode = xmlCurrentChildNode->next;
    // ---------- END: binary-orbital parameters ----------

    /* set up parent RESOURCE node*/
    xmlParentNode = XLALCreateVOTResourceNode("PulsarDopplerParams", name, xmlChildNodeList);
    if(!xmlParentNode) {
        /* clean up */
        xmlFreeNodeList(xmlChildNodeList);
        XLALPrintError("Couldn't create RESOURCE node: %s\n", name);
        XLAL_ERROR_NULL(XLAL_EFAILED);
    }

    /* return RESOURCE node (needs to be xmlFreeNode'd or xmlFreeDoc'd by caller!!!) */
    return xmlParentNode;

} // XLALPulsarDopplerParams2VOTNode()
Esempio n. 22
0
str
BATXMLxmltext(bat *ret, const bat *bid)
{
	BAT *b, *bn;
	BUN p, q;
	BATiter bi;
	size_t size = 0;
	str buf = NULL;
	xmlDocPtr doc = NULL;
	xmlNodePtr elem;
	str content = NULL;
	const char *err = OPERATION_FAILED;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "xml.text", INTERNAL_BAT_ACCESS);
	prepareResult(bn, b, TYPE_str, "text", (void) 0);
	bi = bat_iterator(b);
	BATloop(b, p, q) {
		const char *t = (const char *) BUNtail(bi, p);
		size_t len;

		if (strNil(t)) {
			bunfastapp(bn, t);
			bn->T->nonil = 0;
			continue;
		}
		len = strlen(t);
		switch (*t) {
		case 'D': {
			xmlDocPtr d = xmlParseMemory(t + 1, (int) (len - 1));
			elem = xmlDocGetRootElement(d);
			content = (str) xmlNodeGetContent(elem);
			xmlFreeDoc(d);
			if (content == NULL) {
				err = MAL_MALLOC_FAIL;
				goto bunins_failed;
			}
			break;
		}
		case 'C':
			if (doc == NULL)
				doc = xmlParseMemory("<doc/>", 6);
			xmlParseInNodeContext(xmlDocGetRootElement(doc), t + 1, (int) (len - 1), 0, &elem);
			content = (str) xmlNodeGetContent(elem);
			xmlFreeNodeList(elem);
			if (content == NULL) {
				err = MAL_MALLOC_FAIL;
				goto bunins_failed;
			}
			break;
		case 'A': {
			str s;

			if (buf == NULL || size < len) {
				size = len + 128;
				if (buf != NULL)
					GDKfree(buf);
				buf = GDKmalloc(size);
				if (buf == NULL) {
					err = MAL_MALLOC_FAIL;
					goto bunins_failed;
				}
			}
			s = buf;
			t++;
			while (*t) {
				if (*t == '"' || *t == '\'') {
					char q = *t++;

					s += XMLunquotestring(&t, q, s);
				}
				t++;
			}
			*s = 0;
			break;
		}
		default:
			assert(*t == 'A' || *t == 'C' || *t == 'D');
			bunfastapp(bn, str_nil);
			bn->T->nonil = 0;
			continue;
		}
		assert(content != NULL || buf != NULL);
		bunfastapp(bn, content != NULL ? content : buf);
		if (content != NULL)
			GDKfree(content);
		content = NULL;
	}
	finalizeResult(ret, bn, b);
	if (buf != NULL)
		GDKfree(buf);
	if (doc != NULL)
		xmlFreeDoc(doc);
	return MAL_SUCCEED;
  bunins_failed:
	BBPunfix(b->batCacheid);
	BBPunfix(bn->batCacheid);
	if (buf != NULL)
		GDKfree(buf);
	if (doc != NULL)
		xmlFreeDoc(doc);
	if (content != NULL)
		GDKfree(content);
	throw(MAL, "xml.text", "%s", err);
}
/**
 * xsltAttrTemplateProcess:
 * @ctxt:  the XSLT transformation context
 * @target:  the result node
 * @cur:  the attribute template node
 *
 * Process the given attribute and return the new processed copy.
 *
 * Returns the attribute replacement.
 */
xmlAttrPtr
xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
	                xmlAttrPtr cur) {
    const xmlChar *value;
    xmlNsPtr ns;
    xmlAttrPtr ret;
    if ((ctxt == NULL) || (cur == NULL) || (target == NULL))
	return(NULL);
    
    if (cur->type != XML_ATTRIBUTE_NODE)
	return(NULL);

    if ((cur->children == NULL) || (cur->children->type != XML_TEXT_NODE) ||
        (cur->children->next != NULL)) {
	xsltTransformError(ctxt, NULL, cur->parent,
		"attribute %s content problem\n", cur->name);
        return(NULL);
    }
    value = cur->children->content;
    if (value == NULL)
        value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0);
    if ((cur->ns != NULL) &&
	(xmlStrEqual(cur->ns->href, XSLT_NAMESPACE))) {
	if (xmlStrEqual(cur->name, (const xmlChar *)"use-attribute-sets")) {
	    xsltApplyAttributeSet(ctxt, ctxt->node, NULL, value);
	}
	return(NULL);
    }

    ret = target->properties;
    while (ret != NULL) {
        if (xmlStrEqual(ret->name, cur->name)) {
	    if (cur->ns == NULL) {
	        if (ret->ns == NULL)
		    break;
	    } else {
	        if ((ret->ns != NULL) &&
		    (xmlStrEqual(ret->ns->href, cur->ns->href)))
		    break;
	    }
	}
        ret = ret->next;
    }
    if (ret != NULL) {
        /* free the existing value */
	xmlFreeNodeList(ret->children);
	ret->children = ret->last = NULL;
    } else {
        /* create a new attribute */
	if (cur->ns != NULL)
	    ns = xsltGetPlainNamespace(ctxt, cur->parent, cur->ns, target);
	else
	    ns = NULL;
	ret = xmlNewNsProp(target, ns, cur->name, NULL);
    }
    if (ret != NULL) {
        xmlNodePtr text;

        text = xmlNewText(NULL);
	if (text != NULL) {
	    ret->last = ret->children = text;
	    text->parent = (xmlNodePtr) ret;
	    text->doc = ret->doc;
	    if (cur->psvi != NULL) {
		xmlChar *val;
		val = xsltEvalAVT(ctxt, cur->psvi, cur->parent);
		if (val == NULL) {
		    text->content = xmlStrdup(BAD_CAST "runtime error");
		} else {
		    text->content = val;
		}
	    } else if ((ctxt->internalized) && (target != NULL) &&
	               (target->doc != NULL) &&
		       (target->doc->dict == ctxt->dict)) {
		text->content = (xmlChar *) value;
	    } else {
		text->content = xmlStrdup(value);
	    }
	}
    } else {
	xsltTransformError(ctxt, NULL, cur->parent,
		"Failed to create attribute %s\n", cur->name);
    }
    return(ret);
}