Ejemplo n.º 1
0
//Introduced in DOM Level 2
XMLDeclImpl::XMLDeclImpl(DocumentImpl *ownerDoc, const DOMString &ver,
                         const DOMString &enc, const DOMString &isStd)
	: ChildNode(ownerDoc),
    version ( ver.clone() ),
    encoding ( enc.clone() ),
    standalone ( isStd.clone() )
{
}
Ejemplo n.º 2
0
XERCES_CPP_NAMESPACE_BEGIN


ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImpl *ownerDoc,
                                                     const DOMString &targt,
                                                     const DOMString &dat)
    : ChildNode(ownerDoc)
{
    this->target = targt.clone();
    this->data = dat.clone();
};
Ejemplo n.º 3
0
XERCES_CPP_NAMESPACE_BEGIN


/**
* Notations are how the Document Type Description (DTD) records hints
* about the format of an XML "unparsed entity" -- in other words,
* non-XML data bound to this document type, which some applications
* may wish to consult when manipulating the document. A Notation
* represents a name-value pair, with its nodeName being set to the
* declared name of the notation.
* <P>
* Notations are also used to formally declare the "targets" of
* Processing Instructions.
* <P>
* Note that the Notation's data is non-DOM information; the DOM only
* records what and where it is.
* <P>
* See the XML 1.0 spec, sections 4.7 and 2.6, for more info.
* <P>
* Level 1 of the DOM does not support editing Notation contents.
*
* @author Rania Y. Khalaf
* @author Joseph Kesselman
* @since  PR-DOM-Level-1-19980818.
*/

NotationImpl::NotationImpl(DocumentImpl *ownerDoc, const DOMString &nName)
    : NodeImpl(ownerDoc)
{
    name = nName.clone();
}
Ejemplo n.º 4
0
void ProcessingInstructionImpl::setNodeValue(const DOMString &value)
{
    if (isReadOnly())
        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                               null);
    data = value.clone();
};
Ejemplo n.º 5
0
//Introduced in DOM Level 2
AttrNSImpl::AttrNSImpl(DocumentImpl *ownerDoc,
                       const DOMString &fNamespaceURI,
                       const DOMString &qualifiedName) :
    AttrImpl(ownerDoc, qualifiedName)
{
    DOMString xmlns = NodeImpl::getXmlnsString();
    DOMString xmlnsURI = NodeImpl::getXmlnsURIString();
    this->name = qualifiedName.clone();

    int index = DocumentImpl::indexofQualifiedName(qualifiedName);
    DOMString prefix;
    if (index < 0)
	throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
    bool xmlnsAlone = false;	//true if attribute name is "xmlns"
    if (index == 0) {	//qualifiedName contains no ':'
        if (this->name.equals(xmlns)) {
	    if (!fNamespaceURI.equals(xmlnsURI))
		throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
	    xmlnsAlone = true;
	}
	prefix = null;
	this -> localName = this -> name;
    } else {	//0 < index < this->name.length()-1
	prefix = this->name.substringData(0, index);
	this -> localName =
            this->name.substringData(index+1, this->name.length()-index-1);
    }

    const DOMString& URI = xmlnsAlone ?
        xmlnsURI : mapPrefix(prefix, fNamespaceURI, DOM_Node::ATTRIBUTE_NODE);
    this -> namespaceURI = URI == null ? DOMString(null) : URI.clone();
};
Ejemplo n.º 6
0
XERCES_CPP_NAMESPACE_BEGIN


EntityReferenceImpl::EntityReferenceImpl(DocumentImpl *ownerDoc,
                                         const DOMString &entityName)
    : ParentNode(ownerDoc)
{
    name = entityName.clone();
    // EntityReference behaves as a read-only node, since its contents
    // reflect the Entity it refers to -- but see setNodeName().

    //retrieve the corresponding entity content
    if (ownerDoc) {
        if (ownerDoc->getDoctype()) {
            if (ownerDoc->getDoctype()->getEntities()) {
                EntityImpl* entity = (EntityImpl*)ownerDoc->getDoctype()->getEntities()->getNamedItem(entityName);
                if (entity) {
                    EntityReferenceImpl* refEntity = entity->getEntityRef();
                    if (refEntity)
                        cloneChildren(*refEntity);
                }
            }
        }
    }

    setReadOnly(true, true);
}
Ejemplo n.º 7
0
XERCES_CPP_NAMESPACE_BEGIN


