本文整理汇总了PHP中DOMNode::setAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode::setAttributeNS方法的具体用法?PHP DOMNode::setAttributeNS怎么用?PHP DOMNode::setAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::setAttributeNS方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildNode
/**
* Builds and creates the Atom XML nodes required by this content
*
* The element node representing this content is created separately and
* passed as the first parameter of this method.
*
* The text content of this content is created as a CDATA section.
*
* @param DOMNode $node the node representing this content. Extra nodes
* should be created and added to this node.
*
* @return void
*/
protected function _buildNode(DOMNode $node)
{
$document = $node->ownerDocument;
$node->setAttributeNS(XML_Atom_Node::NS, 'type', $this->_type);
$cdata_node = $document->createCDATASection($this->_text);
$node->appendChild($cdata_node);
}
示例2: AddXsiType
/**
* Adds the xsi:type to the DOMNode generated from the corresponding object.
* @param DOMNode $domNode the DOM node corresponding to the object
* @param $object the object used to determine the xsi:type
* @access private
*/
private function AddXsiType(DOMNode $domNode, $object)
{
$xsiType = $domNode->getAttributeNS(self::$XSI_NAMESPACE, 'xsi:type');
if (method_exists($object, 'getXsiTypeName') && method_exists($object, 'getNamespace') && empty($xsiType)) {
$xsiTypeName = $object->getXsiTypeName();
if (isset($xsiTypeName) && $xsiTypeName != '') {
$prefix = $domNode->lookupPrefix($object->getNamespace());
$domNode->setAttributeNS(self::$XSI_NAMESPACE, 'xsi:type', (isset($prefix) ? $prefix . ':' : '') . $xsiTypeName);
}
}
}
示例3: _buildNode
/**
* Builds all the XML information contained inside this link node.
*
* @param DOMNode $node the link node that will contain the XML generated
* by this node.
*
* @return void
*/
protected function _buildNode(DOMNode $node)
{
$node->setAttributeNS(XML_Atom_Node::NS, 'href', $this->_href);
if ($this->_rel != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'rel', $this->_rel);
}
if ($this->_type != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'type', $this->_type);
}
if ($this->_hreflang != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'hreflang', $this->_hreflang);
}
if ($this->_title != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'title', $this->_title);
}
if ($this->_length !== null) {
$node->setAttributeNS(XML_Atom_Node::NS, 'length', $this->_length);
}
}
示例4: _buildNode
/**
* Builds all the XML information contained inside this generator node
*
* @param DOMNode $node the node that will contain the XML generated
* by this generator node.
*
* @return void
*/
protected function _buildNode(DOMNode $node)
{
$document = $node->ownerDocument;
if ($this->_uri != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'uri', $this->_uri);
}
if ($this->_version != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'version', $this->_version);
}
$generator_content = $document->createTextNode($this->_generator);
$node->appendChild($generator_content);
}
示例5: add_attributes
/**
* Applies attributes to a node
* @param DOMNode $node
* @param array $attributes as key => value
* @return DOMNode
*/
private function add_attributes(DOMNode $node, $attributes = array())
{
$node_name = $this->meta()->alias($node->tagName);
if ($this->meta()->attributes($node_name))
{
$attributes = array_merge($this->meta()->attributes($node_name), $attributes);
}
foreach ($attributes as $key => $val)
{
// Trim elements
$key = $this->meta()->alias(trim($key));
$val = $this->filter($key, trim($val));
// Set the attribute
// Let's check if the attribute name has a namespace prefix, and if this prefix is defined in our driver
if ($this->meta()->ns($key))
{
list ($ns, $prefix) = $this->meta()->ns($key);
// Register the prefixed namespace
$this->dom_node->setAttributeNS("http://www.w3.org/2000/xmlns/" ,"xmlns:$prefix", $ns);
// Add the prefixed attribute within that namespace
$node->setAttributeNS($ns, $key, $val);
}
else
{
// Simply add the attribute
$node->setAttribute($key, $val);
}
}
return $node;
}
示例6: _buildNode
/**
* Builds all the XML information contained inside this node.
*
* @param DOMNode $node the parent node that will contain the XML
* generated by this node.
*
* @return void
*/
protected function _buildNode(DOMNode $node)
{
$document = $node->ownerDocument;
$node->setAttributeNS(XML_Atom_Node::NS, 'term', $this->_term);
if ($this->_scheme != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'scheme', $this->_scheme);
}
if ($this->_label != '') {
$node->setAttributeNS(XML_Atom_Node::NS, 'label', $this->_label);
}
}
示例7: transferObjectTo
/**
* Transfer an object value into a target element node. If the object has no properties,
* the json:type attribute is always set to 'object'. If verbose is not set the json:type attribute will
* be omitted if the object value has properties.
*
* The method creates child nodes for each property. The property name will be normalized to a valid NCName.
* If the normalized NCName is different from the property name or verbose is TRUE, a json:name attribute
* with the property name will be added.
*
* @param \DOMNode|\DOMElement|\DOMDocumentFragment $target
* @param object $value
* @param int $recursions
*/
private function transferObjectTo(\DOMNode $target, $value, $recursions)
{
$properties = is_array($value) ? $value : get_object_vars($value);
if ($this->_verbose || empty($properties)) {
$target->setAttributeNS(self::XMLNS, 'json:type', 'object');
}
foreach ($properties as $property => $item) {
$qname = $this->getQualifiedName($property, self::DEFAULT_QNAME);
$target->appendChild($child = $target->ownerDocument->createElement($qname));
if ($this->_verbose || $qname != $property) {
$child->setAttributeNS(self::XMLNS, 'json:name', $property);
}
$this->transferTo($child, $item, $recursions);
}
}