本文整理汇总了PHP中DOMElement::setAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::setAttributeNS方法的具体用法?PHP DOMElement::setAttributeNS怎么用?PHP DOMElement::setAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::setAttributeNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* Converts the 'font-size' CSS style.
*
* This method receives a $targetProperty DOMElement and converts the given
* style with $styleName and $styleValue to attributes on this
* $targetProperty.
*
* @param DOMElement $targetProperty
* @param string $styleName
* @param ezcDocumentPcssStyleValue $styleValue
*/
public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
{
$mmValue = sprintf('%smm', $styleValue->value);
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:{$styleName}", $mmValue);
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-asian", $mmValue);
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-complex", $mmValue);
}
示例2: createMajorElements
/**
* Create basics tags. Definitions (root), schema (contain types), port type
* and binding.
*
* @return void
*/
protected function createMajorElements()
{
// >> definitions
$this->oDefinitions = $this->createElementNS(self::NS_WSDL, 'wsdl:definitions');
$this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-enc', self::NS_SOAP_ENC);
$this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:soap-env', self::NS_SOAP_ENV);
$this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:tns', $this->sTns);
$this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:wsdl', self::NS_WSDL);
$this->oDefinitions->setAttributeNS(self::NS_XML, 'xmlns:xsd', self::NS_XSD);
$this->oDefinitions->setAttribute('targetNamespace', $this->sTns);
$this->appendChild($this->oDefinitions);
// >> definitions >> types
$oTypes = $this->createElementNS(self::NS_WSDL, 'types');
$this->oDefinitions->appendChild($oTypes);
// >> definitions >> types >> schema
$this->oSchema = $this->createElementNS(self::NS_XSD, 'schema');
$this->oSchema->setAttribute('targetNamespace', $this->sTns);
$oTypes->appendChild($this->oSchema);
// >> definitions >> types >>port type
$this->oPortType = $this->createElementNS(self::NS_WSDL, 'portType');
$this->oPortType->setAttribute('name', $this->oClass->name . 'PortType');
// >> definitions >> types >> binding
$this->oBinding = $this->createElementNS(self::NS_WSDL, 'binding');
$this->oBinding->setAttribute('name', $this->oClass->name . 'Binding');
$this->oBinding->setAttribute('type', 'tns:' . $this->oClass->name . 'PortType');
// >> definitions >> types >> binding >> soap binding
$oBindingSoap = $this->createElementNS(self::NS_SOAP_ENV, 'binding');
$oBindingSoap->setAttribute('style', 'rpc');
$oBindingSoap->setAttribute('transport', self::BINDING);
$this->oBinding->appendChild($oBindingSoap);
}
示例3: createStyle
/**
* Creates the styles with $styleAttributes for the given $odtElement.
*
* @param ezcDocumentOdtStyleInformation $styleInfo
* @param DOMElement $odtElement
* @param array $styleAttributes
* @return void
*/
public function createStyle(ezcDocumentOdtStyleInformation $styleInfo, DOMElement $odtElement, array $styleAttributes)
{
$styleName = $this->getUniqueStyleName($odtElement->localName);
$style = $styleInfo->automaticStyleSection->appendChild($styleInfo->automaticStyleSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:style'));
$style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:family', 'table');
$style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:name', $styleName);
$odtElement->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:style-name', $styleName);
$this->tablePropertyGenerator->createProperty($style, $styleAttributes);
}
示例4: offsetSet
/**
* Required by the ArrayAccess interface.
*
* @param string $offset
* @param string $value
* @return string
*/
public function offsetSet($offset, $value)
{
$this->ensureAppended();
if (strpos($offset, ':') !== false) {
list($ns, $attr) = explode(':', $offset, 2);
return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $attr, $value);
} else {
return $this->_element->setAttribute($offset, $value);
}
}
示例5: getWorksheet
/**
* Returns the DOMElement representation of the worksheet
*
* @return \DOMElement
*/
public function getWorksheet()
{
if (is_null($this->worksheet)) {
$document = $this->getDocument();
$this->worksheet = $this->append('worksheet', array(), $document);
$this->worksheet->setAttributeNS(static::$namespaces['xmlns'], 'xmlns:r', static::$namespaces['relationships']);
}
$this->updateDocument();
return $this->worksheet;
}
示例6: offsetSet
/**
* Required by the ArrayAccess interface.
*
* @param string $offset
* @param string $value
* @return string
*/
public function offsetSet($offset, $value)
{
$this->ensureAppended();
if (strpos($offset, ':') !== false) {
list($ns, $attr) = explode(':', $offset, 2);
// DOMElement::setAttributeNS() requires $qualifiedName to have a prefix
return $this->_element->setAttributeNS(Zend_Feed::lookupNamespace($ns), $offset, $value);
} else {
return $this->_element->setAttribute($offset, $value);
}
}
示例7: __construct
/**
* Create an AttributeValue.
*
* @param mixed $value The value of this element. Can be one of:
* - string Create an attribute value with a simple string.
* - DOMElement(AttributeValue) Create an attribute value of the given DOMElement.
* - DOMElement Create an attribute value with the given DOMElement as a child.
*/
public function __construct($value)
{
assert('is_string($value) || $value instanceof DOMElement');
if (is_string($value)) {
$doc = new DOMDocument();
$this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
$this->element->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', 'xs:string');
$this->element->appendChild($doc->createTextNode($value));
/* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
$this->element->setAttributeNS(SAML2_Const::NS_XS, 'xs:tmp', 'tmp');
$this->element->removeAttributeNS(SAML2_Const::NS_XS, 'tmp');
return;
}
if ($value->namespaceURI === SAML2_Const::NS_SAML && $value->localName === 'AttributeValue') {
$this->element = SAML2_Utils::copyElement($value);
return;
}
$doc = new DOMDocument();
$this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
SAML2_Utils::copyElement($value, $this->element);
}
示例8: createStyle
/**
* Creates the styles with $styleAttributes for the given $odtElement.
*
* @param ezcDocumentOdtStyleInformation $styleInfo
* @param DOMElement $odtElement
* @param array $styleAttributes
*/
public function createStyle(ezcDocumentOdtStyleInformation $styleInfo, DOMElement $odtElement, array $styleAttributes)
{
$styleName = $this->getUniqueStyleName($odtElement->localName);
$style = $styleInfo->automaticStyleSection->appendChild($styleInfo->automaticStyleSection->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:style'));
$style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:family', 'paragraph');
$style->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:name', $styleName);
$odtElement->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:style-name', $styleName);
// Setting the margins in a list contained paragraph results in
// overwriting the list margin. Therefore we skip paragraph property
// generation completely here.
// @TODO: Does this have any strange effects? Find a nicer solution?
if ($odtElement->parentNode->localName !== 'list-item') {
$this->paragraphPropertyGenerator->createProperty($style, $styleAttributes);
}
$this->textPropertyGenerator->createProperty($style, $styleAttributes);
}
示例9: convert
/**
* Converts the 'text-decoration' CSS style.
*
* This method receives a $targetProperty DOMElement and converts the given
* style with $styleName and $styleValue to attributes on this
* $targetProperty.
*
* @param DOMElement $targetProperty
* @param string $styleName
* @param ezcDocumentPcssStyleValue $styleValue
*/
public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue)
{
foreach ($styleValue->value as $listElement) {
switch ($listElement) {
case 'line-through':
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-type', 'single');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-style', 'solid');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-width', 'auto');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-line-through-color', 'font-color');
break;
case 'underline':
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-type', 'single');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-style', 'solid');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-width', 'auto');
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-underline-color', 'font-color');
break;
case 'overline':
break;
case 'blink':
$targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, 'style:text-blinking', 'true');
break;
}
}
}
示例10: offsetSet
/**
* Required by the ArrayAccess interface.
*
* @internal
*/
public function offsetSet($offset, $value)
{
if (!is_scalar($value)) {
throw new InvalidArgumentException('Element values must be scalars, ' . gettype($value) . ' given');
}
$this->_ensureAppended();
if (strpos($offset, ':') !== false) {
list($ns) = explode(':', $offset, 2);
$result = $this->_element->setAttributeNS(Horde_Xml_Element::lookupNamespace($ns), $offset, $value);
} else {
$result = $this->_element->setAttribute($offset, $value);
}
if ($result) {
$this->_expireCachedChildren();
return true;
} else {
return false;
}
}
示例11: _fromArray
/**
* Recursive method to create childs from array
*
* @param \DOMDocument $dom Handler to DOMDocument
* @param \DOMElement $node Handler to DOMElement (child)
* @param array &$data Array of data to append to the $node.
* @param string $format Either 'attribute' or 'tags'. This determines where nested keys go.
* @return void
* @throws \Cake\Utility\Exception\XmlException
*/
protected static function _fromArray($dom, $node, &$data, $format)
{
if (empty($data) || !is_array($data)) {
return;
}
foreach ($data as $key => $value) {
if (is_string($key)) {
if (method_exists($value, 'toArray')) {
$value = $value->toArray();
}
if (!is_array($value)) {
if (is_bool($value)) {
$value = (int) $value;
} elseif ($value === null) {
$value = '';
}
$isNamespace = strpos($key, 'xmlns:');
if ($isNamespace !== false) {
$node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, $value);
continue;
}
if ($key[0] !== '@' && $format === 'tags') {
$child = null;
if (!is_numeric($value)) {
// Escape special characters
// http://www.w3.org/TR/REC-xml/#syntax
// https://bugs.php.net/bug.php?id=36795
$child = $dom->createElement($key, '');
$child->appendChild(new \DOMText($value));
} else {
$child = $dom->createElement($key, $value);
}
$node->appendChild($child);
} else {
if ($key[0] === '@') {
$key = substr($key, 1);
}
$attribute = $dom->createAttribute($key);
$attribute->appendChild($dom->createTextNode($value));
$node->appendChild($attribute);
}
} else {
if ($key[0] === '@') {
throw new XmlException('Invalid array');
}
if (is_numeric(implode('', array_keys($value)))) {
// List
foreach ($value as $item) {
$itemData = compact('dom', 'node', 'key', 'format');
$itemData['value'] = $item;
static::_createChild($itemData);
}
} else {
// Struct
static::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
}
}
} else {
throw new XmlException('Invalid array');
}
}
}
示例12: addAttribute
/**
* Add an attribute to the target element node.
*
* @param \DOMElement $target
* @param \DOMAttr $source
*/
private function addAttribute(\DOMElement $target, \DOMAttr $source)
{
list($prefix, $name, $uri) = $this->getNodeDefinition($source);
if (empty($prefix)) {
$target->setAttribute($name, $source->value);
} else {
$target->setAttributeNS($uri, $prefix . ':' . $name, $source->value);
}
}
示例13: root
public function root(\DOMElement &$root)
{
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:codesearch', 'http://www.google.com/codesearch/schemas/sitemap/1.0');
}
示例14: processAttributesBySchema
/**
* processAttributesBySchema
* Parses customattributes attribute and splits it into actual
* custom: xml attributes, passes processing of normal attributes
* to parent class.
*
* @param DOMElement $element
*/
function processAttributesBySchema($element)
{
// custom attributes conversion
$attr = $element->getAttribute('customattributes');
if ($attr) {
$attrArray = explode('attribute_separation', $attr);
foreach ($attrArray as $attr) {
if ($attr !== '' && strpos($attr, '|') !== false) {
list($attrName, $attrValue) = explode('|', $attr);
$element->setAttributeNS('http://ez.no/namespaces/ezpublish3/custom/', 'custom:' . $attrName, $attrValue);
}
}
}
parent::processAttributesBySchema($element);
}
示例15: setFixedAttributes
/**
* Set attributes which are not (yet?) extracted from PCSS.
*
* @param DOMElement $prop
*/
protected function setFixedAttributes(DOMElement $prop)
{
// Align table to margins specified
$prop->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:align', 'margins');
$prop->setAttributeNS(ezcDocumentOdt::NS_ODT_TABLE, 'table:border-model', 'separating');
}