本文整理汇总了PHP中DOMElement::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::hasAttribute方法的具体用法?PHP DOMElement::hasAttribute怎么用?PHP DOMElement::hasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::hasAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create a PAOS Request element.
*
* @param DOMElement|NULL $xml The XML element we should load.
*/
public function __construct(DOMElement $xml = NULL)
{
if ($xml === NULL) {
return;
}
if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) {
throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.');
} elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') {
throw new Exception('Invalid value of soap-env:mustUnderstand attribute in <paos:Request>.');
}
if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) {
throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.');
} elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') {
throw new Exception('Invalid value of soap-env:actor attribute in <paos:Request>.');
}
if (!$xml->hasAttribute('responseConsumerURL')) {
throw new Exception('Missing responseConsumerURL attribute in <paos:Request>.');
}
$this->responseConsumerURL = $xml->getAttribute('responseConsumerURL');
if (!$xml->hasAttribute('service')) {
throw new Exception('Missing service attribute in <paos:Request>.');
}
$this->service = $xml->getAttribute('service');
if ($xml->hasAttribute('messageID')) {
$this->messageID = $xml->getAttribute('messageID');
}
}
示例2: visit
public function visit(\DOMElement $node, Compiler $context)
{
if ($node->hasAttribute("from-exp")) {
$filename = $node->getAttribute("from-exp");
} elseif ($node->hasAttribute("from")) {
$filename = '"' . $node->getAttribute("from") . '"';
} else {
throw new Exception("The 'from' or 'from-exp' attribute is required");
}
// remove any non-element node
foreach (iterator_to_array($node->childNodes) as $child) {
if (!$child instanceof \DOMElement) {
$child->parentNode->removeChild($child);
}
}
$context->compileChilds($node);
$code = "embed {$filename}";
if ($node->hasAttribute("ignore-missing") && $node->hasAttribute("ignore-missing") !== false) {
$code .= " ignore missing";
}
if ($node->hasAttribute("with")) {
$code .= " with " . $node->getAttribute("with");
}
if ($node->hasAttribute("only") && $node->getAttribute("only") !== "false") {
$code .= " only";
}
$ext = $context->createControlNode($code);
$set = iterator_to_array($node->childNodes);
$n = $node->ownerDocument->createTextNode("\n");
array_unshift($set, $n);
array_unshift($set, $ext);
$set[] = $context->createControlNode("endembed");
DOMHelper::replaceWithSet($node, $set);
}
示例3: __construct
/**
* Initialize an EndpointType.
*
* @param DOMElement|NULL $xml The XML element we should load.
* @throws Exception
*/
public function __construct(DOMElement $xml = NULL)
{
if ($xml === NULL) {
return;
}
if (!$xml->hasAttribute('Binding')) {
throw new Exception('Missing Binding on ' . $xml->tagName);
}
$this->Binding = $xml->getAttribute('Binding');
if (!$xml->hasAttribute('Location')) {
throw new Exception('Missing Location on ' . $xml->tagName);
}
$this->Location = $xml->getAttribute('Location');
if ($xml->hasAttribute('ResponseLocation')) {
$this->ResponseLocation = $xml->getAttribute('ResponseLocation');
}
foreach ($xml->attributes as $a) {
if ($a->namespaceURI === NULL) {
continue;
/* Not namespace-qualified -- skip. */
}
$fullName = '{' . $a->namespaceURI . '}' . $a->localName;
$this->attributes[$fullName] = array('qualifiedName' => $a->nodeName, 'namespaceURI' => $a->namespaceURI, 'value' => $a->value);
}
}
示例4: parse
public function parse(DOMElement $element)
{
if ($element->hasAttribute('variable')) {
$this->variable = $element->getAttribute('variable');
}
if ($element->hasAttribute('value')) {
$this->value = $element->getAttribute('value');
}
for ($i = 0; $i < $element->childNodes->length; $i++) {
$childElement = $element->childNodes->item($i);
if ($childElement->parentNode !== $element) {
continue;
}
if ($childElement instanceof DOMComment || $childElement instanceof DOMText) {
continue;
}
switch ($childElement->nodeName) {
case 'from':
$this->part = new Ezer_XmlAssignStepFromAttribute($childElement);
break;
default:
throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName);
}
}
}
示例5: createRefMark
/**
* Creates a ref-mark as the first element of the given $odtElement, based
* on the ID attribute of the given $docbookElement.
*
* @param DOMElement $docbookElement
* @param DOMElement $odtElement
*/
protected function createRefMark(DOMElement $docbookElement, DOMElement $odtElement)
{
// Work around for DocBook inconsistency in using ID or id. id
// would be correct, if one follows the specs here…
if ($docbookElement->hasAttribute('ID') || $docbookElement->hasAttribute('id')) {
$refMark = $odtElement->insertBefore($odtElement->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:reference-mark'), $odtElement->firstChild);
$refMark->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:name', $docbookElement->hasAttribute('ID') ? $docbookElement->getAttribute('ID') : $docbookElement->getAttribute('id'));
}
}
示例6: parse
/**
* Parse font family.
* @param DOMElement $node
*/
public function parse(DOMElement $node)
{
$this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : '';
$this->name = $node->hasAttribute(IdmlAttributes::Name) ? $node->getAttribute(IdmlAttributes::Name) : '';
$fontNodes = $node->getElementsByTagName('Font');
foreach ($fontNodes as $fontNode) {
$font = new IdmlFont();
$font->parse($fontNode);
$font->fontFamily = $this;
$this->fonts[] = $font;
}
}
示例7: __construct
/**
* Initialize a saml:BaseID, either from scratch or from an existing \DOMElement.
*
* @param \DOMElement|null $xml The XML element we should load, if any.
*/
public function __construct(\DOMElement $xml = null)
{
if ($xml === null) {
return;
}
$this->element = $xml;
if ($xml->hasAttribute('NameQualifier')) {
$this->NameQualifier = $xml->getAttribute('NameQualifier');
}
if ($xml->hasAttribute('SPNameQualifier')) {
$this->SPNameQualifier = $xml->getAttribute('SPNameQualifier');
}
}
示例8: visit
public function visit(\DOMElement $node, Compiler $context)
{
$code = "use ";
if ($node->hasAttribute("from")) {
$code .= '"' . $node->getAttribute("from") . '"';
} else {
throw new Exception("The 'from' attribute is required");
}
if ($node->hasAttribute("with")) {
$code .= " with " . $node->getAttribute("with");
}
$pi = $context->createControlNode($code);
$node->parentNode->replaceChild($pi, $node);
}
示例9: __construct
/**
* Create/parse a mdrpi:RegistrationInfo element.
*
* @param \DOMElement|null $xml The XML element we should load.
* @throws \Exception
*/
public function __construct(\DOMElement $xml = null)
{
if ($xml === null) {
return;
}
if (!$xml->hasAttribute('registrationAuthority')) {
throw new \Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.');
}
$this->registrationAuthority = $xml->getAttribute('registrationAuthority');
if ($xml->hasAttribute('registrationInstant')) {
$this->registrationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('registrationInstant'));
}
$this->RegistrationPolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'RegistrationPolicy');
}
示例10: __construct
/**
* Create/parse a mdrpi:RegistrationInfo element.
*
* @param DOMElement|NULL $xml The XML element we should load.
*/
public function __construct(DOMElement $xml = NULL)
{
if ($xml === NULL) {
return;
}
if (!$xml->hasAttribute('registrationAuthority')) {
throw new Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.');
}
$this->registrationAuthority = $xml->getAttribute('registrationAuthority');
if ($xml->hasAttribute('registrationInstant')) {
$this->registrationInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('registrationInstant'));
}
$this->RegistrationPolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'RegistrationPolicy');
}
示例11: loadFromXml
/**
* @param \DOMElement $xml
* @throws \AerialShip\LightSaml\Error\InvalidXmlException
*/
function loadFromXml(\DOMElement $xml)
{
$name = $this->getXmlNodeName();
if ($xml->localName != $name || $xml->namespaceURI != Protocol::NS_METADATA) {
throw new InvalidXmlException("Expected {$name} element and " . Protocol::NS_METADATA . ' namespace but got ' . $xml->localName);
}
if (!$xml->hasAttribute('Binding')) {
throw new InvalidXmlException("Missing Binding attribute");
}
if (!$xml->hasAttribute('Location')) {
throw new InvalidXmlException("Missing Location attribute");
}
$this->setBinding($xml->getAttribute('Binding'));
$this->setLocation($xml->getAttribute('Location'));
}
示例12: parse
public function parse(DOMElement $element)
{
$this->class = $element->getAttribute('class');
if ($element->hasAttribute('args')) {
$this->args[] = $element->getAttribute('args');
}
for ($i = 0; $i < $element->childNodes->length; $i++) {
$childElement = $element->childNodes->item($i);
if ($childElement->parentNode !== $element) {
continue;
}
if ($childElement instanceof DOMComment || $childElement instanceof DOMText) {
continue;
}
switch ($childElement->nodeName) {
case 'args':
$this->parseArgs($childElement);
break;
case 'targets':
case 'sources':
// already handled by Ezer_XmlStepUtil
break;
default:
throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName);
}
}
}
示例13: __construct
/**
* Initialize a KeyInfo element.
*
* @param DOMElement|NULL $xml The XML element we should load.
*/
public function __construct(DOMElement $xml = NULL)
{
if ($xml === NULL) {
return;
}
if ($xml->hasAttribute('Id')) {
$this->Id = $xml->getAttribute('Id');
}
for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) {
if (!$n instanceof DOMElement) {
continue;
}
if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) {
$this->info[] = new SAML2_XML_Chunk($n);
continue;
}
switch ($n->localName) {
case 'KeyName':
$this->info[] = new SAML2_XML_ds_KeyName($n);
break;
case 'X509Data':
$this->info[] = new SAML2_XML_ds_X509Data($n);
break;
default:
$this->info[] = new SAML2_XML_Chunk($n);
break;
}
}
}
示例14: __construct
/**
* Create a IDPEntry element.
*
* @param DOMElement|NULL $xml The XML element we should load.
*/
public function __construct(DOMElement $xml = NULL)
{
if ($xml === NULL) {
return;
}
if (!$xml->hasAttribute('ProviderID')) {
throw new Exception('Missing required attribute "ProviderID" in <samlp:IDPEntry>.');
}
$this->ProviderID = $xml->getAttribute('ProviderID');
if ($xml->hasAttribute('Name')) {
$this->Name = $xml->getAttribute('Name');
}
if ($xml->hasAttribute('Loc')) {
$this->Loc = $xml->getAttribute('Loc');
}
}
示例15: getClassWeight
/**
* Get an elements class/id weight. Uses regular expressions to tell if this
* element looks good or bad.
*
* @param DOMElement $e
* @return number (Integer)
*/
public function getClassWeight($e)
{
if (!$this->flagIsActive(self::FLAG_WEIGHT_CLASSES)) {
return 0;
}
$weight = 0;
if (preg_match($this->regexps['negative'], $e->tagName)) {
$weight -= 250;
}
if (preg_match($this->regexps['positive'], $e->tagName)) {
$weight += 250;
}
/* Look for a special ID */
if ($e->hasAttribute('id') && $e->getAttribute('id') != '') {
if (preg_match($this->regexps['negative'], $e->getAttribute('id'))) {
$weight -= 150;
}
if (preg_match($this->regexps['positive'], $e->getAttribute('id'))) {
$weight += 150;
}
}
/* Look for a special classname */
if ($e->hasAttribute('class') && $e->getAttribute('class') != '') {
$classes = explode(" ", $e->getAttribute('class'));
foreach ($classes as $class) {
if (preg_match($this->regexps['negative'], $class)) {
$weight -= 25;
}
if (preg_match($this->regexps['positive'], $class)) {
$weight += 25;
}
}
}
return $weight;
}