本文整理汇总了PHP中XSLTProcessor::importStylesheet方法的典型用法代码示例。如果您正苦于以下问题:PHP XSLTProcessor::importStylesheet方法的具体用法?PHP XSLTProcessor::importStylesheet怎么用?PHP XSLTProcessor::importStylesheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XSLTProcessor
的用法示例。
在下文中一共展示了XSLTProcessor::importStylesheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveXML
public function saveXML($me = true)
{
$xml = new XMLDom();
if (!self::$xsl instanceof \XSLTProcessor) {
self::$xsl = new \XSLTProcessor();
self::$xsl->importStylesheet(XMLDom::loadXMLString('<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" method="xml"/>
<xsl:template match="node()|@*" priority="-4">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="/" priority="-4">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>'));
}
if ($me) {
$xml->appendChild($xml->importNode($this, true));
return self::$xsl->transformToXml($xml);
} else {
foreach ($this->childNodes as $node) {
$xml->appendChild($xml->importNode($node, true));
}
}
return self::$xsl->transformToXml($xml);
}
示例2: process
public function process($page)
{
global $_PLUGIN;
//echoall($page);
// call plugins
// $pageXml = olivxml_create($page,"page");
if ($page) {
$pageXml = OLIVPlugin::call(new simpleXmlElement($page), "render");
//------------------------------------------------------------------------------
// convert page xml to html
if (sessionfile_exists(system::OLIV_TEMPLATE_PATH() . "post.xslt")) {
$postStylesheet = sessionxml_load_file(system::OLIV_TEMPLATE_PATH() . "post.xslt");
} else {
OLIVError::fire("postprocessor.php::process - post.xslt file not found");
die;
}
$htmlProcessor = new XSLTProcessor();
$htmlProcessor->importStylesheet($postStylesheet);
$pageString = $htmlProcessor->transformToXML($pageXml);
//echoall($pageXml->asXML());
//------------------------------------------------------------------------------
// run markup parser
$pageString = $this->markup($pageString);
return $pageString;
}
}
示例3: getProcessor
/**
* return the xslt processor with the xsl stylesheet loaded
* @param DOMDocument $xsl
* @return XSLTProcessor
*/
public static function getProcessor($xsl_dom)
{
// get the processor and import stylesheet xsl
$xsl_processor = new XSLTProcessor();
$xsl_processor->importStylesheet($xsl_dom);
return $xsl_processor;
}
示例4: xml2html
function xml2html($xmlcontent, $xsl, $settings)
{
global $debugMode;
global $Settings;
$xmlDoc = new DOMDocument();
$xmlDoc->load($xmlcontent);
if ($debugMode) {
$root = $xmlDoc->documentElement;
$root->setAttribute("debug", "true");
}
foreach (array_keys($settings) as $k) {
$v = $settings[$k];
$root = $xmlDoc->documentElement;
$root->setAttribute($k, $v);
}
$xslDoc = new DOMDocument();
$xslDoc->load($xsl);
// подменить пути overrides
$xpath = new DOMXpath($xslDoc);
$includes = $xpath->query("//xsl:include");
foreach ($includes as $inc) {
$ref = $inc->getAttribute("href");
$newRef = preg_replace('/overrides/i', '../' . $Settings["ThisFolder"] . '/' . $Settings["OverridesFolder"], $ref);
$inc->setAttribute("href", $newRef);
}
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
return $proc->transformToXML($xmlDoc);
}
示例5: toXml
/**
* @see OAIMetadataFormat#toXml
*/
function toXml(&$oaiRecord, $format = null)
{
$record =& $oaiRecord->getData('record');
switch ($format) {
case 'oai_dc':
static $xslDoc, $proc;
if (!isset($xslDoc) || !isset($proc)) {
// Cache the XSL
$xslDoc = new DOMDocument();
$xslDoc->load('http://www.loc.gov/standards/marcxml/xslt/MARC21slim2OAIDC.xsl');
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
}
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($record->getContents());
$xml = $proc->transformToXML($xmlDoc);
// Cheesy: strip the XML header
if (($pos = strpos($xml, '<oai_dc:dc')) > 0) {
$xml = substr($xml, $pos);
}
return $xml;
case 'oai_marc':
case 'marcxml':
return $record->getContents();
default:
fatalError("Unable to convert MARC to {$format}!\n");
}
}
示例6: exec
public function exec() {
$proc = new \XSLTProcessor;
$proc->importStylesheet($this->_stylesheet);
$content = $proc->transformToXML($this->_datafile);
return $content;
}
示例7: process
/**
* Обрабатывает данные.
* @param string $data XML-строка
*/
public function process($data)
{
$errorHandler = new \WebConstructionSet\Xml\LibxmlErrorHandler();
$xml = new \DOMDocument();
if (!$xml->loadXML($data)) {
throw new \ErrorException('Document parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
}
$xsl = new \DOMDocument();
if ($this->xslString) {
if (!$xsl->loadXML($this->xslString)) {
throw new \ErrorException('XSL stylesheet load/parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
}
} else {
$xslPath = $this->getXslStylesheetPath($xml);
if (!$xslPath) {
throw new \ErrorException('XSL stylesheet path is not found.', null, null, __FILE__, __LINE__);
}
if (!$xsl->load($xslPath)) {
throw new \ErrorException('XSL stylesheet load/parse failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
}
}
$xslt = new \XSLTProcessor();
if (!$xslt->importStylesheet($xsl)) {
throw new \ErrorException('Import XSL stylesheet failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
}
$this->resultDoc = $xslt->transformToDoc($xml);
if (!$this->resultDoc) {
throw new \ErrorException('XSLT transform failed. ' . $errorHandler->getErrorString(), null, null, __FILE__, __LINE__);
}
// no return
}
示例8: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$environment = $input->getOption('env');
try {
$transformer = $input->getOption('xsl');
$xsl = new \DOMDocument();
$xsl->load($transformer);
$xslt = new \XSLTProcessor();
$xslt->registerPHPFunctions();
$xslt->importStylesheet($xsl);
$files = $input->getOption('file');
foreach ($files as $file) {
$output->writeln('Transforming file: ' . $file);
$doc = new \DOMDocument();
$doc->load($file);
$xml = $xslt->transformToXml($doc);
$xmlobj = new \SimpleXMLElement($xml);
$xmlobj->asXML('output.xml');
}
} catch (\Exception $ex) {
$exception = new OutputFormatterStyle('red');
$output->getFormatter()->setStyle('exception', $exception);
$output->writeln("\n\n");
$output->writeln('<exception>[Exception in: ' . get_class($this) . ']</exception>');
$output->writeln('<exception>Exception: ' . get_class($ex) . ' with message: ' . $ex->getMessage() . '</exception>');
$output->writeln('<exception>Stack Trace:</exception>');
$output->writeln('<exception>' . $ex->getTraceAsString() . '</exception>');
exit(1);
}
exit(0);
}
示例9: params
/**
* Executes Params XSLT (transformation to be used to convert parameters into query) for given query.
*/
function params()
{
$document =& JFactory::getDocument();
$viewName = JRequest::getVar('view', 'params');
$viewType = $document->getType();
$view =& $this->getView($viewName, $viewType);
$data = JRequest::getVar('data', '', 'post', 'string', JREQUEST_ALLOWRAW);
$query_id = JRequest::getInt('id_query', NULL);
$result = $data;
if ($query_id != NULL && !empty($data)) {
$model_queries =& $this->getModel('queries');
$query = $model_queries->getQuery($query_id);
if ($query != NULL && !empty($query->paramsxsl)) {
$xml = new DOMDocument();
if ($xml->loadXML($data)) {
// start xslt
$xslt = new XSLTProcessor();
$xsl = new DOMDocument();
$xsl->loadXML($query->paramsxsl);
$xslt->importStylesheet($xsl);
$paramset = $xslt->transformToDoc($xml);
$result = $xslt->transformToXML($xml);
if ($result === false) {
// TODO: any joomla function for this?
header('HTTP/1.1 500 Internal Server Error');
}
}
}
}
$view->assign('value', $result);
$view->display();
}
示例10: showArticleById
/**
* @Route("/{volume}/{id}", requirements={"id" = "\d+", "volume" = "\d+"})
* @param $volume
* @param $id
* @param bool|false $showByName
* @return \Symfony\Component\HttpFoundation\Response
*/
public function showArticleById($volume, $id, $showByName = false)
{
$id_article = 'v' . $volume . '-' . $id;
$xml_source = new \DOMDocument();
$xml_source->load('../src/AppBundle/Resources/xml/volume' . $volume . '.xml');
$xslt_root = new \DOMDocument();
$xslt_root->load('../src/AppBundle/Resources/xslt/article.xsl');
$transform = new \XSLTProcessor();
$transform->importStylesheet($xslt_root);
$xpath = new \DOMXpath($xml_source);
$page_debut_xpath = $xpath->query("//div[@type='article' and @xml:id='" . $id_article . "']/preceding::pb[position()\n =1]");
$num_vue = $page_debut_xpath->item(0)->attributes->item(1)->nodeValue;
$page_debut = substr($num_vue, strpos($num_vue, "p") + 1);
$article_result = $xpath->query("//div[@type='article' and @xml:id='" . $id_article . "']");
$vedette_adresse_text = $xpath->query("//div[@type='article' and @xml:id='" . $id_article . "']/child::div[position()=1]/child::p[position()=1]/child::seg[@type='vedette_adresse']/descendant::text()");
$vedette_adresse = '';
if ($vedette_adresse_text->length > 0) {
for ($i = 0; $i < $vedette_adresse_text->length; $i++) {
$vedette_adresse .= $vedette_adresse_text->item($i)->nodeValue;
}
}
$pos_article = null;
if ($article_result->length > 0) {
$content = $article_result->item(0);
$xml_transform = new \DOMDocument();
$xml_transform->appendChild($xml_transform->importNode($content, true));
$article = $transform->transformToDoc($xml_transform)->saveHTML();
$pos_article = intval($id);
$next_article = $pos_article + 1;
$previous_article = $pos_article - 1;
if ($pos_article == 1) {
$previous_article = null;
} else {
if ($showByName) {
$previous_article_id = 'v' . $volume . '-' . $previous_article;
$previous_article_vedette_adresse_text = $xpath->query("//div[@type='article' and @xml:id='" . $previous_article_id . "']/child::div[position()=1]/child::p[position()=1]/child::seg[@type='vedette_adresse']");
if ($previous_article_vedette_adresse_text->length > 0) {
$previous_article = $previous_article_vedette_adresse_text->item(0)->textContent;
$previous_article = str_replace(" ", "_", $previous_article);
}
}
}
$next_article_id = 'v' . $volume . '-' . $next_article;
$xpath_find_next_article = $xpath->query("//div[@type='article' and @xml:id='" . $next_article_id . "']");
if ($xpath_find_next_article->length == 0) {
$next_article = null;
} else {
if ($showByName) {
$next_article_vedette_adresse_text = $xpath->query("//div[@type='article' and @xml:id='" . $next_article_id . "']/child::div[position()=1]/child::p[position()=1]/child::seg[@type='vedette_adresse']");
if ($next_article_vedette_adresse_text->length > 0) {
$next_article = $next_article_vedette_adresse_text->item(0)->textContent;
$next_article = str_replace(" ", "_", $next_article);
}
}
}
return $this->render('AppBundle::article.html.twig', array('article' => $article, 'id_article' => $id, 'name_article' => $vedette_adresse, 'next_article' => $next_article, 'previous_article' => $previous_article, 'volume' => $volume, 'first_page' => $page_debut));
}
return $this->render('AppBundle::404.html.twig', array('error' => 404));
}
示例11: xmltransform
function xmltransform($xml, $xslt_f)
{
$xslt = new XSLTProcessor();
$xmldoc = DomDocument::loadXML($xml, LIBXML_COMPACT);
$xsltdoc = DomDocument::load($xslt_f, LIBXML_COMPACT);
$xslt->importStylesheet($xsltdoc);
return $xslt->transformToXML($xmldoc);
}
示例12: testHeaderDoesNotContainCompleteLogFileContentXsltProcessor
/**
* Tests that the header stylesheet does not reprints the complete log file
* content. This issue occured with some CC versions because the corresponding
* template does not include a default template for <b>/</b>.
*
* @return void
* @group stylesheet
*/
public function testHeaderDoesNotContainCompleteLogFileContentXsltProcessor()
{
$xsl = $this->createXslStylesheet('header.xsl');
$xml = $this->createCruiseControlLog();
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);
$this->assertSame($this->loadExpectedResult(), trim($proc->transformToXml($xml)));
}
示例13: normalize
/**
* XSLT to HTML5 covertation
* @param $htmlDoc
* @return string
*/
public static function normalize($htmlDoc)
{
$normalizerXml = View\Normalizer::getXML();
$normalizerDoc = new \DOMDocument();
$normalizerDoc->loadXML($normalizerXml);
$normalizerProc = new \XSLTProcessor();
$normalizerProc->importStylesheet($normalizerDoc);
return $normalizerProc->transformToXml($htmlDoc);
}
示例14: render
/**
* Process given document into template and render it with given values.
*
* @param DocumentInterface $document
* @param array $values
* @return Result
*/
public function render(DocumentInterface $document, array $values)
{
// fill with values
$xslt = new \XSLTProcessor();
$template = $this->getTemplate($document);
$xslt->importStylesheet($template);
$content = $xslt->transformToDoc($this->createValuesDocument($values));
Processor::undoEscapeXsl($content);
return new Result($content, $document);
}
示例15: convert
private function convert($tableName, \DOMDocument $schemaDocument, $resourcesPath)
{
$template = new \DOMDocument('1.0', 'UTF-8');
$template->load($resourcesPath . '/mysql-schema.xsl');
$xslt = new \XSLTProcessor();
$xslt->importStylesheet($template);
$xslt->setParameter('', 'tableName', $tableName);
$conversionResult = $this->xslt->transformToXml($schemaDocument);
return $conversionResult;
}