update dev300-m58
[ooovba.git] / unoxml / source / dom / element.cxx
blob8de5e3632e86e1bae65f274c44669a2a55ce0a53
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: element.cxx,v $
10 * $Revision: 1.14.20.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "node.hxx"
32 #include "element.hxx"
33 #include "attr.hxx"
34 #include "elementlist.hxx"
35 #include "attributesmap.hxx"
36 #include "../events/mutationevent.hxx"
38 #include "comphelper/attributelist.hxx"
39 #include <com/sun/star/xml/sax/FastToken.hdl>
41 #include <string.h>
44 namespace DOM
47 CElement::CElement(const xmlNodePtr aNodePtr)
49 m_aNodeType = NodeType_ELEMENT_NODE;
50 init_node(aNodePtr);
53 void SAL_CALL CElement::saxify(
54 const Reference< XDocumentHandler >& i_xHandler) {
55 if (!i_xHandler.is()) throw RuntimeException();
56 comphelper::AttributeList *pAttrs =
57 new comphelper::AttributeList();
58 OUString type = OUString::createFromAscii("");
59 // add namespace definitions to attributes
60 for (xmlNsPtr pNs = m_aNodePtr->nsDef; pNs != 0; pNs = pNs->next) {
61 const xmlChar *pPrefix = pNs->prefix;
62 OUString prefix(reinterpret_cast<const sal_Char*>(pPrefix),
63 strlen(reinterpret_cast<const char*>(pPrefix)),
64 RTL_TEXTENCODING_UTF8);
65 OUString name = (prefix.equalsAscii(""))
66 ? OUString::createFromAscii("xmlns")
67 : OUString::createFromAscii("xmlns:") + prefix;
68 const xmlChar *pHref = pNs->href;
69 OUString val(reinterpret_cast<const sal_Char*>(pHref),
70 strlen(reinterpret_cast<const char*>(pHref)),
71 RTL_TEXTENCODING_UTF8);
72 pAttrs->AddAttribute(name, type, val);
74 // add attributes
75 for (xmlAttrPtr pAttr = m_aNodePtr->properties;
76 pAttr != 0; pAttr = pAttr->next) {
77 CNode * pNode = CNode::get(reinterpret_cast<xmlNodePtr>(pAttr));
78 OSL_ENSURE(pNode != 0, "CNode::get returned 0");
79 OUString prefix = pNode->getPrefix();
80 OUString name = (prefix.getLength() == 0)
81 ? pNode->getLocalName()
82 : prefix + OUString(static_cast<sal_Unicode>(':')) + pNode->getLocalName();
83 OUString val = pNode->getNodeValue();
84 pAttrs->AddAttribute(name, type, val);
86 OUString prefix = getPrefix();
87 OUString name = (prefix.getLength() == 0)
88 ? getLocalName()
89 : prefix + OUString(static_cast<sal_Unicode>(':')) + getLocalName();
90 Reference< XAttributeList > xAttrList(pAttrs);
91 i_xHandler->startElement(name, xAttrList);
92 // recurse
93 for (xmlNodePtr pChild = m_aNodePtr->children;
94 pChild != 0; pChild = pChild->next) {
95 CNode * pNode = CNode::get(pChild);
96 OSL_ENSURE(pNode != 0, "CNode::get returned 0");
97 pNode->saxify(i_xHandler);
99 i_xHandler->endElement(name);
102 void SAL_CALL CElement::fastSaxify( Context& i_rContext ) {
103 if (!i_rContext.mxDocHandler.is()) throw RuntimeException();
104 pushContext(i_rContext);
105 addNamespaces(i_rContext,m_aNodePtr);
107 // add attributes
108 i_rContext.mxAttribList->clear();
109 for (xmlAttrPtr pAttr = m_aNodePtr->properties;
110 pAttr != 0; pAttr = pAttr->next) {
111 CNode * pNode = CNode::get(reinterpret_cast<xmlNodePtr>(pAttr));
112 OSL_ENSURE(pNode != 0, "CNode::get returned 0");
114 const xmlChar* xName = pAttr->name;
115 sal_Int32 nAttributeToken=FastToken::DONTKNOW;
117 if( pAttr->ns && strlen((char*)pAttr->ns->prefix) )
118 nAttributeToken = getTokenWithPrefix( i_rContext,
119 (sal_Char*)pAttr->ns->prefix,
120 (sal_Char*)xName );
121 else
122 nAttributeToken = getToken( i_rContext, (sal_Char*)xName );
124 if( nAttributeToken != FastToken::DONTKNOW )
125 i_rContext.mxAttribList->add( nAttributeToken,
126 OUStringToOString(pNode->getNodeValue(),
127 RTL_TEXTENCODING_UTF8));
130 const xmlChar* xPrefix = m_aNodePtr->ns ? m_aNodePtr->ns->prefix : (const xmlChar*)"";
131 const xmlChar* xName = m_aNodePtr->name;
132 sal_Int32 nElementToken=FastToken::DONTKNOW;
133 if( strlen((char*)xPrefix) )
134 nElementToken = getTokenWithPrefix( i_rContext, (sal_Char*)xPrefix, (sal_Char*)xName );
135 else
136 nElementToken = getToken( i_rContext, (sal_Char*)xName );
138 Reference<XFastContextHandler> xParentHandler(i_rContext.mxCurrentHandler);
141 Reference< XFastAttributeList > xAttr( i_rContext.mxAttribList.get() );
142 if( nElementToken == FastToken::DONTKNOW )
144 const OUString aNamespace;
145 const OUString aElementName( (sal_Char*)xPrefix,
146 strlen((char*)xPrefix),
147 RTL_TEXTENCODING_UTF8 );
149 if( xParentHandler.is() )
150 i_rContext.mxCurrentHandler = xParentHandler->createUnknownChildContext( aNamespace, aElementName, xAttr );
151 else
152 i_rContext.mxCurrentHandler = i_rContext.mxDocHandler->createUnknownChildContext( aNamespace, aElementName, xAttr );
154 if( i_rContext.mxCurrentHandler.is() )
155 i_rContext.mxCurrentHandler->startUnknownElement( aNamespace, aElementName, xAttr );
157 else
159 if( xParentHandler.is() )
160 i_rContext.mxCurrentHandler = xParentHandler->createFastChildContext( nElementToken, xAttr );
161 else
162 i_rContext.mxCurrentHandler = i_rContext.mxDocHandler->createFastChildContext( nElementToken, xAttr );
164 if( i_rContext.mxCurrentHandler.is() )
165 i_rContext.mxCurrentHandler->startFastElement( nElementToken, xAttr );
168 catch( Exception& )
171 // recurse
172 for (xmlNodePtr pChild = m_aNodePtr->children;
173 pChild != 0; pChild = pChild->next) {
174 CNode * pNode = CNode::get(pChild);
175 OSL_ENSURE(pNode != 0, "CNode::get returned 0");
176 pNode->fastSaxify(i_rContext);
179 if( i_rContext.mxCurrentHandler.is() ) try
181 if( nElementToken != FastToken::DONTKNOW )
182 i_rContext.mxCurrentHandler->endFastElement( nElementToken );
183 else
185 const OUString aNamespace;
186 const OUString aElementName( (sal_Char*)xPrefix,
187 strlen((char*)xPrefix),
188 RTL_TEXTENCODING_UTF8 );
190 i_rContext.mxCurrentHandler->endUnknownElement( aNamespace, aElementName );
193 catch( Exception& )
196 // restore after children have been processed
197 i_rContext.mxCurrentHandler = xParentHandler;
198 popContext(i_rContext);
202 Retrieves an attribute value by name.
203 return empty string if attribute is not set
205 OUString CElement::getAttribute(const OUString& name)
206 throw (RuntimeException)
208 OUString aValue;
209 // search properties
210 if (m_aNodePtr != NULL)
212 OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
213 xmlChar *xValue = xmlGetProp(m_aNodePtr, (xmlChar*)o1.getStr());
214 if (xValue != NULL) {
215 aValue = OUString((sal_Char*)xValue, strlen((char*)xValue), RTL_TEXTENCODING_UTF8);
218 return aValue;
222 Retrieves an attribute node by name.
224 Reference< XAttr > CElement::getAttributeNode(const OUString& name)
225 throw (RuntimeException)
227 Reference< XAttr > aAttr;
228 if (m_aNodePtr != NULL)
230 OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
231 xmlChar *xName = (xmlChar*)o1.getStr();
232 xmlAttrPtr pAttr = xmlHasProp(m_aNodePtr, xName);
233 aAttr = Reference< XAttr >(static_cast< CAttr* >(CNode::get((xmlNodePtr)pAttr)));
235 return aAttr;
239 Retrieves an Attr node by local name and namespace URI.
241 Reference< XAttr > CElement::getAttributeNodeNS(
242 const OUString& namespaceURI, const OUString& localName)
243 throw (RuntimeException)
245 Reference< XAttr > aAttr;
246 if (m_aNodePtr != NULL)
248 OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
249 xmlChar *xName = (xmlChar*)o1.getStr();
250 OString o2 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
251 xmlChar *xNS = (xmlChar*)o2.getStr();
252 xmlAttrPtr pAttr = xmlHasNsProp(m_aNodePtr, xName, xNS);
253 aAttr = Reference< XAttr >(static_cast< CAttr* >(CNode::get((xmlNodePtr)pAttr)));
255 return aAttr;
259 Retrieves an attribute value by local name and namespace URI.
260 return empty string if attribute is not set
262 OUString CElement::getAttributeNS(const OUString& namespaceURI, const OUString& localName)
263 throw (RuntimeException)
265 OUString aValue;
266 // search properties
267 if (m_aNodePtr != NULL)
269 OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
270 xmlChar *xName = (xmlChar*)o1.getStr();
271 OString o2 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
272 xmlChar *xNS = (xmlChar*)o2.getStr();
273 xmlChar *xValue = (xmlChar*)xmlGetNsProp(m_aNodePtr, xName, xNS);
274 if (xValue != NULL) {
275 aValue = OUString((sal_Char*)xValue, strlen((char*)xValue), RTL_TEXTENCODING_UTF8);
276 xmlFree(xValue);
279 return aValue;
283 Returns a NodeList of all descendant Elements with a given tag name,
284 in the order in which they are
285 encountered in a preorder traversal of this Element tree.
287 Reference< XNodeList > CElement::getElementsByTagName(const OUString& name)
288 throw (RuntimeException)
290 Reference< XNodeList > aList = Reference< XNodeList >(new CElementList(this, name));
291 return aList;
295 Returns a NodeList of all the descendant Elements with a given local
296 name and namespace URI in the order in which they are encountered in
297 a preorder traversal of this Element tree.
299 Reference< XNodeList > CElement::getElementsByTagNameNS(const OUString& namespaceURI,
300 const OUString& localName)
301 throw (RuntimeException)
303 Reference< XNodeList > aList = Reference< XNodeList >(new CElementList(this, localName, namespaceURI));
304 return aList;
308 The name of the element.
310 OUString CElement::getTagName()
311 throw (RuntimeException)
313 OUString aName;
314 if (m_aNodePtr != NULL)
316 aName = OUString((sal_Char*)m_aNodePtr->name, strlen((char*)m_aNodePtr->name), RTL_TEXTENCODING_UTF8);
318 return aName;
323 Returns true when an attribute with a given name is specified on this
324 element or has a default value, false otherwise.
326 sal_Bool CElement::hasAttribute(const OUString& name)
327 throw (RuntimeException)
329 OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
330 xmlChar *xName = (xmlChar*)o1.getStr();
331 return (m_aNodePtr != NULL && xmlHasProp(m_aNodePtr, xName) != NULL);
335 Returns true when an attribute with a given local name and namespace
336 URI is specified on this element or has a default value, false otherwise.
338 sal_Bool CElement::hasAttributeNS(const OUString& namespaceURI, const OUString& localName)
339 throw (RuntimeException)
341 OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
342 xmlChar *xName = (xmlChar*)o1.getStr();
343 OString o2 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
344 xmlChar *xNs = (xmlChar*)o2.getStr();
345 return (m_aNodePtr != NULL && xmlHasNsProp(m_aNodePtr, xName, xNs) != NULL);
349 Removes an attribute by name.
351 void CElement::removeAttribute(const OUString& name)
352 throw (RuntimeException, DOMException)
354 xmlChar *xName = (xmlChar*)OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr();
355 if (m_aNodePtr != NULL) {
356 xmlUnsetProp(m_aNodePtr, xName);
361 Removes an attribute by local name and namespace URI.
363 void CElement::removeAttributeNS(const OUString& namespaceURI, const OUString& localName)
364 throw (RuntimeException, DOMException)
366 OString o1 = OUStringToOString(localName, RTL_TEXTENCODING_UTF8);
367 xmlChar *xName = (xmlChar*)o1.getStr();
368 OString o2 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
369 xmlChar *xURI = (xmlChar*)o2.getStr();
370 if (m_aNodePtr != NULL) {
371 // XXX
372 xmlNsPtr pNs = xmlSearchNsByHref(m_aNodePtr->doc, m_aNodePtr, xURI);
373 xmlUnsetNsProp(m_aNodePtr, pNs, xName);
378 Removes the specified attribute node.
380 Reference< XAttr > CElement::removeAttributeNode(const Reference< XAttr >& oldAttr)
381 throw (RuntimeException, DOMException)
383 Reference< XAttr > aAttr;
384 if(m_aNodePtr != NULL)
386 xmlAttrPtr pAttr = (xmlAttrPtr) CNode::getNodePtr(oldAttr.get());
388 if (pAttr->parent != m_aNodePtr)
390 DOMException e;
391 e.Code = DOMExceptionType_HIERARCHY_REQUEST_ERR;
392 throw e;
394 if (pAttr->doc != m_aNodePtr->doc)
396 DOMException e;
397 e.Code = DOMExceptionType_WRONG_DOCUMENT_ERR;
398 throw e;
401 if (oldAttr->getNamespaceURI().getLength() > 0)
402 aAttr = oldAttr->getOwnerDocument()->createAttributeNS(
403 oldAttr->getNamespaceURI(), oldAttr->getName());
404 else
405 aAttr = oldAttr->getOwnerDocument()->createAttribute(oldAttr->getName());
406 aAttr->setValue(oldAttr->getValue());
407 xmlRemoveProp(pAttr);
410 return aAttr;
414 Adds a new attribute node.
416 Reference< XAttr > CElement::_setAttributeNode(const Reference< XAttr >& newAttr, sal_Bool bNS)
417 throw (RuntimeException)
419 Reference< XAttr > aAttr;
420 if (m_aNodePtr != NULL)
422 // check whether the attrib belongs to this document
423 Reference< XDocument > newDoc(newAttr->getOwnerDocument(), UNO_QUERY);
424 Reference< XDocument > oldDoc(CNode::getOwnerDocument(), UNO_QUERY);
425 if (newDoc != oldDoc) {
426 throw RuntimeException();
429 // get the implementation
430 xmlAttrPtr pAttr = (xmlAttrPtr) CNode::getNodePtr(newAttr.get());
432 // check whether the attribute is not in use by another element
433 xmlNsPtr pNs = NULL;
434 if (pAttr->parent != NULL)
435 if(strcmp((char*)pAttr->parent->name, "__private") == 0
436 && pNs && pAttr->ns != NULL)
438 pNs = xmlSearchNs(m_aNodePtr->doc, m_aNodePtr, pAttr->ns->prefix);
439 if (pNs == NULL || strcmp((char*)pNs->href, (char*)pAttr->ns->href) !=0 )
440 pNs = xmlNewNs(m_aNodePtr, pAttr->ns->href, pAttr->ns->href);
441 else
442 throw RuntimeException();
445 xmlAttrPtr res = NULL;
447 if (bNS)
448 res = xmlNewNsProp(m_aNodePtr, pNs, pAttr->name, pAttr->children->content);
449 else
450 res = xmlNewProp(m_aNodePtr, pAttr->name, pAttr->children->content);
452 // free carrier node ...
453 if(pAttr->parent != NULL && strcmp((char*)pAttr->parent->name, "__private")== 0)
454 xmlFreeNode(pAttr->parent);
455 // ... remove the old attr from the node cache
456 CNode::remove((xmlNodePtr)pAttr);
458 // get the new attr node
459 aAttr = Reference< XAttr >(static_cast< CAttr* >(CNode::get((xmlNodePtr)res)));
462 if (aAttr.is())
464 // attribute adition event
465 // dispatch DOMAttrModified event
466 Reference< XDocumentEvent > docevent(getOwnerDocument(), UNO_QUERY);
467 Reference< XMutationEvent > event(docevent->createEvent(
468 OUString::createFromAscii("DOMAttrModified")), UNO_QUERY);
469 event->initMutationEvent(OUString::createFromAscii("DOMAttrModified"),
470 sal_True, sal_False, Reference< XNode >(aAttr, UNO_QUERY),
471 OUString(), aAttr->getValue(), aAttr->getName(), AttrChangeType_ADDITION);
472 dispatchEvent(Reference< XEvent >(event, UNO_QUERY));
473 dispatchSubtreeModified();
475 return aAttr;
478 Reference< XAttr > CElement::setAttributeNode(const Reference< XAttr >& newAttr)
479 throw (RuntimeException, DOMException)
481 return _setAttributeNode(newAttr, sal_False);
485 Adds a new attribute.
487 Reference< XAttr > CElement::setAttributeNodeNS(const Reference< XAttr >& newAttr)
488 throw (RuntimeException, DOMException)
490 return _setAttributeNode(newAttr, sal_True);
494 Adds a new attribute.
496 void CElement::setAttribute(const OUString& name, const OUString& value)
497 throw (RuntimeException, DOMException)
499 OString o1 = OUStringToOString(name, RTL_TEXTENCODING_UTF8);
500 xmlChar *xName = (xmlChar*)o1.getStr();
501 OString o2 = OUStringToOString(value, RTL_TEXTENCODING_UTF8);
502 xmlChar *xValue = (xmlChar*)o2.getStr();
503 if (m_aNodePtr != NULL)
505 OUString oldValue;
506 AttrChangeType aChangeType = AttrChangeType_MODIFICATION;
507 xmlChar *xOld = xmlGetProp(m_aNodePtr, xName);
508 if (xOld == NULL)
510 aChangeType = AttrChangeType_ADDITION;
511 xmlNewProp(m_aNodePtr, xName, xValue);
513 else
515 oldValue = OUString((char*)xOld, strlen((char*)xOld), RTL_TEXTENCODING_UTF8);
516 xmlSetProp(m_aNodePtr, xName, xValue);
519 // dispatch DOMAttrModified event
521 Reference< XDocumentEvent > docevent(getOwnerDocument(), UNO_QUERY);
522 Reference< XMutationEvent > event(docevent->createEvent(
523 OUString::createFromAscii("DOMAttrModified")), UNO_QUERY);
524 event->initMutationEvent(OUString::createFromAscii("DOMAttrModified"),
525 sal_True, sal_False, Reference< XNode >(getAttributeNode(name), UNO_QUERY),
526 oldValue, value, name, aChangeType);
527 dispatchEvent(Reference< XEvent >(event, UNO_QUERY));
528 dispatchSubtreeModified();
533 Adds a new attribute.
535 void CElement::setAttributeNS(
536 const OUString& namespaceURI, const OUString& qualifiedName, const OUString& value)
537 throw (RuntimeException, DOMException)
539 if (namespaceURI.getLength() == 0) throw RuntimeException();
541 OString o1, o2, o3, o4, o5;
542 xmlChar *xPrefix = NULL;
543 xmlChar *xLName = NULL;
544 o1 = OUStringToOString(qualifiedName, RTL_TEXTENCODING_UTF8);
545 xmlChar *xQName = (xmlChar*)o1.getStr();
546 sal_Int32 idx = qualifiedName.indexOf(':');
547 if (idx != -1)
549 o2 = OUStringToOString(
550 qualifiedName.copy(0,idx),
551 RTL_TEXTENCODING_UTF8);
552 xPrefix = (xmlChar*)o2.getStr();
553 o3 = OUStringToOString(
554 qualifiedName.copy(idx+1),
555 RTL_TEXTENCODING_UTF8);
556 xLName = (xmlChar*)o3.getStr();
557 } else {
558 xPrefix = (xmlChar*)"";
559 xLName = xQName;
561 o4 = OUStringToOString(namespaceURI, RTL_TEXTENCODING_UTF8);
562 o5 = OUStringToOString(value, RTL_TEXTENCODING_UTF8);
563 xmlChar *xURI= (xmlChar*)o4.getStr();
564 xmlChar *xValue = (xmlChar*)o5.getStr();
565 if (m_aNodePtr != NULL)
567 //find the right namespace
568 xmlNsPtr pNs = xmlSearchNs(m_aNodePtr->doc, m_aNodePtr, xPrefix);
569 // if no namespace found, create a new one
570 if (pNs == NULL)
571 pNs = xmlNewNs(m_aNodePtr, xURI, xPrefix);
573 if (strcmp((char*)pNs->href, (char*)xURI) == 0)
575 // found namespace matches
577 OUString oldValue;
578 AttrChangeType aChangeType = AttrChangeType_MODIFICATION;
579 xmlChar *xOld = xmlGetNsProp(m_aNodePtr, xLName, pNs->href);
580 if (xOld == NULL)
582 aChangeType = AttrChangeType_ADDITION;
583 xmlNewNsProp(m_aNodePtr, pNs, xLName, xValue);
585 else
587 oldValue = OUString((char *)xOld, strlen((char *)xOld), RTL_TEXTENCODING_UTF8);
588 xmlSetNsProp(m_aNodePtr, pNs, xLName, xValue);
590 // dispatch DOMAttrModified event
591 Reference< XDocumentEvent > docevent(getOwnerDocument(), UNO_QUERY);
592 Reference< XMutationEvent > event(docevent->createEvent(
593 OUString::createFromAscii("DOMAttrModified")), UNO_QUERY);
594 event->initMutationEvent(OUString::createFromAscii("DOMAttrModified"), sal_True, sal_False,
595 Reference< XNode >(getAttributeNodeNS(namespaceURI, OUString((char*)xLName, strlen((char*)xLName), RTL_TEXTENCODING_UTF8)), UNO_QUERY),
596 oldValue, value, qualifiedName, aChangeType);
597 dispatchEvent(Reference< XEvent >(event, UNO_QUERY));
598 dispatchSubtreeModified();
600 } else {
601 // ambigious ns prefix
602 throw RuntimeException();
608 Reference< XNamedNodeMap > SAL_CALL CElement::getAttributes()throw (RuntimeException)
610 Reference< XNamedNodeMap > aMap;
611 if (hasAttributes()) {
612 aMap = Reference< XNamedNodeMap >(new CAttributesMap(this));
614 return aMap;
616 OUString SAL_CALL CElement::getNodeName()throw (RuntimeException)
618 return getLocalName();
620 OUString SAL_CALL CElement::getLocalName()throw (RuntimeException)
622 OUString aName;
623 if (m_aNodePtr != NULL)
625 const xmlChar* xName = m_aNodePtr->name;
626 aName = OUString((const sal_Char*)xName, strlen((const char*)xName), RTL_TEXTENCODING_UTF8);
628 return aName;
630 OUString SAL_CALL CElement::getNodeValue() throw (RuntimeException)
632 return OUString();
635 void SAL_CALL CElement::setElementName(const OUString& aName) throw (RuntimeException, DOMException)
637 if (aName.getLength() > 0 && aName.indexOf(OUString::createFromAscii(":")) < 0)
639 OString oName = OUStringToOString(aName, RTL_TEXTENCODING_UTF8);
640 xmlChar *xName = (xmlChar*)oName.getStr();
641 // xmlFree((void*)m_aNodePtr->name);
642 m_aNodePtr->name = xmlStrdup(xName);
644 else
646 DOMException e;
647 e.Code = DOMExceptionType_INVALID_CHARACTER_ERR;
648 throw e;