QDomElement KivioBaseTargetStencil::createRootElement( QDomDocument &doc ) { QDomElement e = doc.createElement("KivioPluginStencil"); XmlWriteString( e, "id", m_pSpawner->info()->id() ); XmlWriteString( e, "setId", m_pSpawner->set()->id() ); return e; }
/** * Save this object to an XML element * * @param doc The document to save to * @returns QDomElement representing this object. */ QDomElement KivioShape::saveXML( QDomDocument &doc ) { QDomElement e = doc.createElement("KivioShape"); XmlWriteString( e, "name", m_shapeData.m_name ); XmlWriteInt( e, "shapeType", m_shapeData.m_shapeType ); e.appendChild( m_shapeData.saveXML( doc ) ); return e; }
Boolean XmlWriteElement ( FILE *file, XmlContent *content, XmlDocument *document ) /* Input: content - The element to write to file document - The document to where content appears in Output: file - The element was written to this file Returns: TRUE on succes, otherwise FALSE. Description: This function writes the contents of element to file. */ { XmlAttribute *attribute; XmlContentElement *element; char attrval_surr; element = &(content->data.element); fprintf (file, "<%s", element->type->type); for (attribute = element->attributes->head; attribute != NULL; attribute = attribute->next) { /* Print the name of the attribute */ fprintf (file, " %s=", attribute->name->name); /*** Decide what character will surround the value of the attribute : ***/ if (strchr(attribute->value, '"')) { if (strchr(attribute->value, '\'')) { XmlSetErrorMsg ("Attribute value contains both \" and ' " "character, which is not allowed."); return (FALSE); } attrval_surr = '\''; } else { attrval_surr = '"'; } /* Print the value of the attribute */ fprintf (file, "%c%s%c", attrval_surr, attribute->value, attrval_surr); } if (element->is_empty) { fputs (" />", file); } else { putc ('>', file); level++; /* If the element contains only 1 XmlContent which is a string */ if (element->contents->num_elements == 1 && element->contents->head->type == XmlCType_String) { XmlWriteString (file, element->contents->head, document); } else { putc ('\n', file); if (!XmlWriteContentList(file, element->contents, document)) { return (FALSE); } indent (file, level-1); } level--; fprintf (file, "</%s>", element->type->type); } return (TRUE); }