<commit_before>RFC 0160: xml.IXSLProcessor::setXMLTree() / setXSLTree()
========================================================================
$Id$

@authors: friebe
@created: Sat Apr 12 13:35:44     2008
@status: discussion, ends Mon Apr 14 18:00:00     2008
@category: xml

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
~~~~~~~~~~~
<?php
  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
~~~~~~~
<?php
  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
--------



<EOF><commit_msg>- Add comment on scriptlet.xml.XMLScriptletResponse patch<commit_after>RFC 0160: xml.IXSLProcessor::setXMLTree() / setXSLTree()
========================================================================
$Id$

@authors: friebe
@created: Sat Apr 12 13:35:44     2008
@status: discussion, ends Mon Apr 14 18:00:00     2008
@category: xml

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
~~~~~~~~~~~
<?php
  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
~~~~~~~
<?php
  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>
{'fraction_non_alphanumeric': 0.23117076808351977, 'fraction_numerical': 0.018891374596072583, 'mean_word_length': 2.4393162393162395, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5853540', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1226, 'n_words': 320}