const XMLCh * DOMAttrImpl::getValue() const { if (fParent.fFirstChild == 0) { return XMLUni::fgZeroLenString; // return ""; } // Simple case where attribute value is just a single text node DOMNode *node = castToChildImpl(fParent.fFirstChild)->nextSibling; if (node == 0 && fParent.fFirstChild->getNodeType() == DOMNode::TEXT_NODE) { return fParent.fFirstChild->getNodeValue(); } // // Complicated case whre attribute value is a DOM tree // // According to the spec, the child nodes of the Attr node may be either // Text or EntityReference nodes. // // The parser will not create such thing, this is for those created by users. // // In such case, we have to visit each child to retrieve the text // XMLBuffer buf(1023, ((DOMDocumentImpl *)this->getOwnerDocument())->getMemoryManager()); getTextValue(fParent.fFirstChild, buf); return (XMLCh*) ((DOMDocumentImpl *)this->getOwnerDocument())->getPooledString(buf.getRawBuffer()); }
//Creates a new text node based on the text that it reads XMLNode *readXMLTextNode() { char* textValue = getTextValue(); XMLNode* newNode = xmlCreateNode(TEXT_NODE, TEXT_NAME, textValue); free(textValue); return newNode; }
void DOMAttrImpl::getTextValue(DOMNode* node, XMLBuffer& buf) const { if (node->getNodeType() == DOMNode::TEXT_NODE) buf.append(node->getNodeValue()); else if (node->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) { for (node = node->getFirstChild(); node != 0; node = castToChildImpl(node)->nextSibling) { getTextValue(node, buf); } } return; }
void VerbatimXmlComponent::renderBegin() const { auto context = getContext(); auto attribs = getRenderAttributes(context); /*we ALWAYS use the provided id for plain xml tags, regardless of naming *containers etc. this means plain html will always work as expected - and *no plain html component needs its id for anything other than css!*/ auto& id = attribs["id"]; auto sepPos = id.find_last_of(Component::NAMING_SEPARATOR); if (sepPos != id.npos) { id = id.substr(sepPos + 1); } //the root element needs to declare the xhtml namespace if (getTagName() == "html" && attribs.find("xmlns") == attribs.end()) { attribs["xmlns"] = "http://www.w3.org/1999/xhtml"; } getWriter() <<"<" <<impl->getOriginalTag() <<Util::toString(attribs) <<">" <<context->evaluateString(getTextValue()); }
void CClientMimeHandler::envelope() { if (theEnvelopeItem.isNull()) { throw EmailException("PARSE_ERROR", "The message could not be parsed."); } //set the date from the client. //If this is not set it defaults to the date of the SMTP server. char line[MAILTMPLEN]; rfc822_date (line); theEnvelope->date = (unsigned char *) fs_get (1+strlen (line)); strcpy((char *)theEnvelope->date,line); Iterator_t lChildIter; zorba::Item lChild; String lNodeName, lNodeValue; String lName, lMailbox, lHost; lChildIter = theEnvelopeItem.getChildren(); lChildIter->open(); while (lChildIter->next(lChild)) { if (lChild.getNodeKind() != store::StoreConsts::elementNode) { continue; } getNodeName(lChild, lNodeName); getTextValue(lChild, lNodeValue); if (lNodeName == "date") { char lDate[MAILTMPLEN]; parseXmlDateTime(lNodeValue, lDate); theEnvelope->date = (unsigned char *) fs_get (1+strlen (lDate)); strcpy ((char *)theEnvelope->date, lDate); } else if (lNodeName == "from") { getNameAndEmailAddress(lChild, lName, lMailbox, lHost); theEnvelope->from = create_mail_address(lName, lMailbox, lHost); } else if (lNodeName == "sender") { getNameAndEmailAddress(lChild, lName, lMailbox, lHost); theEnvelope->sender = create_mail_address(lName, lMailbox, lHost); } else if (lNodeName == "replyto") { getNameAndEmailAddress(lChild, lName, lMailbox, lHost); theEnvelope->reply_to = create_mail_address(lName, lMailbox, lHost); } else if (lNodeName == "subject") { encodeStringForEMailHeader(lNodeValue, theEnvelope->subject); } else if (lNodeName == "recipient") { Iterator_t lRecipentChildren = lChild.getChildren(); lRecipentChildren->open(); Item lRecipentChild; // read the recipient element but skip comments while (lRecipentChildren->next(lRecipentChild)) { if (lRecipentChild.getNodeKind() == store::StoreConsts::elementNode) { break; } } getNodeName(lRecipentChild, lNodeName); lRecipentChildren->close(); if (lNodeName == "to") { getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost); // there can be multiple to nodes, iterate to the next free one! ADDRESS** lNext = &theEnvelope->to; while (*lNext) { lNext = &((*lNext)->next); } *lNext = create_mail_address(lName, lMailbox, lHost); } else if(lNodeName == "cc") { getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost); ADDRESS** lNext = &theEnvelope->cc; while (*lNext) { lNext = &((*lNext)->next); } *lNext = create_mail_address(lName, lMailbox, lHost); } else if (lNodeName == "bcc") { getNameAndEmailAddress(lRecipentChild, lName, lMailbox, lHost); ADDRESS** lNext = &theEnvelope->bcc; while (*lNext) { lNext = &((*lNext)->next); } *lNext = create_mail_address(lName, lMailbox, lHost); } } } lChildIter->close(); }
int FXmlBtn::AddChildData( AST_TXML_Tag *root, FBtnVM& vm ) { long ret = 0; AST_TXML_Tag* tag = root->getFirstTag( FBL_TAG_frames ); if( !tag ) { if( !html_strcmp( getTextValue(), FBL_VAL_table ) ) return 0; else { vm.dmm.AddLine( vm.dmm_page, _T("definition of frames is mandatory part of the formula node description"), root->getLine() ); return -1; } } long i, j; AST_TXML_Compound *comp = 0; AST_TXML_Node *node; std::vector<AST_TXML_Tag*> arrtags; tag->getAllTags( FBL_TAG_frame, arrtags, 1 ); for( i = 0; i < (long) arrtags.size(); i++ ) { if( arrtags[ i ] ) { AST_TXML_Attribute *name = 0, *left = 0, *right = 0, *top = 0, *bottom = 0, *valign = 0, *halign = 0, *level = 0; if( !(comp = arrtags[ i ]->getAttributes()) ) continue; for( j = 0; j < comp->getChildNumber(); j++ ) { node = comp->getChild( j ); if( node->getNodeType() != ASTT_TXML_Attribute ) continue; if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_name ) ) name = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_level ) ) level = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_left ) ) left = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_top ) ) top = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_right ) ) right = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_bottom ) ) bottom = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_valign ) ) valign = (AST_TXML_Attribute*)node; else if( ((AST_TXML_Attribute*)node)->isAttribute( FBL_ATTR_halign ) ) halign = (AST_TXML_Attribute*)node; } struct FBtnChildPos child; if( name && name->getValueType() == ASTVALT_TXML_String ) vm.AddObject( name->getStringValue(), arrtags[ i ]->getLine() ); else vm.AddObject( QString("%1").arg(i), arrtags[ i ]->getLine() ); if( left && top && right && bottom ) { if( left->getValueType() != ASTVALT_TXML_Real && left->convert2Float() != ELH_NO_ERROR ) { vm.dmm.AddLine( vm.dmm_page, _T("child frame position fields left must be of integer or real type"), arrtags[ i ]->getLine() ); ret = -1; continue; } if( top->getValueType() != ASTVALT_TXML_Real && top->convert2Float() != ELH_NO_ERROR ) { vm.dmm.AddLine( vm.dmm_page, _T("child frame position fields top must be of integer or real type"), arrtags[ i ]->getLine() ); ret = -1; continue; } if( right->getValueType() != ASTVALT_TXML_Real && right->convert2Float() != ELH_NO_ERROR ) { vm.dmm.AddLine( vm.dmm_page, _T("child frame position fields right must be of integer or real type"), arrtags[ i ]->getLine() ); ret = -1; continue; } if( bottom->getValueType() != ASTVALT_TXML_Real && bottom->convert2Float() != ELH_NO_ERROR ) { vm.dmm.AddLine( vm.dmm_page, _T("child frame position fields bottom must be of integer or real type"), arrtags[ i ]->getLine() ); ret = -1; continue; } child.pos.setLeft( left->getFloatValue() ); child.pos.setTop( top->getFloatValue() ); child.pos.setRight( right->getFloatValue() ); child.pos.setBottom( bottom->getFloatValue() ); } AddChildData_read_align( arrtags[ i ], child, vm ); if( level ) { if( level->getValueType() == ASTVALT_TXML_Int && level->getIntValue() >= 0 ) child.level = level->getIntValue(); else if( level->getValueType() == ASTVALT_TXML_String ) { if( !html_strcmp( level->getStringValue(), FBL_VAL_parent ) || !html_strcmp( level->getStringValue(), FBL_VAL_frame ) ) child.level = FTEXT_HEIGHT_FRAME; else if( !html_strcmp( level->getStringValue(), FBL_VAL_child ) || !html_strcmp( level->getStringValue(), FBL_VAL_child1 ) ) child.level = FTEXT_HEIGHT_CHILD1; } } FBtn::AddChildData( child ); } } return ret; }
void FXmlBtn::AddButtonData( AST_TXML_Tag *root, FBtnVM& vm ) { HKStringMap attrMap; root->setAttrMap( attrMap ); HKStringMap::iterator it; QString attrName; long value = 0; bool ok; if( (it = attrMap.find(FBL_ATTR_rows)) != attrMap.end() ) { unsigned long rows = 0; if( !html_strcmp(it->second, FBL_VAL_ask) ) input_properties.push_back( QString(FBL_ATTR_rows) ); else { if( (rows = it->second.toULong(&ok)) == 0 || !ok ) vm.dmm.AddLine( vm.dmm_page, QString("%1 field must be of integer type, wrong value is ignored"), root->getLine(), FBL_ATTR_rows ); else this->rows = rows; } } if( (it = attrMap.find(FBL_ATTR_columns)) != attrMap.end() ) { unsigned long columns = 0; if( !html_strcmp(it->second, FBL_VAL_ask) ) input_properties.push_back( QString(FBL_ATTR_columns) ); else { if( (columns = it->second.toULong(&ok)) == 0 || !ok ) vm.dmm.AddLine( vm.dmm_page, QString("%1 field must be of integer type, wrong value is ignored"), root->getLine(), FBL_ATTR_columns ); else this->columns = columns; } } if( (it = attrMap.find(FBL_ATTR_encoding)) != attrMap.end() ) input_properties.push_back( it->second ); if( (it = attrMap.find(FBL_ATTR_cannot_draw_width)) != attrMap.end() ) m_cannot_draw_width = it->second; if( (it = attrMap.find(FBL_ATTR_cannot_draw_height)) != attrMap.end() ) m_cannot_draw_height = it->second; if( (it = attrMap.find(FBL_ATTR_disabledFrame)) != attrMap.end() && !html_strcmp(it->second, FBL_VAL_yes) ) proplist.setFrameHidden(); if( (it = attrMap.find(FBL_ATTR_eatleftop)) != attrMap.end() ) { if( !html_strcmp(it->second, FBL_VAL_yes )) proplist.setContentEatLeftOp(); else if( !html_strcmp(it->second, FBL_VAL_no) ) proplist.clearContentEatLeftOp(); } if( (it = attrMap.find(FBL_ATTR_name)) != attrMap.end() ) setToolTip( formula_type_name = it->second ); if( (it = attrMap.find(FBL_ATTR_id)) != attrMap.end() ) { setID( it->second ); } if( (it = attrMap.find(FBL_ATTR_stretchy)) != attrMap.end() ) { if( !html_strcmp(it->second, FBL_VAL_yes )) proplist.setStretchy(); else if( !html_strcmp(it->second, FBL_VAL_no) ) proplist.clearStretchy(); } if( (it = attrMap.find(FBL_ATTR_symmetric)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_yes ) ) proplist.setSymmetric(); else if( !html_strcmp( it->second, FBL_VAL_no ) ) proplist.clearSymmetric(); } if( (it = attrMap.find(FBL_ATTR_mathml_support)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_yes ) ) proplist.setRWMMLSupport(); else if( !html_strcmp( it->second, FBL_VAL_no ) ) proplist.clearRWMMLSupport(); } if( (it = attrMap.find(FBL_ATTR_mathml_support)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_postfix ) ) proplist.setRWMMLPostfix(); else if( !html_strcmp( it->second, FBL_VAL_infix ) ) proplist.setRWMMLInfix(); else proplist.setRWMMLPrefix(); } if( (it = attrMap.find(FBL_ATTR_bevelled)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_yes ) ) proplist.setUnfilteredAttr( FBL_ATTR_bevelled, FBL_VAL_true ); if( !html_strcmp( it->second, FBL_VAL_no ) ) proplist.setUnfilteredAttr( FBL_ATTR_bevelled, FBL_VAL_false ); } if( (it = attrMap.find(FBL_ATTR_largeop)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_yes ) ) proplist.setLargeOp(); else if( !html_strcmp( it->second, FBL_VAL_no ) ) proplist.clearLargeOp(); } if( (it = attrMap.find(FBL_ATTR_lspace)) != attrMap.end() ) { RealFde value = 0.0; if( ::mml_convertSpaceName2FloatValue( 0/*x*/, it->second, value, ::getCurrentFormulatorStyle().getUnit2PX() ) != -1 ) proplist.setLSpace( value ); } if( (it = attrMap.find(FBL_ATTR_rspace)) != attrMap.end() ) { RealFde value = 0.0; if( ::mml_convertSpaceName2FloatValue( 0/*x*/, it->second, value, ::getCurrentFormulatorStyle().getUnit2PX() ) != -1 ) proplist.setRSpace( value ); } if( (it = attrMap.find(FBL_ATTR_type)) != attrMap.end() ) { if( !html_strcmp( it->second, FBL_VAL_text ) ) node_type = NODE_PLANETEXT; else if( !html_strcmp( it->second, FBL_VAL_formula ) ) node_type = NODE_FORMULA; else if( !html_strcmp( it->second, FBL_VAL_mathml ) ) node_type = NODE_MATHML; else { node_type = NODE_FORMULA; QString warn2 = _T("type \"%1\" is unknown and ignored"); vm.dmm.AddLine( vm.dmm_page, warn2, root->getLine(), it->second ); } } if( (it = attrMap.find(FBL_ATTR_value)) != attrMap.end() ) { LCEntity la_ent; long ret = la_ent.Analisys( it->second.midRef(0) ); if( ret == LCEntity::Number ) { proplist.setUnicode(); text_value = QString(QChar(la_ent.getVal())); } else text_value = it->second; } if( (it = attrMap.find(FBL_ATTR_vertical_center_type)) != attrMap.end() ) { if( node_type == NODE_PLANETEXT ) vm.dmm.AddLine( vm.dmm_page, _T("attribute \"%1\" is not for plane text, it's ignored"), root->getLine(), it->second ); else { attrName = it->second; if( !html_strcmp( attrName, FBL_VAL_object ) || !html_strcmp( it->second, FBL_VAL_child ) ) { ok = false; if( (it = attrMap.find(FBL_ATTR_vertical_center_value)) != attrMap.end()) value = it->second.toLong(&ok); if( ok ) { vertical_center_type = FBtnChildPos::Child; vertical_center_value = value; } else vm.dmm.AddLine( vm.dmm_page, _T("vertical center value is missing or has the wrong type, vertical center option is ignored"), root->getLine() ); } else if( !html_strcmp( attrName, FBL_VAL_average ) ) { ok = false; if( (it = attrMap.find(FBL_ATTR_vertical_center_value)) != attrMap.end()) value = it->second.toLong(&ok); if( ok ) { vertical_center_type = FBtnChildPos::Child_Average; vertical_center_value = value; } else vm.dmm.AddLine( vm.dmm_page, _T("vertical center value is missing or has the wrong type, vertical center option is ignored"), root->getLine() ); } else if( !html_strcmp( attrName, FBL_VAL_blank_average ) ) { vertical_center_type = FBtnChildPos::Frame_Blank_Average; } else if( !html_strcmp( attrName, FBL_VAL_half ) ) { vertical_center_type = FBtnChildPos::Half; } else if( !html_strcmp( attrName, FBL_VAL_frame ) ) { ok = false; if( (it = attrMap.find(FBL_ATTR_vertical_center_value)) != attrMap.end()) value = it->second.toLong(&ok); if( ok ) { vertical_center_type = FBtnChildPos::Frame; vertical_center_value = value; } else vm.dmm.AddLine( vm.dmm_page, _T("vertical center value is missing or has the wrong type, vertical center option is ignored"), root->getLine() ); } else vm.dmm.AddLine( vm.dmm_page, _T("vertical center type \'%1\' is unknown, it's ignored"), root->getLine(), it->second ); } } if( (it = attrMap.find(FBL_ATTR_style)) != attrMap.end() ) { if( node_type != NODE_PLANETEXT ) vm.dmm.AddLine( vm.dmm_page, _T("style \"%1\" is for plane text only, it's ignored"), root->getLine(), it->second ); long id = ::getCurrentFormulatorStyle().getStyleByName( it->second ); if( id >= 0 ) text_style = id; else { text_style = ::getCurrentFormulatorStyle_OnChar(); vm.dmm.AddLine( vm.dmm_page, _T("style \"%1\" is unknown and ignored"), root->getLine(), it->second ); } } // validity checks if( getNodeType() == NODE_FORMULA && !html_strcmp( getTextValue(), FBL_VAL_table ) && (this->rows == 0 || this->columns == 0) ) { text_value = _T(""); vm.dmm.AddLine( vm.dmm_page, _T("for the \"table\" template rows and columns must be greater-than or equal to 1, template is ignored"), root->getLine() ); } AST_TXML_Tag *hotkeys = root->getFirstTag( FBL_TAG_hotkeys ); if ( hotkeys ) AddAccels( hotkeys, vm ); }