creates a XML tag with serialized attributes
 @see SerializedAttributes#serialized_attributes
11369
def serialized_tag(tagname, str, additional_attributes = {}, &block)
      str << "<#{tagname} "
      serialized_attributes(str, additional_attributes)
      if block_given?
        str << '>'
        yield
        str << "</#{tagname}>"
      else
        str << '/>'
      end
    end
601875
static ElementAttributes createElementAttributes(String tag) {
        // Parsing strings
        // <!--$includetemplate$aggregated2$templatewithparams.jsp$-->
        // or
        // <!--$includeblock$aggregated2$$(block)$myblock$-->
        // in order to retrieve driver, page and name attributes
        Pattern pattern = Pattern.compile("(?<=\\$)(?:[^\\$]|\\$\\()*(?=\\$)");
        Matcher matcher = pattern.matcher(tag);
        List<String> listparameters = new ArrayList<>();
        while (matcher.find()) {
            listparameters.add(matcher.group());
        }

        String[] parameters = listparameters.toArray(new String[listparameters.size()]);

        Driver driver;
        String page = "";
        String name = null;

        if (parameters.length > 1) {
            driver = DriverFactory.getInstance(parameters[1]);
        } else {
            driver = DriverFactory.getInstance();
        }

        if (parameters.length > 2) {
            page = parameters[2];
        }

        if (parameters.length > 3) {
            name = parameters[3];
        }
        return new ElementAttributes(driver, page, name);

    }
565637
def serialize
      serialized = {}

      # set basic info
      serialized[:id] = id
      serialized[:title] = title
      serialized[:subtitle] = subtitle
      serialized[:excerpt] = excerpt
      serialized[:content] = content
      serialized[:seo_description] = seo_description
      serialized[:meta_language] = meta_language
      serialized[:meta_permalink] = meta_permalink
      serialized[:meta_status] = meta_status

      # add fields informations
      serialized[:fields] = serialize_fields

      # add categories informations
      serialized[:categories] = serialize_categories

      # add tags informations
      serialized[:tags] = serialize_tags

      # add post parent informations
      serialized[:other_informations] = serialize_other_informations

      # return serialized post
      serialized
    end
268555
public XMLSerializer attribute(String namespace, String name, String value) throws IOException {
		if (!startTagIncomplete) {
			throw new IllegalArgumentException("startTag() must be called before attribute()" + getLocation());
		}
		// assert setPrefixCalled == false;
		out.write(' ');
		//// assert namespace != null;
		if (namespace != null && namespace.length() > 0) {
			// namespace = namespace.intern();
			if (!namesInterned) {
				namespace = namespace.intern();
			} else if (checkNamesInterned) {
				checkInterning(namespace);
			}
			String prefix = getPrefix(namespace, false, true);
			// assert( prefix != null);
			// if(prefix.length() == 0) {
			if (prefix == null) {
				// needs to declare prefix to hold default namespace
				// NOTE: attributes such as a='b' are in NO namespace
				prefix = generatePrefix(namespace);
			}
			out.write(prefix);
			out.write(':');
			// if(prefix.length() > 0) {
			// out.write(prefix);
			// out.write(':');
			// }
		}
		// assert name != null;
		out.write(name);
		out.write('=');
		// assert value != null;
		out.write(attributeUseApostrophe ? '\'' : '"');
		writeAttributeValue(value, out);
		out.write(attributeUseApostrophe ? '\'' : '"');
		return this;
	}
1034374
public static String open(Tag tag, AttributeValue... attrs) {

        StringBuffer sb = new StringBuffer();
        sb.append("<").append(tag.name());
        for (AttributeValue attr : attrs) {
            sb.append(" ").append(attr.toString());
        }
        sb.append(">");
        return sb.toString();
    }
357840
def init_tags
      @attr_tags = [
        InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
        InlineTag.new(SM::Attribute.bitmap_for(:TT),   "<tt>", "</tt>"),
        InlineTag.new(SM::Attribute.bitmap_for(:EM),   "<em>", "</em>"),
      ]
    end
333548
private TagScript createTagScript(QName n, Map<?, ?> attributes) throws JellyException {
        TagLibrary lib = context.getTagLibrary(n.getNamespaceURI());
        if(lib!=null) {
            String localName = n.getLocalPart();

            TagScript tagScript = lib.createTagScript(localName, null/*this parameter appears to be unused.*/);
            if (tagScript==null)    tagScript = lib.createTagScript(localName.replace('_','-'), null);

            if (tagScript!=null) {
                if (attributes != null) {
                    for (Entry e : attributes.entrySet()) {
                        Object v = e.getValue();
                        if (v!=null)
                            tagScript.addAttribute(e.getKey().toString(), new ConstantExpression(v));
                    }
                }

                return tagScript;
            }
        }

        // otherwise treat it as a literal.
        return null;
    }
