-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff18c9e
commit f9a4832
Showing
10 changed files
with
155 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
namespace Genkgo\Xsl\Xpath; | ||
|
||
use DOMNode; | ||
use Genkgo\Xsl\Callback\PhpCallback; | ||
use Genkgo\Xsl\Callback\ReplaceFunctionInterface; | ||
use Genkgo\Xsl\Schema\XsSequence; | ||
|
||
/** | ||
* Class Sequence | ||
* @package Genkgo\Xsl\Xpath | ||
*/ | ||
final class ForLoopConstructor implements ReplaceFunctionInterface | ||
{ | ||
/** | ||
* @param Lexer $lexer | ||
* @param DOMNode $currentElement | ||
* @return array|\string[] | ||
*/ | ||
public function replace(Lexer $lexer, DOMNode $currentElement) | ||
{ | ||
$resultTokens = []; | ||
$resultTokens[] = 'php:function'; | ||
$resultTokens[] = '('; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = PhpCallback::class.'::callStatic'; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = ','; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = static::class; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = ','; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = 'call'; | ||
$resultTokens[] = '\''; | ||
$resultTokens[] = ','; | ||
$resultTokens[] = $lexer->peek($lexer->key() - 2); | ||
$resultTokens[] = ','; | ||
$resultTokens[] = $lexer->peek($lexer->key() + 2); | ||
$resultTokens[] = ')'; | ||
$resultTokens[] = '/'; | ||
$resultTokens[] = 'xs:sequence'; | ||
$resultTokens[] = '/'; | ||
$resultTokens[] = '*'; | ||
|
||
$lexer->seek($lexer->key() + 2); | ||
|
||
return $resultTokens; | ||
} | ||
|
||
/** | ||
* @param $first | ||
* @param $last | ||
* @return mixed | ||
* @throws \Genkgo\Xsl\Schema\Exception\UnknownSequenceItemException | ||
*/ | ||
public static function call($first, $last) | ||
{ | ||
return XsSequence::fromArray(range($first, $last)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
namespace Genkgo\Xsl\Integration\Xpath; | ||
|
||
class ForLoopTest extends AbstractXpathTest | ||
{ | ||
public function testSimple() | ||
{ | ||
$result = $this->transformFile('Stubs/Xpath/ForLoop/simple.xsl'); | ||
$this->assertContains('1 2 3 4 5 6 7 8 9 10', $result); | ||
} | ||
|
||
public function testForEach() | ||
{ | ||
$result = $this->transformFile('Stubs/Xpath/ForLoop/for-each.xsl'); | ||
$this->assertContains('12345678910', $result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:output omit-xml-declaration="yes" /> | ||
|
||
<xsl:template match="collection"> | ||
<xsl:for-each select="1 to 10"> | ||
<xsl:value-of select="." /> | ||
</xsl:for-each> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:output omit-xml-declaration="yes" /> | ||
|
||
<xsl:template match="collection"> | ||
<xsl:variable name="list" select="1 to 10" /> | ||
<xsl:value-of select="$list" /> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:output omit-xml-declaration="yes" /> | ||
|
||
<xsl:template match="collection"> | ||
|
||
<xsl:value-of select="(1, 2, 3)" /> | ||
|
||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters