Ejemplo n.º 1
0
 protected function setupStoreData()
 {
     // Using XMLWriter because SimpleXML namespaces on attribute names
     $this->doc = new XMLWriter();
     $this->doc->openMemory();
     $this->doc->setIndent(true);
     $this->doc->setIndentString('    ');
     $this->doc->startDocument('1.0', 'UTF-8');
     $this->doc->startElement('feed');
     $this->doc->writeAttribute('xmlns', 'http://www.w3.org/2005/Atom');
     $this->doc->writeAttribute('xmlns:g', 'http://base.google.com/ns/1.0');
     $this->doc->writeElement('title', $this->getConfig('title'));
     $this->doc->startElement('link');
     $this->doc->writeAttribute('rel', 'self');
     $this->doc->writeAttribute('href', $this->_store->getBaseUrl());
     $this->doc->endElement();
     $date = new Zend_Date();
     $this->doc->writeElement('updated', $date->get(Zend_Date::ATOM));
     $this->doc->startElement('author');
     $this->doc->writeElement('name', $this->getConfig('author'));
     $this->doc->endElement();
     $url = $this->_store->getBaseUrl();
     $day = $date->toString('yyyy-MM-dd');
     $path = $this->getConfig('output');
     $filename = $path . '/' . str_replace('+', '-', strtolower(urlencode($this->_store->getName()))) . '-products.xml';
     $this->doc->writeElement('id', 'tag:' . $url . ',' . $day . ':' . $filename);
 }
Ejemplo n.º 2
0
 /**
  * Create new XMLWriter
  *
  * @param int $tempLocation Temporary storage location
  * @param string $tempFolder Temporary storage folder
  */
 public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = './')
 {
     // Create internal XMLWriter
     $this->xmlWriter = new \XMLWriter();
     // Open temporary storage
     if ($tempLocation == self::STORAGE_MEMORY) {
         $this->xmlWriter->openMemory();
     } else {
         // Create temporary filename
         $this->tempFile = @tempnam($tempFolder, 'xml');
         // Open storage
         if ($this->xmlWriter->openUri($this->tempFile) === false) {
             // Fallback to memory...
             $this->xmlWriter->openMemory();
         }
     }
     // Set xml Compatibility
     $compatibility = Settings::getCompatibility();
     if ($compatibility) {
         $this->xmlWriter->setIndent(false);
         $this->xmlWriter->setIndentString('');
     } else {
         $this->xmlWriter->setIndent(true);
         $this->xmlWriter->setIndentString('  ');
     }
 }
Ejemplo n.º 3
0
 /**
  * Create a new PHPPowerPoint_Shared_XMLWriter instance
  *
  * @param int		$pTemporaryStorage			Temporary storage location
  * @param string	$pTemporaryStorageFolder	Temporary storage folder
  */
 public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = './')
 {
     // Create internal XMLWriter
     $this->_xmlWriter = new XMLWriter();
     // Open temporary storage
     if ($pTemporaryStorage == self::STORAGE_MEMORY) {
         $this->_xmlWriter->openMemory();
     } else {
         // Create temporary filename
         $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
         // Open storage
         if ($this->_xmlWriter->openUri($this->_tempFileName) === false) {
             // Fallback to memory...
             $this->_xmlWriter->openMemory();
         }
     }
     // Set default values
     // proposed to be false in production version
     $this->_xmlWriter->setIndent(true);
     //$this->_xmlWriter->setIndent(false);
     // Set indent
     // proposed to be '' in production version
     $this->_xmlWriter->setIndentString('  ');
     //$this->_xmlWriter->setIndentString('');
 }
Ejemplo n.º 4
0
 /**
  * Create new XMLWriter
  *
  * @param int $tempLocation Temporary storage location
  * @param string $tempFolder Temporary storage folder
  */
 public function __construct($tempLocation = self::STORAGE_MEMORY, $tempFolder = './')
 {
     // Create internal XMLWriter
     $this->xmlWriter = new \XMLWriter();
     // Open temporary storage
     if ($tempLocation == self::STORAGE_MEMORY) {
         $this->xmlWriter->openMemory();
     } else {
         // Create temporary filename
         $this->tempFile = @tempnam($tempFolder, 'xml');
         // Fallback to memory when temporary file cannot be used
         // @codeCoverageIgnoreStart
         // Can't find any test case. Uncomment when found.
         if ($this->xmlWriter->openUri($this->tempFile) === false) {
             $this->xmlWriter->openMemory();
         }
         // @codeCoverageIgnoreEnd
     }
     // Set xml Compatibility
     $compatibility = Settings::hasCompatibility();
     if ($compatibility) {
         $this->xmlWriter->setIndent(false);
         $this->xmlWriter->setIndentString('');
     } else {
         $this->xmlWriter->setIndent(true);
         $this->xmlWriter->setIndentString('  ');
     }
 }
Ejemplo n.º 5
0
 /**
  * Set and instantiate new UTF-8 XML document
  */
 public function __construct()
 {
     $this->context = new \XMLWriter();
     $this->context->openMemory();
     $this->context->startDocument('1.0', 'UTF-8');
     $this->context->setIndent(true);
     $this->context->setIndentString("  ");
 }
Ejemplo n.º 6
0
 /**
  * Converts array with export data to XML format.
  *
  * @param array $array
  *
  * @return string
  */
 public function write(array $array)
 {
     $this->xmlWriter->openMemory();
     $this->xmlWriter->setIndent($this->formatOutput);
     $this->xmlWriter->setIndentString('    ');
     $this->xmlWriter->startDocument('1.0', 'UTF-8');
     $this->fromArray($array);
     $this->xmlWriter->endDocument();
     return $this->xmlWriter->outputMemory();
 }
Ejemplo n.º 7
0
 /**
  * Defined by ReportInterface.
  *
  * @see ReportInterface::start()
  */
 public function start()
 {
     $this->writer = new XMLWriter();
     $this->writer->openMemory();
     $this->writer->setIndent(true);
     $this->writer->setIndentString('    ');
     $this->writer->startDocument('1.0', 'UTF-8');
     $this->writer->startElement('checkstyle');
     $this->writer->writeAttribute('version', '5.5');
 }
Ejemplo n.º 8
0
 public function initialize(Config $config, $directory, $filenameWithDate = false)
 {
     $this->setFilename($config, $directory, $filenameWithDate);
     $this->xml = new \XMLWriter();
     $this->xml->openUri($this->filename);
     $this->xml->startDocument('1.0', 'utf-8');
     $this->xml->setIndent(true);
     $this->xml->setIndentString('    ');
     $this->xml->writeComment('list of ' . $config->getClassName());
     $this->elementName = strtolower($config->getClassNameLastPart());
     $this->xml->startElement(strtolower($config->getClassNameLastPart(true)));
 }
Ejemplo n.º 9
0
 /**
  * @param Definition $definition
  * @param \XMLWriter $writer
  */
 protected function initialize($writer, Definition $definition)
 {
     $writer->setIndent(true);
     $writer->setIndentString("    ");
     $writer->startDocument("1.0", "UTF-8");
     $writer->startElement($definition->getNodeName() ?: "root");
 }
Ejemplo n.º 10
0
 /**
  * Creates a new XML document.
  * 
  * @param	string		$rootElement
  * @param	string		$namespace
  * @param	string		$schemaLocation
  * @param	array<string>	$attributes
  */
 public function beginDocument($rootElement, $namespace, $schemaLocation, array $attributes = array())
 {
     if ($this->activeDocument) {
         throw new SystemException("Could not begin a new document unless the previous is finished");
     }
     if ($this->xml === null) {
         $this->xml = new \XMLWriter();
         $this->xml->openMemory();
         $this->xml->setIndent(true);
         $this->xml->setIndentString("\t");
     }
     $this->xml->startDocument('1.0', 'UTF-8');
     $this->startElement($rootElement);
     $attributes = array_merge($attributes, array('xmlns' => $namespace, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => $namespace . ' ' . $schemaLocation));
     $this->writeAttributes($attributes);
     $this->activeDocument = true;
 }
Ejemplo n.º 11
0
 public function testSetRebateName()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new RebateType();
     $this->setExpectedException('InvalidArgumentException');
     $node->setRebateName(str_repeat('x', 300));
 }
Ejemplo n.º 12
0
 /**
  * 
  */
 function __construct($config = array())
 {
     if (!class_exists('XMLWriter')) {
         require_once 'Spizer/Logger/Exception.php';
         throw new Spizer_Logger_Exception('The XMLWriter PHP extension is not loaded');
     }
     $this->_config = array_merge($this->_config, $config);
     $this->_writer = new XMLWriter();
     if (!$this->_writer->openUri($this->_config['target'])) {
         require_once 'Spizer/Logger/Exception.php';
         throw new Spizer_Logger_Exception('Cannot open log file "' . $this->_config['target'] . '" for writing');
     }
     $this->_writer->setIndent($this->_config['indent']);
     $this->_writer->setIndentString($this->_config['indentstr']);
     $this->_writer->startDocument('1.0', 'UTF-8');
     $this->_writer->startElement('spizerlog');
     $this->_writer->writeAttribute('xmlns', 'http://arr.gr/spizer/xmllog/1.0');
     $this->_writer->writeAttribute('microtime', microtime(true));
 }
 public function testSetStandardProductId()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new StandardProductId();
     $this->setExpectedException('InvalidArgumentException');
     $node->setType('Foo');
 }
Ejemplo n.º 14
0
 /**
  * Execute parsing
  *
  * @param \PhpHal\Resource $resource
  * @return mixed
  */
 public function execute(Resource $resource)
 {
     $writer = new BasicXmlWriter();
     $writer->openMemory();
     $writer->setIndentString('  ');
     $writer->setIndent($this->pretty);
     $writer->startDocument('1.0');
     $this->resourceToArray($writer, $resource);
     return $writer->outputMemory();
 }
Ejemplo n.º 15
0
Archivo: XML.php Proyecto: fewlines/xml
 /**
  * @param string $resource
  */
 private function writeTo($resource)
 {
     $this->writer->openURI($resource);
     $this->writer->startDocument($this->version, $this->encoding);
     $this->writer->setIndent(true);
     $this->writer->setIndentString("\t");
     $this->getRoot()->save($this->writer);
     $this->writer->endDocument();
     $this->writer->flush();
 }
Ejemplo n.º 16
0
 /**
  * @depends testConditionInfo
  */
 public function testSetConditionType()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new ConditionInfo();
     $this->setExpectedException('InvalidArgumentException');
     $node->setConditionType('Foo');
 }
Ejemplo n.º 17
0
 public function testSetBaseCurrencyCode()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new CurrencyAmount();
     $this->setExpectedException('InvalidArgumentException');
     $node->setBaseCurrencyCode('Foo');
 }
Ejemplo n.º 18
0
 public function testSetBatteryType()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $battery = new Battery();
     $this->setExpectedException('InvalidArgumentException');
     $battery->setBatteryType('foo');
 }
Ejemplo n.º 19
0
 public function testSetPriority()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $this->setExpectedException('InvalidArgumentException');
     $product = new ClothingProduct($xml);
     $product->setPriority(100);
 }
 /**
  * @depends testJewelryWatchProduct
  */
 public function testSetLithiumBatteryPackaging()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $product = new JewelryWatchProduct($xml);
     $this->setExpectedException('InvalidArgumentException');
     $product->setLithiumBatteryPackaging('Foo');
 }
Ejemplo n.º 21
0
 /**
  * Init feed with shared properties
  *
  * @param MwsClient $client 
  */
 public function __construct(MwsClient $client)
 {
     $this->client = $client;
     $this->xml = new \XMLWriter();
     $this->xml->openMemory();
     $this->xml->setIndent(true);
     $this->xml->setIndentString("\t");
     $this->xml->startDocument('1.0', 'UTF-8');
     $this->xml->startElement('AmazonEnvelope');
     $this->xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $this->xml->writeAttribute('xsi:noNamespaceSchemaLocation', 'amzn-envelope.xsd');
     // Header
     $this->xml->startElement('Header');
     $this->xml->writeElement('DocumentVersion', '1.01');
     $this->xml->writeElement('MerchantIdentifier', $client->getConfig('merchant_id'));
     $this->xml->endElement();
     $this->xml->writeElement('MessageType', $this->feedType);
     $this->xml->writeElement('PurgeAndReplace', 'false');
 }
Ejemplo n.º 22
0
 /**
  * Serialize the resource to the specified output stream.
  *
  * @param mixed $resource
  *
  * @return string
  */
 public function serialize($resource)
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("    ");
     $xml->startDocument('1.0', 'UTF-8');
     $resource->toXml($xml);
     $xml->endDocument();
     return $xml->outputMemory(true);
 }
