Changeset 199

Show
Ignore:
Timestamp:
02/02/07 15:36:50 (2 years ago)
Author:
mikey
Message:

added net.stubbles.xml.stubXMLXIncludeStreamWrapper

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/experiments/general/xsl/copy.xsl

    r184 r199  
    33    xmlns:php="http://php.net/xsl" 
    44    xmlns:stub="http://stubbles.org/stub" 
    5   exclude-result-prefixes="php stub"> 
     5    exclude-result-prefixes="php stub"> 
    66   
    7    <xsl:template match="*|/"> 
     7  <xsl:template match="*|/"> 
    88    <xsl:copy> 
    9       <xsl:apply-templates/> 
     9      <xsl:copy-of select="./@*"/> 
     10      <xsl:apply-templates select="node()"/> 
    1011    </xsl:copy> 
    1112  </xsl:template> 
  • trunk/experiments/general/xsl/main_home.xml

    r198 r199  
    44    exclude-result-prefixes="stub"> 
    55   
    6    <part name="content"> 
    7        <lang id="default"> 
    8        <stub:link page="testlinkPage">Das ist ein Stubbles-Link</stub:link> 
    9        <stub:include href="parts.xml" part="frank"/> 
    10     <stub:image src="stubbles.png" alt="Stubbles Logo"/> 
    11      </lang> 
    12    </part> 
     6  <part name="content"> 
     7    <lang id="default"> 
     8      <stub:link page="testlinkPage">Das ist ein Stubbles-Link</stub:link> 
     9      <stub:include href="parts.xml" part="frank"/> 
     10      <stub:image src="stubbles.png" alt="Stubbles Logo"/> 
     11    </lang> 
     12  </part> 
    1313   
    1414</parts> 
  • trunk/experiments/general/xsl/parts.xml

    r184 r199  
    11<?xml version="1.0" encoding="iso-8859-1"?> 
    2 <parts> 
     2<parts 
     3    xmlns:stub="http://stubbles.org/stub" 
     4    exclude-result-prefixes="stub"> 
    35<part name="frank"> 
    4    <lang id="default"> 
    5     Frank Kleine 
     6  <lang id="default"> 
     7    <stub:include href="parts2.xml" part="nico"/> 
    68  </lang> 
    79</part> 
    810<part name="nico"> 
    9    <lang id="default"> 
     11  <lang id="default"> 
    1012    Nico Steiner 
    1113  </lang> 
  • trunk/experiments/general/xsl/stub.xsl

    r197 r199  
    55    xmlns:stub="http://stubbles.org/stub" 
    66    exclude-result-prefixes="php xi stub"> 
     7   
     8  <xsl:template match="stub:document"> 
     9    <xsl:apply-templates select="node()"/> 
     10  </xsl:template> 
    711   
    812  <xsl:template match="stub:link"> 
     
    1822   
    1923  <xsl:template match="stub:maincontent"> 
    20        <xsl:variable name="path"> 
     24    <xsl:variable name="path"> 
    2125      <xsl:choose> 
    2226        <xsl:when test="@path"> 
     
    2832      </xsl:choose> 
    2933    </xsl:variable> 
    30        <xsl:variable name="prefix"> 
     34    <xsl:variable name="prefix"> 
    3135      <xsl:choose> 
    3236        <xsl:when test="@prefix"> 
     
    3842      </xsl:choose> 
    3943    </xsl:variable> 
    40        <xsl:variable name="suffix"> 
     44    <xsl:variable name="suffix"> 
    4145      <xsl:choose> 
    4246        <xsl:when test="@suffix"> 
     
    4852      </xsl:choose> 
    4953    </xsl:variable> 
    50        <xsl:variable name="part"> 
     54    <xsl:variable name="part"> 
    5155      <xsl:choose> 
    5256        <xsl:when test="@part"> 
     
    7276    <xsl:param name="href" select="@href"/> 
    7377    <xsl:param name="part" select="@part"/>     
    74     <xi:include href="{$href}#xpointer(/parts/part[@name='{$part}']/lang/node())"> 
     78    <xi:include href="xinc://{$href}#xpointer(/parts/part[@name='{$part}']/lang/node())"> 
    7579      <xi:fallback> 
    7680        ERROR: Could not include part <xsl:value-of select="$part"/> in file <xsl:value-of select="$href"/> 
  • trunk/experiments/general/xsl/test.xsl

    r197 r199  
    44    xmlns:xi="http://www.w3.org/2001/XInclude" 
    55    xmlns:stub="http://stubbles.org/stub" 
    6   exclude-result-prefixes="php xi stub"> 
     6    exclude-result-prefixes="php xi stub"> 
    77 
    88  <xsl:import href="copy.xsl"/> 
     
    1717   
    1818  <xsl:template match="/"> 
    19     <xsl:apply-templates select="/stub:document/node()"/> 
     19    <xsl:apply-templates select="node()"/> 
    2020  </xsl:template> 
    2121   
  • trunk/experiments/general/xsl/transform.php

    r191 r199  
    7272stubClassLoader::load('net.stubbles.xml.xsl.util.stubXSLImageDimensions'); 
    7373$xslProcessor->registerCallback('image', new stubXSLImageDimensions(new stubDomXMLStreamWriter())); 
    74    
     74 
     75stubClassLoader::load('net.stubbles.xml.stubXMLXIncludeStreamWrapper'); 
     76stubXMLXIncludeStreamWrapper::register(); 
     77stubXMLXIncludeStreamWrapper::setXSLProcessor($xslProcessor); 
     78stubXMLXIncludeStreamWrapper::setCachePath(dirname(__FILE__) . '/cache'); 
     79 
    7580$resultDoc = $xslProcessor->transformToDoc(); 
    7681$resultDoc->xinclude(); 
    7782print $resultDoc->saveXML(); 
    78    
    79 //$xslProcessor->transformToURI(($args->isDefined('target') == false) ? ('result.html') : ($args->getValue('target'))); 
     83 
     84$dirIt = new DirectoryIterator(dirname(__FILE__) . '/cache/xml'); 
     85foreach ($dirIt as $file) { 
     86    if ($file->isDot() == true) { 
     87        continue; 
     88    } 
     89     
     90    unlink($file->getPathname()); 
     91
    8092exit(0); 
    8193?> 
  • trunk/src/main/php/net/stubbles/xml/xsl/stubXSLProcessor.php

    r180 r199  
    4242     */ 
    4343    protected $callbacks     = array(); 
     44    /** 
     45     * list of used stylesheets 
     46     * 
     47     * @var  array<DOMDocument> 
     48     */ 
     49    protected $stylesheets   = array(); 
    4450     
    4551    /** 
     
    7682    public function importXSLStylesheet(DOMDocument $stylesheet) 
    7783    { 
     84        $this->stylesheets[] = $stylesheet; 
    7885        $this->xsltProcessor->importStylesheet($stylesheet); 
     86    } 
     87     
     88    /** 
     89     * returns the list of used stylesheets 
     90     * 
     91     * @return  array<DOMDocument> 
     92     */ 
     93    public function getStylesheets() 
     94    { 
     95        return $this->stylesheets; 
    7996    } 
    8097     
     
    166183        $this->parameters[$nameSpace] = array_merge($this->parameters[$nameSpace], $params); 
    167184        return true; 
     185    } 
     186     
     187    /** 
     188     * returns all parameters for the given namespace3 
     189     * 
     190     * @param   string  $nameSpace 
     191     * @return  array 
     192     */ 
     193    public function getParameters($nameSpace) 
     194    { 
     195        if (isset($this->parameters[$nameSpace]) == true) { 
     196            return $this->parameters[$nameSpace]; 
     197        } 
     198         
     199        return array(); 
     200    } 
     201     
     202    /** 
     203     * returns a list of all used namespaces 
     204     * 
     205     * @return  array 
     206     */ 
     207    public function getParameterNameSpaces() 
     208    { 
     209        return array_keys($this->parameters); 
    168210    } 
    169211