本文整理汇总了PHP中Sabre\Xml\Writer::writeAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Writer::writeAttribute方法的具体用法?PHP Writer::writeAttribute怎么用?PHP Writer::writeAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\Xml\Writer
的用法示例。
在下文中一共展示了Writer::writeAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
$reader = new Reader();
// Wrapping the xml in a container, so root-less values can still be
// parsed.
$xml = <<<XML
<?xml version="1.0"?>
<xml-fragment xmlns="http://sabre.io/ns">{$this->getXml()}</xml-fragment>
XML;
$reader->xml($xml);
$elementNamespace = null;
while ($reader->read()) {
if ($reader->depth < 1) {
// Skipping the root node.
continue;
}
switch ($reader->nodeType) {
case Reader::ELEMENT:
$writer->startElement($reader->getClark());
$empty = $reader->isEmptyElement;
while ($reader->moveToNextAttribute()) {
switch ($reader->namespaceURI) {
case '':
$writer->writeAttribute($reader->localName, $reader->value);
break;
case 'http://www.w3.org/2000/xmlns/':
// Skip namespace declarations
break;
default:
$writer->writeAttribute($reader->getClark(), $reader->value);
break;
}
}
if ($empty) {
$writer->endElement();
}
break;
case Reader::CDATA:
case Reader::TEXT:
$writer->text($reader->value);
break;
case Reader::END_ELEMENT:
$writer->endElement();
break;
}
}
}
示例2: writeXml
/**
* Serializes a xCal or xCard object.
*
* @param Component $component
*
* @return string
*/
static function writeXml(Component $component)
{
$writer = new Xml\Writer();
$writer->openMemory();
$writer->setIndent(true);
$writer->startDocument('1.0', 'utf-8');
if ($component instanceof Component\VCalendar) {
$writer->startElement('icalendar');
$writer->writeAttribute('xmlns', Parser\Xml::XCAL_NAMESPACE);
} else {
$writer->startElement('vcards');
$writer->writeAttribute('xmlns', Parser\Xml::XCARD_NAMESPACE);
}
$component->xmlSerialize($writer);
$writer->endElement();
return $writer->outputMemory();
}
示例3: xmlSerialize
/**
* The xmlSerialize metod is called during xml writing.
*
* Use the $writer argument to write its own xml serialization.
*
* An important note: do _not_ create a parent element. Any element
* implementing XmlSerializble should only ever write what's considered
* its 'inner xml'.
*
* The parent of the current element is responsible for writing a
* containing element.
*
* This allows serializers to be re-used for different element names.
*
* If you are opening new elements, you must also close them again.
*
* @param Writer $writer
* @return void
*/
function xmlSerialize(Writer $writer)
{
foreach ($this->getValue() as $val) {
$writer->startElement('{DAV:}supported-method');
$writer->writeAttribute('name', $val);
$writer->endElement();
}
}
示例4: __construct
/**
* @param string $url
* @param \VirCom\ePUAP2\Requests\Logout $request
* @param \Sabre\Xml\Writer $xmlWriter
*/
public function __construct(Requests\Logout $request, Xml\Writer $xmlWriter)
{
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->startDocument();
$xmlWriter->startElement('samlp:LogoutRequest');
$xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
$xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
$xmlWriter->writeAttribute('ID', microtime(true));
$xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z'));
$xmlWriter->writeAttribute('Version', '2.0');
$xmlWriter->startElement('saml:Issuer');
$xmlWriter->write($request->getApplicationId());
$xmlWriter->endElement();
$xmlWriter->startElement('samlp:NameID');
$xmlWriter->write($request->getUsername());
$xmlWriter->endElement();
$xmlWriter->endElement();
$this->parsedMessage = $xmlWriter->outputMemory();
}
示例5: __construct
/**
* @param \VirCom\ePUAP2\Requests\Login $request
* @param \Sabre\Xml\Writer $xmlWriter
*/
public function __construct(Requests\Login $request, Xml\Writer $xmlWriter)
{
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->startDocument();
$xmlWriter->startElement('samlp:AuthnRequest');
$xmlWriter->writeAttribute('xmlns:samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
$xmlWriter->writeAttribute('ID', microtime(true));
$xmlWriter->writeAttribute('IssueInstant', (new \DateTime())->format('Y-m-d\\TH:i:s\\Z'));
$xmlWriter->writeAttribute('Version', '2.0');
$xmlWriter->writeAttribute('Destination', $request->getUrl());
$xmlWriter->writeAttribute('IsPassive', 'false');
$xmlWriter->writeAttribute('AssertionConsumerServiceURL', $request->getResponseUrl());
$xmlWriter->startElement('saml:Issuer');
$xmlWriter->writeAttribute('xmlns:saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
$xmlWriter->write($request->getApplicationId());
$xmlWriter->endElement();
$xmlWriter->endElement();
$this->parsedMessage = $xmlWriter->outputMemory();
}
示例6: xmlSerializeFull
/**
* This method serializes the entire notification, as it is used in the
* response body.
*
* @param Writer $writer
* @return void
*/
function xmlSerializeFull(Writer $writer)
{
$cs = '{' . Plugin::NS_CALENDARSERVER . '}';
switch ($this->type) {
case self::TYPE_LOW:
$type = 'low';
break;
case self::TYPE_MEDIUM:
$type = 'medium';
break;
default:
case self::TYPE_HIGH:
$type = 'high';
break;
}
$writer->startElement($cs . 'systemstatus');
$writer->writeAttribute('type', $type);
if ($this->description) {
$writer->writeElement($cs . 'description', $this->description);
}
if ($this->href) {
$writer->writeElement('{DAV:}href', $this->href);
}
$writer->endElement();
// systemstatus
}
示例7: xmlSerialize
/**
* This method serializes the data into XML. This is used to create xCard or
* xCal documents.
*
* @param Xml\Writer $writer XML writer.
*
* @return void
*/
function xmlSerialize(Xml\Writer $writer)
{
$propertiesByGroup = [];
foreach ($this->children() as $property) {
$group = $property->group;
if (!isset($propertiesByGroup[$group])) {
$propertiesByGroup[$group] = [];
}
$propertiesByGroup[$group][] = $property;
}
$writer->startElement(strtolower($this->name));
foreach ($propertiesByGroup as $group => $properties) {
if (!empty($group)) {
$writer->startElement('group');
$writer->writeAttribute('name', strtolower($group));
}
foreach ($properties as $property) {
switch ($property->name) {
case 'VERSION':
continue;
case 'XML':
$value = $property->getParts();
$fragment = new Xml\Element\XmlFragment($value[0]);
$writer->write($fragment);
break;
default:
$property->xmlSerialize($writer);
break;
}
}
if (!empty($group)) {
$writer->endElement();
}
}
$writer->endElement();
}
示例8: exportXml
public function exportXml()
{
$writer = new Writer();
$writer->openMemory();
$writer->startDocument();
$writer->startElement('Document');
$writer->writeAttribute('xmlns', 'urn:iso:std:iso:20022:tech:xsd:pain.001.001.03');
$writer->setIndent(true);
// header
$writer->startElement('CstmrCdtTrfInitn');
$writer->startElement('GrpHdr');
$writer->writeElement('MsgId', $this->getMessageId());
$writer->writeElement('CreDtTm', $this->getRequestDateTime());
$writer->writeElement('NbOfTxs', $this->getPayaPaymentInfo()->getNumberOfPayments());
$writer->writeElement('CtrlSum', $this->getPayaPaymentInfo()->getTotalTransactionsAmount());
$writer->startElement('InitgPty');
$writer->writeElement('Nm', $this->getPayaPaymentInfo()->getPayerName());
$writer->endElement();
$writer->endElement();
// payment info
$writer->startElement('PmtInf');
$writer->writeElement('PmtInfId', $this->payaPaymentInfo->getPaymentInfoId());
$writer->startElement('PmtMtd');
$writer->writeAttribute('Ccy', 'IRR');
$writer->write($this->payaPaymentInfo->getPaymentMethod());
$writer->endElement();
$writer->writeElement('NbOfTxs', $this->payaPaymentInfo->getNumberOfPayments());
$writer->writeElement('CtrlSum', $this->payaPaymentInfo->getTotalTransactionsAmount());
$writer->writeElement('ReqdExctnDt', $this->payaPaymentInfo->getRequestDate());
$writer->startElement('Dbtr');
$writer->writeElement('Nm', $this->payaPaymentInfo->getPayerName());
$writer->endElement();
$writer->startElement('DbtrAcct');
$writer->startElement('Id');
$writer->writeElement('IBAN', $this->payaPaymentInfo->getPayerIban());
$writer->endElement();
$writer->endElement();
$writer->startElement('DbtrAgt');
$writer->startElement('FinInstnId');
$writer->writeElement('BIC', 'BMJIIRTHXXX');
$writer->endElement();
$writer->endElement();
/** @var PayaPayment $payment */
foreach ($this->payaPaymentInfo->getPayments() as $payment) {
$writer->startElement('CdtTrfTxInf');
$writer->startElement('PmtId');
$writer->writeElement('InstrId', 'EMPTY');
$writer->writeElement('EndToEndId', 'EMPTY');
$writer->endElement();
$writer->startElement('Amt');
$writer->startElement('InstdAmt');
$writer->writeAttribute('Ccy', 'IRR');
$writer->write($payment->getAmount());
$writer->endElement();
$writer->endElement();
$writer->startElement('Cdtr');
$writer->writeElement('Nm', $payment->getCreditorName());
$writer->endElement();
$writer->startElement('CdtrAcct');
$writer->startElement('Id');
$writer->writeElement('IBAN', $payment->getCreditorIban());
$writer->endElement();
$writer->endElement();
$writer->endElement();
}
$writer->endElement();
$writer->endElement();
$writer->endElement();
$writer->endDocument();
return $writer->outputMemory();
}