/*
 * The handling of the value field being either the first child node (a
 * ChildNode*) or directly the value (a DOMString) is rather tricky. In the
 * DOMString case we need to get the field in the right type so that the
 * compiler is happy and the appropriate operator gets called. This is
 * essential for the reference counts of the DOMStrings involved to be updated
 * as due.
 * This is consistently achieved by taking the address of the value field and
 * changing it into a DOMString*, and then dereferencing it to get a DOMString.
 * The typical piece of code is:
 * DOMString *x = (DomString *)&value;
 *  ... use of *x which is the DOMString ...
 * This was amended by neilg after memory management was
 * introduced.  Now a union exists which is either a 
 * DOMString * or a ChildNode *.  This will be less efficient
 * (one more dereference per access) but actually works on all the
 * compilers we support.
 */

AttrImpl::AttrImpl(DocumentImpl *ownerDoc, const DOMString &aName)
    : NodeImpl (ownerDoc)
{
    name = aName.clone();
    isSpecified(true);
    hasStringValue(true);
    value.child = null;
};
void CharacterDataImpl::setData(const DOMString &arg)
{
    if (isReadOnly())
        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                               null);
    data = arg.clone();
};
Ejemplo n.º 9
0
void DOMString::insertData(unsigned int offset, const DOMString &src)
{
    unsigned int origStrLength = this->length();
    if (offset > origStrLength)
        throw DOM_DOMException(DOM_DOMException::INDEX_SIZE_ERR, 0);

    if (fHandle == 0)
    {
        *this = src.clone();
        return;
    }

    if (src.fHandle == 0 || src.fHandle->fLength == 0)
        return;

    XMLCh *srcP = src.fHandle->fDSData->fData;
    unsigned int srcLength = src.fHandle->fLength;
    unsigned int newLength = fHandle->fLength + srcLength;
    if (newLength >= fHandle->fDSData->fBufferLength ||
            fHandle->fDSData->fRefCount > 1  || fHandle == src.fHandle )
    {
        // We can't stick the data to be added into the
        //  existing string, either because there is not space in
        //  the buffer, or because the buffer is being shared with
        //  some other string.
        //  So, make a new buffer.

        DOMStringData *newBuf = DOMStringData::allocateBuffer(newLength+1);
        XMLCh *newP  = newBuf->fData;
        XMLCh *oldP   = fHandle->fDSData->fData;
        unsigned int i;
        for (i=0; i<offset; ++i)
            newP[i] = oldP[i];

        for (i=0; i<srcLength; i++)
            newP[i+offset] = srcP[i];

        for (i=offset; i<origStrLength; i++)
            newP[i+srcLength] = oldP[i];

        fHandle->fDSData->removeRef();
        fHandle->fDSData = newBuf;
    }
    else
    {
        // There is room in the already-existing buffer to hold
        //  the data to be inserted.  Insert it.
        //
        XMLCh *destP = fHandle->fDSData->fData;
        int i;
        for (i=(int)origStrLength-1; i>=(int)offset; i--)
            destP[i+srcLength] = destP[i];

        unsigned int j;
        for (j=0; j<srcLength; j++)
            destP[j+offset] = srcP[j];
    }

    fHandle->fLength += srcLength;
}
Ejemplo n.º 10
0
/**
* Change the data content of this PI.
* Note that setNodeValue is aliased to setData
* @see getData().
* @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if node is read-only.
*/
void ProcessingInstructionImpl::setData(const DOMString &arg)
{
    if (isReadOnly())
        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                               null);
    data = arg.clone();
};
Ejemplo n.º 11
0
void NotationImpl::setSystemId(const DOMString &arg)
{
    if(isReadOnly())
        throw DOM_DOMException(
        DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,null);

    systemId = arg.clone();
}
Ejemplo n.º 12
0
XERCES_CPP_NAMESPACE_BEGIN


EntityImpl::EntityImpl(DocumentImpl *ownerDoc, const DOMString &eName)
   : ParentNode(ownerDoc)
{
    name        = eName.clone();
    setReadOnly(true, true);
}
XERCES_CPP_NAMESPACE_BEGIN


CharacterDataImpl::CharacterDataImpl(DocumentImpl *ownerDoc,
                                     const DOMString &dat)
    : ChildNode(ownerDoc)
{
    this->data = dat.clone();
};
Ejemplo n.º 14
0
XERCES_CPP_NAMESPACE_BEGIN



ElementDefinitionImpl::ElementDefinitionImpl(DocumentImpl *ownerDoc,
                                             const DOMString &nam)
    : NodeImpl(ownerDoc)
{
    name = nam.clone();
    attributes = 0;
};
Ejemplo n.º 15
0
XERCES_CPP_NAMESPACE_BEGIN


EntityImpl::EntityImpl(DocumentImpl *ownerDoc, const DOMString &eName)
   : ParentNode(ownerDoc),
	refEntity(0)

{
    name        = eName.clone();
    setReadOnly(true, true);
}   /* SPEC_CPU: removed extra ';' for C++98 standards compliance -- yag */
Ejemplo n.º 16
0
AttrImpl::AttrImpl(const AttrImpl &other, bool deep)
    : NodeImpl(other)
{
    name = other.name.clone();
	
    isSpecified(other.isSpecified());

    /* We must initialize the void* value to null in *all* cases. Failing to do
     * so would cause, in case of assignment to a DOMString later, its content
     * to be derefenced as a DOMString, which would lead the ref count code to
     * be called on something that is not actually a DOMString... Really bad
     * things would then happen!!!
     */
    value.child = null;
    hasStringValue(other.hasStringValue());

    if (other.isIdAttr())
    {
        isIdAttr(true);
        this->getOwnerDocument()->getNodeIDMap()->add(this);
    }

    // take care of case where there are kids
    if (!hasStringValue()) {
        cloneChildren(other);
    }
    else {
        if(other.value.str == null) 
        {
            if(value.str != null)
            {
                *(value.str) = null;
                delete value.str;
                value.str = null;
            }
       }
       else
       {
            // get the address of the value field of this as a DOMString*
            DOMString *x = (value.str == null
                ?(value.str = new (getOwnerDocument()->getMemoryManager()) DOMString())
                :value.str
            );
            // and the address of the value field of other as a DOMString*
            DOMString *y = other.value.str;
            // We can now safely do the cloning and assignement, both operands
            // being a DOMString their ref counts will be updated appropriately
            *x = y->clone();
        }
    }
};
Ejemplo n.º 17
0
XERCES_CPP_NAMESPACE_BEGIN