Ejemplo n.º 23
0
function _pugpig_subs_start_xml_writer()
{
    header('Content-type: text/xml');
    header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
    $writer = new XMLWriter();
    $writer->openMemory();
    $writer->setIndent(TRUE);
    $writer->setIndentString('  ');
    $writer->startDocument('1.0', 'UTF-8');
    return $writer;
}
Ejemplo n.º 24
0
 public static function fromArray($data, $encoding = 'UTF-8')
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString('  ');
     $xml->startDocument('1.0', $encoding);
     self::_write($xml, $data);
     $xml->endDocument();
     return $xml->outputMemory(true);
 }
Ejemplo n.º 25
0
 /**
  * Create a new \PhpOffice\PhpPowerpoint\Shared\XMLWriter instance
  *
  * @param int $pTemporaryStorage Temporary storage location
  * @param string $pTemporaryStorageDir Temporary storage folder
  */
 public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageDir = './', $compatibility = false)
 {
     // Create internal XMLWriter
     $this->xmlWriter = new \XMLWriter();
     // Open temporary storage
     if ($pTemporaryStorage == self::STORAGE_MEMORY) {
         $this->xmlWriter->openMemory();
     } else {
         // Create temporary filename
         $this->tempFileName = @tempnam($pTemporaryStorageDir, 'xml');
         // Open storage
         $this->xmlWriter->openUri($this->tempFileName);
     }
     if ($compatibility) {
         $this->xmlWriter->setIndent(false);
         $this->xmlWriter->setIndentString('');
     } else {
         $this->xmlWriter->setIndent(true);
         $this->xmlWriter->setIndentString('  ');
     }
 }
Ejemplo n.º 26
0
 public function testLengthDimension()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new LengthDimension(1, 'IN');
     $node->setValue(1)->setUnitOfMeasure('IN');
     $node->writeXml($xml, 'LengthDimension');
     $dom = new \DOMDocument();
     $dom->loadXML($xml->outputMemory(true));
     $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../XSD/DataType.xsd'));
 }
 public function testSpatialDimensions()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new SpatialDimensions(LengthDimension::factory(1, 'IN'), LengthDimension::factory(2, 'IN'), LengthDimension::factory(3, 'IN'));
     $node->setLength(LengthDimension::factory(1, 'IN'))->setWidth(LengthDimension::factory(2, 'IN'))->setHeight(LengthDimension::factory(3, 'IN'));
     $node->writeXml($xml, 'SpatialDimensions');
     $dom = new \DOMDocument();
     $dom->loadXML($xml->outputMemory(true));
     $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../XSD/DataType.xsd'));
 }
 public function testTemperatureRatingDimension()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new TemperatureRatingDimension(100, 'degrees-fahrenheit');
     $node->setValue(100)->setUnitOfMeasure('degrees-fahrenheit');
     $node->writeXml($xml, 'TemperatureRatingDimension');
     $dom = new \DOMDocument();
     $dom->loadXML($xml->outputMemory(true));
     $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../XSD/DataType.xsd'));
 }
Ejemplo n.º 29
0
 public function testSale()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->setIndentString("\t");
     $node = new Sale(new \DateTime(), new \DateTime(), CurrencyAmount::factory(1, 'USD'));
     $node->setStartDate(new \DateTime())->setEndDate(new \DateTime())->setSalePrice(CurrencyAmount::factory(1, 'USD'));
     $node->writeXml($xml, 'Sale');
     $dom = new \DOMDocument();
     $dom->loadXML($xml->outputMemory(true));
     $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../XSD/DataType.xsd'));
 }
 /**
  * Writes view informations into a XML file, replacing or creating it if necessary.
  */
 public function saveToFile()
 {
     $XMLViewDoc = new XMLWriter();
     $XMLViewDoc->openURI('file://' . VIEW_DATA_DIR . '/' . $this->id . '.xml');
     $XMLViewDoc->setIndent(true);
     $XMLViewDoc->setIndentString('    ');
     $XMLViewDoc->startDocument();
     $XMLViewDoc->startElement("view");
     $XMLViewDoc->writeElement("slice-transformation-filename", $this->getXsltSliceToSVG());
     $XMLViewDoc->writeElement("obsel-transformation-filename", $this->getXsltObselToSVG());
     $XMLViewDoc->writeElement("default-scale", $this->getDefaultScale());
     $XMLViewDoc->writeElement("css-filename", $this->getCssFileName());
     $XMLViewDoc->endElement();
 }