103183
public function createTag($tag, $attr = NULL, $content = NULL)
    {
        $temp = '<'.$tag;
        if($attr != NULL) {
            $attr = (array) $attr;
            foreach($attr as $key => $val) {
                if(is_numeric($key)) {
                    $val = strtolower(trim($val));
                    if(isset($this->attr[$tag][$val])) {
                        $args[$val] = $this->attr[$tag][$val];
                        //$args[] = $val.($this->attr[$tag][$val] == NULL ? '' : "=\"{$this->attr[$tag][$val]}\"");
                    }
                    else {
                        $args[$val] = NULL;
                    }
                }
                else {
                    if(!isset($args[$key])) {
                        $args[$key] = $val;
                    }
                }
                if(isset($this->attr[$tag][$key])) {
                    if(is_array($this->attr[$tag][$key])) {
                        foreach($this->attr[$tag][$key] as $k => $v) {
                            if(isset($v[$val]) && !isset($args[$val])) {
                                $args[$k] = $v[$val];
                            }
                        }
                    }
                    else {
                        if(!isset($args[$val])) {
                            $args[$key] = $this->attr[$tag][$key];
                        }
                    }
                }
            }
            unset($attr);
            foreach($args as $key => $val) {
                $attr[] = $key.($val == NULL ? '' : "=\"$val\"");
            }
            unset($args);
            $args = array_unique($attr);
            $args = implode(' ', $args);
        }
        $temp .= isset($args) ? ' '.$args.'>' : '>'; 
        if($content != NULL) {
            if(is_array($content)) {
                array_walk($content, function(&$val, $key) { $val = trim($val); } );//5.3
                $content = implode("\n",$content);
                $content = explode("\n", $content);
                $content = preg_replace('/^/', "\t", $content);
                #$content = preg_filter('/^/', "@", $content);
                $content = rtrim("\n".implode("\n", $content), "\n")."\n";
            }
            $temp .= $content;
        }
        if($this->tags[$tag] === true) {
            $temp .= '</'.$tag.'>';
        }
        return $temp;
    }
122652
private static void createAttribute(Map<String, List<XsdAttribute>> createdAttributes, XsdAttribute elementAttribute) {
        if (!createdAttributes.containsKey(elementAttribute.getName())){
            List<XsdAttribute> attributes = new ArrayList<>();

            attributes.add(elementAttribute);

            createdAttributes.put(elementAttribute.getName(), attributes);
        } else {
            List<XsdAttribute> attributes = createdAttributes.get(elementAttribute.getName());

            if (!attributes.contains(elementAttribute)){
                attributes.add(elementAttribute);
            }
        }
    }
86153
def get_xml_attributes obj, parent=true
      attribs = obj.reject { |k, _| @@ignored_attributes.include? k }
      if parent
        attribs = attribs.reject { |k, _| @@parent_ignored_attributes.include? k }
      end
      attribs = attribs.reject { |_, v| v.kind_of?(Hash) || v.kind_of?(Array) }
      attribs.each_pair do |k, v|
        if @@numeric_attributes.include?(k) || k.to_s =~ /.+_score/
          attribs[k] = v.round(@render_options[:round])
        end
      end
      attribs
    end
598192
def to_xml_string(str = '')
      str << '<xf '
      serialized_attributes str
      str << '>'
      alignment.to_xml_string(str) if self.alignment
      protection.to_xml_string(str) if self.protection
      str << '</xf>'
    end
13003
protected void addAttributes(SXTag tag, Collection<XAttribute> attributes)
			throws IOException {
		for (XAttribute attribute : attributes) {
			SXTag attributeTag;
			if (attribute instanceof XAttributeList) {
				attributeTag = tag.addChildNode("list");
				attributeTag.addAttribute("key", attribute.getKey());
			} else if (attribute instanceof XAttributeContainer) {
				attributeTag = tag.addChildNode("container");
				attributeTag.addAttribute("key", attribute.getKey());
			} else if (attribute instanceof XAttributeLiteral) {
				attributeTag = tag.addChildNode("string");
				attributeTag.addAttribute("key", attribute.getKey());
				attributeTag.addAttribute("value", attribute.toString());
			} else if (attribute instanceof XAttributeDiscrete) {
				attributeTag = tag.addChildNode("int");
				attributeTag.addAttribute("key", attribute.getKey());
				attributeTag.addAttribute("value", attribute.toString());
			} else if (attribute instanceof XAttributeContinuous) {
				attributeTag = tag.addChildNode("float");
				attributeTag.addAttribute("key", attribute.getKey());
				attributeTag.addAttribute("value", attribute.toString());
			} else if (attribute instanceof XAttributeTimestamp) {
				attributeTag = tag.addChildNode("date");
				attributeTag.addAttribute("key", attribute.getKey());
				Date timestamp = ((XAttributeTimestamp) attribute).getValue();
				attributeTag.addAttribute("value",
						xsDateTimeConversion.format(timestamp));
			} else if (attribute instanceof XAttributeBoolean) {
				attributeTag = tag.addChildNode("boolean");
				attributeTag.addAttribute("key", attribute.getKey());
				attributeTag.addAttribute("value", attribute.toString());
			} else if (attribute instanceof XAttributeID) {
				attributeTag = tag.addChildNode("id");
				attributeTag.addAttribute("key", attribute.getKey());
				attributeTag.addAttribute("value", attribute.toString());
			} else {
				throw new IOException("Unknown attribute type!");
			}
			if (attribute instanceof XAttributeCollection) {
				/*
				 * Use order as specified by the collection.
				 */
				Collection<XAttribute> childAttributes = ((XAttributeCollection) attribute).getCollection();
				addAttributes(attributeTag, childAttributes);
			} else {
				addAttributes(attributeTag, attribute.getAttributes().values());
			}
		}
	}