DocumentTypeImpl::DocumentTypeImpl(DocumentImpl *ownerDoc,
                                   const DOMString &dtName)
    : ParentNode(ownerDoc),
    publicId(null), systemId(null), internalSubset(null) //DOM Level 2
	, intSubsetReading(false)	
{
    name = dtName.clone();
    entities = new NamedNodeMapImpl(this);
    notations = new NamedNodeMapImpl(this);
	elements = new NamedNodeMapImpl(this);

};
Ejemplo n.º 18
0
void AttrImpl::setValue(const DOMString &newvalue)
{
    if (isReadOnly())
    {
        throw DOM_DOMException
        (
            DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null
        );
    }

    //  If this attribute was of type ID and in the map, take it out,
    //    then put it back in with the new name.  For now, we don't worry
    //    about what happens if the new name conflicts
    //
    if (isIdAttr())
        this->getOwnerDocument()->getNodeIDMap()->remove(this);

    if (!hasStringValue() && value.str != null) {
        NodeImpl *kid;
        while ((kid = value.child) != null) { // Remove existing kids
            removeChild(kid);
            if (kid->nodeRefCount == 0)
                NodeImpl::deleteIf(kid);
        }
    }

    // directly store the string as the value by changing the value field
    // into a DOMString
    DOMString *x = (value.str == null 
        ?(value.str = new (getOwnerDocument()->getMemoryManager()) DOMString())
        :value.str
    );
    if (newvalue != null) {
        *x = newvalue.clone();
    }
    else {
        *x = null;
        delete x;
        value.str = null;
    }
    hasStringValue(true);
    isSpecified(true);
    changed();

    if (isIdAttr())
        this->getOwnerDocument()->getNodeIDMap()->add(this);

};
Ejemplo n.º 19
0
//Introduced in DOM Level 2
DocumentTypeImpl::DocumentTypeImpl(DocumentImpl *ownerDoc,
                                   const DOMString &qualifiedName,
                                   const DOMString &pubId,
                                   const DOMString &sysId)
	: ParentNode(ownerDoc),
    publicId(pubId), systemId(sysId), internalSubset(null)
	, intSubsetReading(false)
{
    name = qualifiedName.clone();
    if (DocumentImpl::indexofQualifiedName(qualifiedName) < 0)
        throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);

    entities = new NamedNodeMapImpl(this);
    notations= new NamedNodeMapImpl(this);
	elements = new NamedNodeMapImpl(this);
};
void CharacterDataImpl::setNodeValue(const DOMString &value)
{
    if (isReadOnly())
        throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,
                               null);
    data = value.clone();

    if (this->getOwnerDocument() != null) {
        typedef RefVectorOf<RangeImpl> RangeImpls;
        RangeImpls* ranges = this->getOwnerDocument()->getRanges();
        if (ranges != null) {
            unsigned int sz = ranges->size();
            if (sz != 0) {
                for (unsigned int i =0; i<sz; i++) {
                    ranges->elementAt(i)->receiveReplacedText( this);
                }
            }
        }
    }
};
Ejemplo n.º 21
0
//Introduced in DOM Level 2
ElementNSImpl::ElementNSImpl(DocumentImpl *ownerDoc,
                             const DOMString &fNamespaceURI,
                             const DOMString &qualifiedName) :
    ElementImpl(ownerDoc, qualifiedName)
{
    this->name = qualifiedName.clone();

    int index = DocumentImpl::indexofQualifiedName(qualifiedName);
    DOMString prefix;
    if (index < 0)
	throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null);
    if (index == 0) {	//qualifiedName contains no ':'
        prefix = null;
	this -> localName = this -> name;
    } else {	//0 < index < this->name.length()-1
	prefix = this->name.substringData(0, index);
	this -> localName =
            this->name.substringData(index+1, this->name.length()-index-1);
    }

    const DOMString& URI =
        mapPrefix(prefix, fNamespaceURI, DOM_Node::ELEMENT_NODE);
    this -> namespaceURI = URI == null ? DOMString(null) : URI.clone();
}   /* SPEC_CPU: removed extra ';' for C++98 standards compliance -- yag */
Ejemplo n.º 22
0
void        DocumentTypeImpl::setInternalSubset(const DOMString &value)
{
    if (value == 0)
        return;
    internalSubset = value.clone();
}
Ejemplo n.º 23
0
void        DocumentTypeImpl::setSystemId(const DOMString& value)
{
    if (value == 0)
        return;
    systemId = value.clone();
}
Ejemplo n.º 24
0
void        DocumentTypeImpl::setPublicId(const DOMString& value)
{
    if (value == 0)
        return;
    publicId = value.clone();
}
Ejemplo n.º 25
0
DOMString operator + (const DOMString &lhs, XMLCh rhs)
{
    DOMString retString = lhs.clone();
    retString.appendData(rhs);
    return retString;
}
Ejemplo n.º 26
0
void XMLDeclImpl::setVersion(const DOMString &data)
{
    version = data.clone();
}
Ejemplo n.º 27
0
void XMLDeclImpl::setStandalone(const DOMString &data)
{
    standalone = data.clone();
}
Ejemplo n.º 28
0
void XMLDeclImpl::setEncoding(const DOMString &data)
{
    encoding = data.clone();
}
void      DOM_ProcessingInstruction::setData(const DOMString &data)
{
    ((ProcessingInstructionImpl *)fImpl)->setData(data.clone());
};
Ejemplo n.º 30
0
void      DOM_ProcessingInstruction::setData(const DOMString &data)
{
    ((ProcessingInstructionImpl *)fImpl)->setData(data.clone());
}   /* SPEC_CPU: removed extra ';' for C++98 standards compliance -- yag */