예제 #1
0
    //####################################################################
    phantom_attr* find_default_prop (xmlNodePtr xmlnode,
                                     const char *name, const ns *nspace) {
        if (xmlnode->doc != 0) {
            xmlAttributePtr dtd_attr = 0;
            const xmlChar* prefix = 0;

            if (nspace && strlen(nspace->get_prefix()) > 0)
                prefix = reinterpret_cast<const xmlChar*>(nspace->get_prefix());

            if (xmlnode->doc->intSubset != 0) {
                if (nspace)
                    dtd_attr = xmlGetDtdQAttrDesc(xmlnode->doc->intSubset,
                                                  xmlnode->name,
                                                  reinterpret_cast<const xmlChar*>(name),
                                                  prefix);
                else
                    dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->intSubset,
                                                 xmlnode->name,
                                                 reinterpret_cast<const xmlChar*>(name));
            }

            if (dtd_attr == 0 && xmlnode->doc->extSubset != 0) {
                if (nspace)
                    dtd_attr = xmlGetDtdQAttrDesc(xmlnode->doc->extSubset,
                                                  xmlnode->name,
                                                  reinterpret_cast<const xmlChar*>(name),
                                                  prefix);
                else
                    dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->extSubset,
                                                 xmlnode->name,
                                                 reinterpret_cast<const xmlChar*>(name));
            }

            if (dtd_attr != 0 && dtd_attr->defaultValue != 0) {

                node_private_data *  node_data = attach_node_private_data(xmlnode);


                // Found, now check the phantom attributes list attached to the
                // node
                phantom_attr *  current = node_data->phantom_attrs_;
                while (current != NULL) {
                    if (current->def_prop_ == dtd_attr)
                        return current;
                    current = current->next;
                }

                // Not found. Create a new phantom_attr structure
                phantom_attr *  new_phantom = new phantom_attr;
                memset( new_phantom, 0, sizeof( phantom_attr ) );
                new_phantom->def_prop_ = dtd_attr;

                current = node_data->phantom_attrs_;
                new_phantom->next = current;
                node_data->phantom_attrs_ = new_phantom;
                return new_phantom;
            }
        }
        return NULL;
    }
예제 #2
0
        void *  get_ptr_to_attr_instance(void *  att)
        {
            attributes::attr *  att_ptr = static_cast<attributes::attr *>(att);
            node_private_data * node_data = attach_node_private_data(
                                                        att_ptr->get_node());
            attr_instance *     current = node_data->attr_instances_;

            while (current != NULL)
            {
                if (*att_ptr == current->attr_)
                    return & current->attr_;
                current = current->next;
            }

            // Not found, so insert a new node to the head
            attr_instance *     new_attr_instance = new attr_instance(*att_ptr);

            new_attr_instance->next = node_data->attr_instances_;
            node_data->attr_instances_ = new_attr_instance;
            return & new_attr_instance->attr_;
        }