xml.IXSLProcessor::setXMLTree() / setXSLTree()

  Status: implemented,  Tue Apr 15 13:06:10 2008
  • Created: 2008-04-12 13:35:44+0200
  • Categories: xml
  • Author: friebe

Scope of Change

Two new methods will be added to the xml.IXSLProcessor interface and implementing classes: setXMLTree() and setXSLTree().


Rationale

Allow for a separate implementation.

Functionality



New methods

  interface IXSLProcessor {
// ...

/**
* Set XSL from a tree
*
* @param xml.Tree xsl
*/
public function setXSLTree(Tree $xsl);

/**
* Set XML from a tree
*
* @param xml.Tree xml
*/
public function setXMLTree(Tree $xml);

// ...
}

Example

  with ($proc= new DomXSLProcessor()); {

// Create a stylesheet
$s= new Stylesheet();
$s->setOutputMethod('text');

// Add template
$t= $s->addChild(new Node('xsl:template', NULL, array('match' => '/document')));
$t->addChild(new Node('xsl:value-of', NULL, array('select' => 'name')));

// Create a tree
$t= new Tree();
$t->addChild(new Node('name', 'Timm'));

// Pass them to the processor
$proc->setXSLTree($s); // instead of $proc->setXSLBuf($s->getDeclaration().$s->getSource());
$proc->setXMLTree($t); // instead of $proc->setXMLBuf($t->getDeclaration().$t->getSource());

// Run transformation
$proc->run();
$result= $proc->output();
}

Security considerations

None.

Speed impact

Neglectible.

Dependencies

- xml.DomXSLProcessor changes

Related documents

- http://xp-framework.net/rfc/contrib/rfc0160.diff Implementing patch

Comments

- friebe, Sat Apr 12 14:03:42 2008 The above class a patch to the scriptlet.xml.XMLScriptletResponse class which makes it use the new API.

<EOF>


Table of contents