//--------------------------------------------------------------- void StreamWriter::closeElements( ElementIndexType elementIndex ) { // we need to determine how many elements need to be close // we search from the end until we find the first element index <= elementIndex and count the elements // If this is == elementIndex, we need close elmentsToClose elements // If it is < elementIndex, the element has been close before, nothing to do ElementIndexType elmentsToClose = 0; OpenTagStack::reverse_iterator it = mOpenTags.rbegin(); for ( ; it != mOpenTags.rend(); ++it) { elmentsToClose++; const ElementIndexType& currentTagIndex = it->mElementIndex; if ( currentTagIndex < elementIndex) { // the element is not in the stack, i.e. has already been closed return; } if ( currentTagIndex == elementIndex) { // we need to close elmentsToClose elements for ( ElementIndexType i = 0; i < elmentsToClose; ++i) { closeElement(); } return; } } // if we reach this point, the searched element is not in the stack, i.e. already, nothing to do }
void XMLTreeBuilder::processStartTag(const AtomicXMLToken& token) { exitText(); bool isFirstElement = !m_sawFirstElement; m_sawFirstElement = true; NodeStackItem top = m_currentNodeStack.last(); processNamespaces(token, top); QualifiedName qName(token.prefix(), token.name(), top.namespaceForPrefix(token.prefix(), top.namespaceURI())); RefPtr<Element> newElement = m_document->createElement(qName, true); processAttributes(token, top, newElement); newElement->beginParsingChildren(); m_currentNodeStack.last().node()->parserAddChild(newElement.get()); top.setNode(newElement); pushCurrentNode(top); if (!newElement->attached()) newElement->attach(); if (isFirstElement && m_document->frame()) m_document->frame()->loader()->dispatchDocumentElementAvailable(); if (token.selfClosing()) closeElement(newElement); }
void XMLTreeBuilder::processEndTag(const AtomicXMLToken& token) { exitText(); RefPtr<ContainerNode> node = m_currentNodeStack.last().node(); if (!node->hasTagName(QualifiedName(token.prefix(), token.name(), m_currentNodeStack.last().namespaceForPrefix(token.prefix(), m_currentNodeStack.last().namespaceURI())))) m_parser->stopParsing(); closeElement(toElement(node.get())); }
//--------------------------------------------------------------- void StreamWriter::appendTextElement ( const String& elementName, const String& text ) { openElement ( elementName ); appendText ( COLLADABU::StringUtils::translateToXML(text) ); closeElement(); }
//--------------------------------------------------------------- void StreamWriter::endDocument() { while ( !mOpenTags.empty() ) closeElement(); }
//--------------------------------------------------------------- void StreamWriter::appendURIElement ( const String& elementName, const COLLADABU::URI& uri ) { openElement ( elementName ); appendText ( COLLADABU::StringUtils::translateToXML(uri.getURIString()) ); closeElement(); }
void PrefabPlant::closeElement( const wstring & prefix, const wstring & name ) { closeElement(name); }