本文整理汇总了PHP中XMLWriter::writeAttributeNS方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeAttributeNS方法的具体用法?PHP XMLWriter::writeAttributeNS怎么用?PHP XMLWriter::writeAttributeNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeAttributeNS方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateEDMX
/**
* Start Generating EDMX file.
*
* @return EDMX xml object.
*/
public function generateEDMX()
{
$this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_ELEMENT, ODataConnectorForMySQLConstants::EDMX_NAMESPACE_1_0);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::EDMX_VERSION, ODataConnectorForMySQLConstants::EDMX_VERSION_VALUE);
$this->xmlWriter->endAttribute();
$this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_DATASERVICES_ELEMENT, null);
$this->xmlWriter->startElement(ODataConnectorForMySQLConstants::SCHEMA);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::NAMESPACE1, $this->schema->namespace);
$this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_NAMESPACE);
$this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE);
$this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::CSDL_VERSION_1_0);
$this->xmlWriter->endAttribute();
try {
$this->writeEntityType();
$this->writeAssociations();
$this->writeEntityContainer();
$this->writeEntityInfo();
$this->writeMappingDetails();
} catch (Exception $e) {
ODataConnectorForMySQLException::createInternalServerError();
}
$this->xmlWriter->endElement();
$this->xmlWriter->endElement();
$this->xmlWriter->endElement();
$this->xmlWriter->endElement();
return $this->xmlWriter->outputMemory(true);
}
示例2: serialize
/**
* Serialize a PlayReadyLicenseResponseTemplate object into a PlayReadyLicenseResponseTemplate XML.
*
* @param PlayReadyLicenseResponseTemplate $template
*
* @return string The PlayReadyLicenseResponseTemplate XML
*/
public static function serialize($template)
{
self::ValidateLicenseResponseTemplate($template);
$writer = new \XMLWriter();
$writer->openMemory();
$writer->startElementNS(null, 'PlayReadyLicenseResponseTemplate', Resources::PRL_XML_NAMESPACE);
$writer->writeAttributeNS('xmlns', 'i', null, Resources::XSI_XML_NAMESPACE);
self::serializeLicenseTemplates($writer, $template->getLicenseTemplates());
$writer->writeElement('ResponseCustomData', $template->getResponseCustomData());
$writer->endElement();
return $writer->outputMemory();
}
示例3: writeAttribute
/**
* Write an attribute with namespace if used
*
* @param \XMLWriter $xmlWriter XMLWriter instance
* @param string $prefix Namespace prefix if any
* @param string $name Attribute name
* @param string $namespace The uri of the namespace
* @param string $value The attribute content
*/
protected function writeAttribute($xmlWriter, $prefix, $name, $namespace, $value)
{
if (empty($namespace)) {
$xmlWriter->writeAttribute($name, $value);
} else {
$xmlWriter->writeAttributeNS($prefix, $name, $namespace, $value);
}
}
示例4: XMLWriter
<?php
/* $Id$ */
$xw = new XMLWriter();
$xw->openMemory();
$xw->setIndent(TRUE);
$xw->setIndentString(' ');
$xw->startDocument('1.0', "UTF-8");
$xw->startElement('root');
$xw->startElementNS('ns1', 'child1', 'urn:ns1');
$xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&');
$xw->writeElement('chars', "special characters: <>\"'&");
$xw->endElement();
$xw->endDocument();
// Force to write and empty the buffer
$output = $xw->flush(true);
print $output;
示例5: writeCatalog
/**
* Construct the catalog entry
*
* @param XmlWriter $xml XML stream to write to
* @param array $data data-blob of i18n and config variables
* @param array $dataset array of the dataset identifiers
*/
function writeCatalog(XMLWriter $xml, array $data, array $dataset)
{
$xml->startElementNS('rdf', 'Description', null);
$xml->writeAttributeNS('rdf', 'about', null, $data['config']['uri'] . '#catalog');
$xml->startElementNS('rdf', 'type', null);
$xml->writeAttributeNS('rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Catalog');
$xml->endElement();
$xml->startElementNS('dcterms', 'license', null);
$xml->writeAttributeNS('rdf', 'resource', null, $data['config']['catalog-license']);
$xml->endElement();
$xml->startElementNS('dcat', 'themeTaxonomy', null);
$xml->writeAttributeNS('rdf', 'resource', null, 'http://eurovoc.europa.eu/');
$xml->endElement();
$xml->writeElementNS('foaf', 'homepage', null, $data['config']['catalog-homepage']);
$xml->startElementNS('dcterms', 'modified', null);
$xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date');
$xml->text(date('Y-m-d'));
$xml->endElement();
$xml->startElementNS('dcterms', 'issued', null);
$xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date');
$xml->text($data['config']['catalog-issued']);
$xml->endElement();
$xml->startElementNS('dcterms', 'publisher', null);
$xml->writeAttributeNS('rdf', 'nodeID', null, $data['ids']['publisher']);
$xml->endElement();
// add language, title and description in each language
writeCatalogI18n($xml, $data);
// add datasets
foreach ($dataset as $key => $value) {
$xml->startElementNS('dcat', 'dataset', null);
$xml->writeAttributeNS('rdf', 'resource', null, $value);
$xml->endElement();
}
$xml->endElement();
}
示例6: serialize
/**
* Serialize a TokenRestrictionTemplate object into a TokenRestrictionTemplate XML
* @param TokenRestrictionTemplate $tokenRestriction
* @return string The TokenRestrictionTemplate XML
*/
public static function serialize($tokenRestriction)
{
if (empty($tokenRestriction->getPrimaryVerificationKey()) && ($tokenRestriction->getOpenIdConnectDiscoveryDocument() == null || empty($tokenRestriction->getOpenIdConnectDiscoveryDocument()->getOpenIdDiscoveryUri()))) {
throw new \RuntimeException("Both PrimaryVerificationKey and OpenIdConnectDiscoveryDocument are null");
}
if (empty($tokenRestriction->getAudience())) {
throw new \RuntimeException("TokenRestrictionTemplate Serialize: Audience is required");
}
if (empty($tokenRestriction->getIssuer())) {
throw new \RuntimeException("TokenRestrictionTemplate Serialize: Issuer is required");
}
$writer = new \XMLWriter();
$writer->openMemory();
$writer->startElementNS(null, 'TokenRestrictionTemplate', Resources::TRT_XML_NAMESPACE);
$writer->writeAttributeNS('xmlns', 'i', null, Resources::XSI_XML_NAMESPACE);
if (!empty($tokenRestriction->getAlternateVerificationKeys())) {
TokenRestrictionTemplateSerializer::serializeAlternateVerificationKeys($writer, $tokenRestriction->getAlternateVerificationKeys());
}
$writer->writeElement("Audience", $tokenRestriction->getAudience());
$writer->writeElement("Issuer", $tokenRestriction->getIssuer());
if (!empty($tokenRestriction->getPrimaryVerificationKey())) {
$writer->startElement('PrimaryVerificationKey');
TokenRestrictionTemplateSerializer::serializeTokenVerificationKey($writer, $tokenRestriction->getPrimaryVerificationKey());
$writer->endElement();
}
if (!empty($tokenRestriction->getRequiredClaims())) {
TokenRestrictionTemplateSerializer::serializeRequiredClaims($writer, $tokenRestriction->getRequiredClaims());
}
if (!empty($tokenRestriction->getTokenType())) {
$writer->writeElement('TokenType', $tokenRestriction->getTokenType());
}
if (!empty($tokenRestriction->getOpenIdConnectDiscoveryDocument())) {
TokenRestrictionTemplateSerializer::serializeOpenIdConnectDiscoveryDocument($writer, $tokenRestriction->getOpenIdConnectDiscoveryDocument());
}
$writer->endElement();
return $writer->outputMemory();
}
示例7: wsdl
public function wsdl()
{
/************************
** SETUP XML
************************/
$uri = sprintf("http://%s/api/soap", $_SERVER['HTTP_HOST']);
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(TRUE);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElementNS('wsdl', 'definitions', 'http://schemas.xmlsoap.org/wsdl/');
$xml->writeAttributeNS('xmlns', 'soap', NULL, "http://schemas.xmlsoap.org/wsdl/soap/");
#$xml->writeAttributeNS('xmlns', 'schema', NULL, $uri);
$xml->writeAttributeNS('xmlns', 'xsd', NULL, "http://www.w3.org/2001/XMLSchema");
$xml->writeAttributeNS('xmlns', 'xsi', NULL, "http://www.w3.org/2001/XMLSchema-instance");
$xml->writeAttributeNS('xmlns', 'tns', NULL, "{$uri}");
$xml->writeAttribute('targetNamespace', "{$uri}");
#$xml->writeAttribute('name', $this->name);
$xml->startElementNS('wsdl', 'documentation', NULL);
$xml->text(sprintf('Auto Generated WSDL For %s Class By Quick_WSDL', $this->name));
$xml->endElement();
/************************
** TYPES
************************/
$xml->startElementNS('wsdl', 'types', NULL);
$xml->startElementNS('xsd', 'schema', NULL);
$xml->writeAttribute('targetNamespace', "{$uri}");
foreach (array_keys($this->ctes) as $n) {
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', $n);
$xml->startElementNS('xsd', 'complexType', NULL);
$xml->startElementNS('xsd', 'sequence', NULL);
foreach ($this->ctes[$n] as $p) {
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', $p->name);
$xml->writeAttribute('type', $p->type);
if ($p->mand) {
$xml->writeAttribute('minOccurs', '1');
$xml->writeAttribute('maxOccurs', '1');
} else {
$xml->writeAttribute('minOccurs', '0');
$xml->writeAttribute('maxOccurs', '1');
}
$xml->endElement();
//element
}
$xml->endElement();
//sequence
$xml->endElement();
//complexType
$xml->endElement();
//element
}
foreach ($this->oper as $o) {
if (!isset($this->ctes[$o])) {
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', sprintf('%s', $o));
$xml->startElementNS('xsd', 'complexType', NULL);
$xml->startElementNS('xsd', 'sequence', NULL);
foreach ($this->msgs[$o] as $p) {
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', $p->name);
$xml->writeAttribute('type', $p->type);
if ($p->mand) {
$xml->writeAttribute('minOccurs', '1');
$xml->writeAttribute('maxOccurs', '1');
} else {
$xml->writeAttribute('minOccurs', '0');
$xml->writeAttribute('maxOccurs', '1');
}
$xml->endElement();
}
$xml->endElement();
//sequence
$xml->endElement();
//complexType
$xml->endElement();
//element
}
if (!isset($this->ctes[sprintf('%sResponse', $o)])) {
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', sprintf('%sResponse', $o));
$xml->startElementNS('xsd', 'complexType', NULL);
$xml->startElementNS('xsd', 'sequence', NULL);
$xml->startElementNS('xsd', 'element', NULL);
$xml->writeAttribute('name', $this->rets[$o]->name);
$xml->writeAttribute('type', $this->rets[$o]->type);
if ($p->mand) {
$xml->writeAttribute('minOccurs', '1');
$xml->writeAttribute('maxOccurs', '1');
} else {
$xml->writeAttribute('minOccurs', '0');
$xml->writeAttribute('maxOccurs', '1');
}
$xml->endElement();
$xml->endElement();
//sequence
$xml->endElement();
//complexType
$xml->endElement();
//.........这里部分代码省略.........
示例8: writeAttributeNS
/**
* @param string $prefix
* @param string $name
* @param string $uri
* @param string $content
* @return bool
*/
public function writeAttributeNS($prefix, $name, $uri = null, $content)
{
if (!$this->hasNSPrefix($prefix)) {
$this->nsArray[$prefix] = $uri;
}
return parent::writeAttributeNS($prefix, $name, $uri, $content);
}
示例9: _packageGovTalkEnvelope
/**
* Packages the message currently stored in the object into a valid GovTalk
* envelope ready for sending.
*
* @return mixed The XML package (as a string) in GovTalk format, or false on failure.
*/
protected function _packageGovTalkEnvelope()
{
// Firstly check we have everything we need to build the envelope...
if (isset($this->_messageClass) && isset($this->_messageQualifier)) {
if (isset($this->_govTalkSenderId) && isset($this->_govTalkPassword)) {
if (isset($this->_messageAuthType)) {
// Generate the transaction ID...
$this->_generateTransactionId();
if (isset($this->_messageBody)) {
// Create the XML document (in memory)...
$package = new XMLWriter();
$package->openMemory();
$package->setIndent(true);
// Packaging...
$package->startElement('GovTalkMessage');
$xsiSchemaLocation = 'http://www.govtalk.gov.uk/documents/envelope-v2-0.xsd';
if ($this->_additionalXsiSchemaLocation !== null) {
$xsiSchemaLocation .= ' ' . $this->_additionalXsiSchemaLocation;
}
$package->writeAttribute('xmlns', 'http://www.govtalk.gov.uk/CM/envelope');
$package->writeAttributeNS('xsi', 'schemaLocation', 'http://www.w3.org/2001/XMLSchema-instance', $xsiSchemaLocation);
$package->writeElement('EnvelopeVersion', '2.0');
// Header...
$package->startElement('Header');
// Message details...
$package->startElement('MessageDetails');
$package->writeElement('Class', $this->_messageClass);
$package->writeElement('Qualifier', $this->_messageQualifier);
if ($this->_messageFunction !== null) {
$package->writeElement('Function', $this->_messageFunction);
}
$package->writeElement('TransactionID', $this->_transactionId);
if ($this->_messageCorrelationId !== null) {
$package->writeElement('CorrelationID', $this->_messageCorrelationId);
}
if ($this->_messageTransformation !== 'XML') {
$package->writeElement('Transformation', $this->_messageTransformation);
}
$package->writeElement('GatewayTest', $this->_govTalkTest);
$package->endElement();
# MessageDetails
// Sender details...
$package->startElement('SenderDetails');
// Authentication...
$package->startElement('IDAuthentication');
$package->writeElement('SenderID', $this->_govTalkSenderId);
$package->startElement('Authentication');
switch ($this->_messageAuthType) {
case 'alternative':
if ($authenticationArray = $this->generateAlternativeAuthentication($this->_transactionId)) {
$package->writeElement('Method', $authenticationArray['method']);
$package->writeElement('Value', $authenticationArray['token']);
} else {
return false;
}
break;
case 'clear':
$package->writeElement('Method', 'clear');
$package->writeElement('Value', $this->_govTalkPassword);
break;
}
$package->endElement();
# Authentication
$package->endElement();
# IDAuthentication
if ($this->_senderEmailAddress !== null) {
$package->writeElement('EmailAddress', $this->_senderEmailAddress);
}
$package->endElement();
# SenderDetails
$package->endElement();
# Header
// GovTalk details...
$package->startElement('GovTalkDetails');
// Keys...
if (count($this->_govTalkKeys) > 0) {
$package->startElement('Keys');
foreach ($this->_govTalkKeys as $keyPair) {
$package->startElement('Key');
$package->writeAttribute('Type', $keyPair['type']);
$package->text($keyPair['value']);
$package->endElement();
# Key
}
$package->endElement();
# Keys
}
// Target details...
if (count($this->_messageTargetDetails) > 0) {
$package->startElement('TargetDetails');
foreach ($this->_messageTargetDetails as $targetOrganisation) {
$package->writeElement('Organisation', $targetOrganisation);
}
$package->endElement();
//.........这里部分代码省略.........
示例10: writeAttributeNS
public function writeAttributeNS($prefix, $name, $uri, $content)
{
$this->xmlWriter->writeAttributeNS($prefix, $name, $uri, $content);
}
示例11: fiskalsve
function fiskalsve()
{
$zahtjev = $this->input->post('request');
$msg = '';
$uspjelo = 0;
$nijeuspjelo = 0;
//$firma = $this->fiskal->getById('firma', 'fi_id', $this->session->userdata('firmaID'));
$firma = $this->fiskal->getFirma();
//dohvati podatke za sve nefiskalizirane
$nefiskalizirani = $this->fiskal->getNefiskalizirane();
//foreach ID
if ($nefiskalizirani) {
foreach ($nefiskalizirani as $dokument) {
//dohvati pojedinacno
$prikaziStavke = $this->fiskal->getstavke($dokument->do_id);
$zaglavlje = $this->fiskal->getDokumentZag($dokument->do_id);
$rekapitualcijaporeza = $this->fiskal->rekapitulacijaporeza($dokument->do_id);
//Init XML
$doc = new DOMDocument();
$doc->formatOutput = true;
//XML
$ns = 'tns';
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(True);
$writer->startElementNs($ns, 'RacunZahtjev', null);
$writer->writeAttributeNS("xmlns", "tns", null, "http://www.apis-it.hr/fin/2012/types/f73");
$writer->writeAttributeNS("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
$writer->startElementNs($ns, 'Racun', null);
$writer->writeElementNs($ns, 'Oib', null, $firma->fi_oib);
$writer->writeElementNs($ns, 'USustPdv', null, $firma->fi_usustavuPDV);
$writer->writeElementNs($ns, 'DatVrijeme', null, date("d.m.Y", strtotime($zaglavlje->do_datum)) . date("\\Th:i:s", strtotime($zaglavlje->do_vrijeme)));
// date('d.m.Y\Th:i:s'));
$writer->writeElementNs($ns, 'OznSlijed', null, 'N');
/* P ili N => P na nivou Poslovnog prostora, N na nivou naplatnog uredaja */
$writer->startElementNs($ns, 'BrRac', null);
$writer->writeElementNs($ns, 'BrOznRac', null, $zaglavlje->do_broj);
$writer->writeElementNs($ns, 'OznPosPr', null, $zaglavlje->PP);
$writer->writeElementNs($ns, 'OznNapUr', null, $zaglavlje->NU);
$writer->endElement();
/* #BrRac */
$writer->startElementNs($ns, 'Pdv', null);
if (!empty($rekapitualcijaporeza)) {
$rank = 0;
foreach ($rekapitualcijaporeza as $porez) {
$writer->startElementNs($ns, 'Porez', null);
$writer->writeElementNs($ns, 'Stopa', null, $porez->porez_pz_posto);
$writer->writeElementNs($ns, 'Osnovica', null, $porez->sumaIznosa);
$writer->writeElementNs($ns, 'Iznos', null, number_format($porez->sumaPorez, 2, '.', ''));
$writer->endElement();
/* #Porez */
}
}
$writer->endElement();
/* #Pdv */
if (!empty($rekapitualcijaporeza)) {
$rank = 0;
foreach ($rekapitualcijaporeza as $porez) {
if ($porez->porez_pz_posto == "0") {
$writer->writeElementNs($ns, 'IznosOslobPdv', null, number_format($porez->sumaIznosa + $porez->sumaPorez, 2, '.', ''));
}
}
}
//$writer->writeElementNs($ns, 'IznosNePodlOpor', null, number_format($zaglavlje->do_iznos + $zaglavlje->do_iznosPDV, 2,'.',''));
$writer->writeElementNs($ns, 'IznosUkupno', null, number_format($zaglavlje->do_iznos + $zaglavlje->do_iznosPDV, 2, '.', ''));
$writer->writeElementNs($ns, 'NacinPlac', null, $zaglavlje->sp_oznaka);
$writer->writeElementNs($ns, 'OibOper', null, $zaglavlje->op_oib);
$writer->writeElementNs($ns, 'NakDost', null, '1');
$writer->endElement();
/* #Racun */
$writer->endElement();
/* #RacunZahtjev */
$writer->endDocument();
$XMLRequest = $writer->outputMemory();
$doc->loadXML($XMLRequest);
//file_put_contents("racun".$dokument->do_id.".xml",$XMLRequest);
//fiskaliziraj
if ($firma != FALSE) {
try {
$fis = new Fiskalizator($firma->fi_certifikat, $this->decrypt($firma->fi_pass));
//Produkcijski mode
//$fis->setProductionMode();
$fis->doRequest($doc);
#custom timeout and number of retries on network error, default is 3 retries and 5 seconds timeout tolerance
#$fis->doRequest($doc, 10, 5.2);
if ($fis->getRequestType() == 'RacunZahtjev') {
//echo 'JIR: '.$fis->getJIR().'<br>';
//echo 'ZKI: '.$fis->getZKI().'<br>';
$msg = '<pre class="bg-success">Uspješno fiskalizirani svi dokument!</pre>';
$uspjelo = $uspjelo + 1;
//update raèun
$dok['do_zki'] = $fis->getZKI();
$dok['do_jir'] = $fis->getJIR();
$this->fiskal->update("dokument", "do_id", $zaglavlje->do_id, $dok);
}
} catch (Exception $e) {
if ($zahtjev == 'RacunZahtjev') {
//update raèun
$dok['do_zki'] = $fis->getZKI();
//.........这里部分代码省略.........
示例12: Exception
}
try {
$xmlWriter = new \XMLWriter();
/**
* @throws Exception
*/
if (false === $xmlWriter->openMemory()) {
throw new Exception('Can not start XMLWriter memory');
}
/**
* @throws Exception
*/
if (false === $xmlWriter->startElement('map')) {
throw new Exception('Can not start map element');
}
$xmlWriter->writeAttributeNS('xmlns', 'xsi', null, 'https://raw.githubusercontent.com/jeschkec/GozintograPHP/master/src/main/ressources/schema/gozintographp.xsd');
} catch (Exception $exception) {
fwrite(STDERR, $exception->getMessage());
exit(3);
}
/**
*
*/
foreach ($files as $File) {
try {
$gozintographp = new Application($File);
$gozintographp->read();
$gozintographp->parse();
$gozintographp->dump(new \XMLWriter());
} catch (Exception $exception) {
fwrite(STDERR, $exception->getMessage());