822358
protected static function generateTag($tag, $content, $attributes = [])
	{
		$text = '';
		$attribute = self::attribute($attributes);
		if (is_string($tag))
			$text .= "<{$tag}{$attribute}>".PHP_EOL;
		
		if (is_array($content)) {
			if (isset($content['type']) and $content['type'] = 'cdata') {
				$text .="<![CDATA[".PHP_EOL;
				$text .= $content['data'].PHP_EOL;
				$text .="]]>".PHP_EOL;
			} else {
				foreach ($content as $tg => $ct) {
					if (is_array($ct) && isset($ct['content']) && isset($ct['attribute']))
						$text .= self::generateTag($tg, $ct['content'], $ct['attribute']);
					else
						$text .= self::generateTag($tg, $ct);
				}
			}
		} elseif (is_string($content)) {
			$text .= $content;
		}
		
		if (is_string($tag))
			$text .= "</{$tag}>".PHP_EOL;
		return $text;
	}
1353867
public static String getOpeningTag(String tag, Map<String, String> attributes)
	{
		StringBuffer _result = new StringBuffer();
		Map<String, String> _attributes = (null != attributes) ? attributes : EMPTY_MAP;
		return doAppendOpeningTag(_result, tag, _attributes).toString();
	}
1152715
private static function array_to_xml($data = array(), &$xml_data) {
	foreach($data as $key => $value) {

	    if(is_array($value) or (is_object($value))) {
		if(!is_numeric($key)){
		    $subnode = $xml_data->addChild("$key");
		    self::array_to_xml($value, $subnode);
		}
		else{
		    $subnode = $xml_data->addChild("element");
		    self::array_to_xml($value, $subnode);
		}
	    }
	    else {
		if (is_bool($value)) {$value = $value ? "true" : "false";}
		$xml_data->addChild("$key","$value");
	    }
	}
    }
709696
private static void serializeElement(final String tag, final String content, final ContentHandler handler)
      throws SAXException {
    final AttributesImpl attributes = new AttributesImpl();
    handler.startElement(null, tag, tag, attributes);
    handler.characters(content.toCharArray(), 0, content.length());
    handler.endElement(null, tag, tag);
  }
1215112
public void toXML(XMLBuilder xml) throws IllegalArgumentException {
        assert xml != null;
        
        // Determine what tag name to use for the generated element. 
        Map<String, String> attrMap = new LinkedHashMap<>(); 
        String elemName = m_name;
        if (m_tagName.length() > 0) {
            // Place m_name into a "name" attribute and use m_tagName
            attrMap.put("name", m_name);
            elemName = m_tagName;
        }
        
        // Add child VALUE nodes marked as "attribute" in its own map.
        addXMLAttributes(attrMap);
        switch (m_type) {
        case ARRAY:
            // Start an element with or without attributes.
            if (attrMap.size() > 0) {
                xml.startElement(elemName, attrMap);
            } else {
                xml.startElement(elemName);
            }
            
            // Add XML for non-attribute child nodes.
            if (m_children != null) {
                for (UNode childNode : m_children) {
                    if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) {
                        childNode.toXML(xml);
                    }
                }
            }
            xml.endElement();
            break;
        case MAP:
            // Start an element with or without attributes.
            if (attrMap.size() > 0) {
                xml.startElement(elemName, attrMap);
            } else {
                xml.startElement(elemName);
            }
            
            // Add XML for non-attribute child nodes in name order.
            if (m_childNodeMap != null) {
                assert m_childNodeMap.size() == m_children.size();
                for (UNode childNode : m_childNodeMap.values()) {
                    if (childNode.m_type != NodeType.VALUE || !childNode.m_bAttribute) {
                        childNode.toXML(xml);
                    }
                }
            }
            xml.endElement();
            break;
        case VALUE:
            // Map to a simple element.
            String value = m_value;
            if (Utils.containsIllegalXML(value)) {
                value = Utils.base64FromString(m_value);
                attrMap.put("encoding", "base64");
            }
            if (attrMap.size() > 0) {
                xml.addDataElement(elemName, value, attrMap);
            } else {
                xml.addDataElement(elemName, value);
            }
            break;
        default:
            assert false : "Unexpected NodeType: " + m_type;
        }
    }