Welcome!

Artificial Intelligence Authors: Pat Romanski, Yeshim Deniz, Liz McMillan, Zakia Bouachraoui, Elizabeth White

RSS Feed Item

Re: Transformation of RelaxNG syntax into presentationof requi

Per Sennels wrote:

> Is there a tool for presenting the RelaxNG syntax in a more user friendly way?

Please find attached two transformations that are able to convert RELAX
NG schema into SVG diagram. It is outcome of student assignment and it
is far from perfect. It is not in English so it was not published as
real OSS project. But you might find it useful.

				Jirka


-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: [email protected]      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:rng="http://relaxng.org/ns/structure/1.0"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
>

    <!-- definice vystupu -->
    <xsl:output method="xml" 
        indent="yes" 
        encoding="UTF-8" 
        media-type="image/svg" 
        doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" 
        doctype-public="-//W3C//DTD SVG 1.1//EN" />
    
    <!-- prejmenovani jmenneho prostoru pro vystup -->
    <xsl:namespace-alias stylesheet-prefix="rng" result-prefix=""/>
    
    <!-- odstrani bile mezery, ktere jsou potomky -->
    <xsl:strip-space elements="rng:*"/>

    <!-- nejsirsi objekt -->
    <xsl:variable name="nejsirsiObjekt">
        <xsl:value-of select="150"/>
    </xsl:variable>
    
    <!-- odsazeni ze shora -->
    <xsl:variable name="odsazeniY" select="50"/>
    
    <!-- odsazeni z prava -->
    <xsl:variable name="odsazeniX" select="10"/>

    <!-- vyska vsech grafickych prvku -->
    <xsl:variable name="vyskaObjektu" select="40"/>
    
    <!-- vertikalni vzdalenost grafickych prvku -->
    <xsl:variable name="vertikalniVzdalenost" select="10"/>
    
    <!-- horizontalni vzdalenost grafickych prvku -->
    <xsl:variable name="horizontalniVzdalenost" select="20"/>
    
    
    
    
    <!-- sablona pro sirku grafickych prvku -->
    <xsl:template name="sirkaObjektu"> 
        <xsl:variable name="objekt">
            <xsl:call-template name="vyberObjektu"/>            
        </xsl:variable>
        <xsl:value-of select="$objekt/rect[1]/@width"  xpath-default-namespace="http://www.w3.org/2000/svg"/>
    </xsl:template>


    <!-- sablona pro vyber vhodneho objektu -->
    <xsl:template name="vyberObjektu">
        <xsl:choose>
            <xsl:when test="local-name()='element'">
                <xsl:call-template name="element"/>                
            </xsl:when>
            <xsl:when test="local-name()='grammar'">
                <xsl:call-template name="grammar"/>                
            </xsl:when>
            <xsl:when test="local-name()='text'">
                <xsl:call-template name="text"/>                
            </xsl:when>
            <xsl:when test="local-name()='start'">
                <xsl:call-template name="start"/>                
            </xsl:when>
            <xsl:when test="local-name()='attribute'">
                <xsl:call-template name="attribute"/>                
            </xsl:when>
            <xsl:when test="local-name()='group'">
                <xsl:call-template name="group"/>                
            </xsl:when>
            <xsl:when test="local-name()='interleave'">
                <xsl:call-template name="interleave"/>                
            </xsl:when>
            <xsl:when test="local-name()='mixed'">
                <xsl:call-template name="mixed"/>                
            </xsl:when>
            <xsl:when test="local-name()='choice'">
                <xsl:call-template name="choice"/>                
            </xsl:when>
            <xsl:when test="local-name()='optional'">
                <xsl:call-template name="optional"/>                
            </xsl:when>
            <xsl:when test="local-name()='zeroOrMore'">
                <xsl:call-template name="zeroOrMore"/>                
            </xsl:when>
            <xsl:when test="local-name()='oneOrMore'">
                <xsl:call-template name="oneOrMore"/>                
            </xsl:when>
            <xsl:when test="local-name()='empty'">
                <xsl:call-template name="empty"/>                
            </xsl:when>
            <xsl:when test="local-name()='data'">
                <xsl:call-template name="data"/>                
            </xsl:when>
            <xsl:when test="local-name()='param'">
                <xsl:call-template name="param"/>                
            </xsl:when>
            <xsl:when test="local-name()='value'">
                <xsl:call-template name="value"/>                
            </xsl:when>
            <xsl:when test="local-name()='except'">
                <xsl:call-template name="except"/>                
            </xsl:when>
            <xsl:when test="local-name()='list'">
                <xsl:call-template name="list"/>                
            </xsl:when>
            <xsl:when test="local-name()='ref'">
                <xsl:call-template name="ref"/>                
            </xsl:when>
            <xsl:when test="local-name()='parentRef'">
                <xsl:call-template name="parentRef"/>                
            </xsl:when>
            <xsl:when test="local-name()='define'">
                <xsl:call-template name="define"/>                
            </xsl:when>
            <xsl:when test="local-name()='externalRef'">
                <xsl:call-template name="externalRef"/>                
            </xsl:when>
            <xsl:when test="local-name()='include'">
                <xsl:call-template name="include"/>                
            </xsl:when>
            <xsl:when test="local-name()='div'">
                <xsl:call-template name="div"/>                
            </xsl:when>
            <xsl:when test="local-name()='notAllowed'">
                <xsl:call-template name="notAllowed"/>                
            </xsl:when>
            <xsl:when test="local-name()='name'">
                <xsl:call-template name="name"/>                
            </xsl:when>
            <xsl:when test="local-name()='nsName'">
                <xsl:call-template name="nsName"/>                
            </xsl:when>
            <xsl:when test="local-name()='anyName'">
                <xsl:call-template name="anyName"/>                
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="text"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- sablona pro zjisteni y souradnic jakehokoliv objektu 
        reprezentujiciho RelaxNG schema -->
    <xsl:template name="ySouradnice">
        <xsl:value-of select="(count((preceding::node()|ancestor::node())[not(node())]) * ($vyskaObjektu+$vertikalniVzdalenost))+$odsazeniY"/>
    </xsl:template>
 
    <!-- sablona pro spojeni objektu s rodicem -->
    <xsl:template name="spojeniSRodicem">
        <xsl:variable name="vzdalenostKPredchudci" select="count((preceding-sibling::*[1]/descendant-or-self::node())[not(node())]) * ($vyskaObjektu+$vertikalniVzdalenost)"/>
        <xsl:choose>
            <xsl:when test="position()=1">
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -12 0 l 0 0"/>
            </xsl:when>
            <xsl:when test="not(position()=1 or position()=last())">            
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -10 0 l 0 -{$vzdalenostKPredchudci}"/>
            </xsl:when>
            <xsl:when test="position()=last()">
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -10 0 l 0 -{$vzdalenostKPredchudci}"/>
            </xsl:when>
        </xsl:choose>   
    </xsl:template>
 
    <!-- sablona pro ecmascript -->
    <xsl:template name="ecmascript">
        <script type="text/ecmascript"> 
<![CDATA[
//Ecmascript

//Globální proměnné začínající podtržítkem.
var _kolekceSouradnicSpojeni = [];
var _kolekceGrafickychObjektu = [];
var _kolekceSouradnicTransform = [];
var _kolekceSpojeni = [];
var _kolekcePlusMinus = [];
var _svgDokument = null;
var _vertikalniPosun = 50;
            

/**
  *Fce vyvolaná po načtení svg obrázku, která načte kolekce grafických objektů.
  *
  *@param udalost   událost, která fci vyvolala
  */
function poNacteni(udalost) { 
  _svgDokument = udalost.target.ownerDocument;  
  _kolekceSpojeni = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('path'), 'spojeni');
  _kolekceSouradnicSpojeni = ziskaniAtributuZUzlu(_kolekceSpojeni, 'd');  
  _kolekceGrafickychObjektu = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('g'), 'uzel'); 
  _kolekceSouradnicTransform = ziskaniAtributuZUzlu(_kolekceGrafickychObjektu, 'transform');
  _kolekcePlusMinus = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('use'), 'plusminus');     
}


/**
  *Fce, která z kolekce uzlů vrátí jen ty, které náleží do určité třídy.
  *
  *@param uzly    kolekce uzlů, které se mají prohledávat
  *@param trida   název třídy  
  *@return        kolekce uzlů příslušné třídy
  */
function ziskaniUzluPodleTridy(uzly, trida){
  var vysledneUzly = [];
  for (var i=0; i<uzly.length; i++) {
    if(uzly[i].getAttribute('class')==trida){
      vysledneUzly.push(uzly[i]);
    }
  }
  return vysledneUzly;  
}


/**
  *Fce, která nalezne uzel podle Id.
  *
  *@param uzly    kolekce uzlů, které se mají prohledávat
  *@param trida   id Uzlu  
  *@return        kolekce uzlů příslušné třídy
  */
function ziskaniUzluPodleId(uzly, hledaneId){
  var vysledek = null;
  for (var i=0; i<uzly.length; i++) {
    if(uzly[i].getAttribute('id')==hledaneId){
      vysledek=uzly[i];
    }
  }
  return vysledek;  
}


/**
  *Fce, která z kolekce uzlů vrátí stejně velkou kolekci, která bude obsahovat
  *namísto uzlů jen hodnoty určitého atributu.   
  *
  *@param uzly      kolekce uzlů, které se mají prohledávat
  *@param atribut   název atriutu, který se nachází ve všech uzlech  
  *@return          kolekce hodnot atributů
  */
function ziskaniAtributuZUzlu(uzly, atribut){
  var vysledneUzly = [];
  for (var i=0; i<uzly.length; i++) {
    vysledneUzly.push(uzly[i].getAttribute(atribut));
  }
  return vysledneUzly;  
}


/**
  *U objektu use, který fci vyvolal, se změní odkaz ze známénka plus na mínus 
  *nebo obráceně.     
  *
  *@param udalost   událost, která fci vyvolala
  */
function zmenaPlusMinus(uzel){
  var soucasneZnamenko=uzel.getAttribute('xlink:href');
  if(soucasneZnamenko=="#minus"){
    uzel.setAttribute('xlink:href', '#plus');
  }else{
    uzel.setAttribute('xlink:href', '#minus');          
  }                
}


/**
  *Fce se vyvolá při kliknutí na znaménko plus nebo minus v obrázku. Tím se
  *změní visuální hodnota celého stromu - některé větve se zabalí nebo naopak
  *jiné rozbalí.        
  *
  *@param udalost   událost, která fci vyvolala
  */
function zmenaStromu(udalost){
  var objekt=udalost.target; 
  rizeniZmen(objekt); 
}


/**
  *Fce, která řídí změny ve stromu.        
  *
  *@param objekt   objekt, který fci vyvolal
  */
function rizeniZmen(objekt){
  var soucasneZnamenko=objekt.getAttribute('xlink:href');
  var idUzlu=objekt.getAttribute('id').substring(4);
  var uzel=ziskaniUzluPodleId(_kolekceGrafickychObjektu, idUzlu);
  var jeViditelny=uzel.getAttribute('visibility');
  if(jeViditelny=='visible'){
    zmenaPlusMinus(objekt);
    if(soucasneZnamenko=="#plus"){
      typ='rozbaleni';
      vseViditelne();   
      zneviditelneniObjektu();
      zmenyPolohyUzlu(objekt, typ); 
    }else{
      typ='zabaleni'; 
      zmenyPolohyUzlu(objekt, typ); 
      vseViditelne();   
      zneviditelneniObjektu();         
    }
  }
}


/**
  *Fce pro získání X souřadnice z atributu transform.       
  *
  *@param hodnotaTransform    hodnota, která je obsažena v atributu transform
  *@return                    x souřadnice objektu  
  */
function ziskaniXPosunutiObjektu(hodnotaTransform){                      
  return hodnotaTransform.substring(10, hodnotaTransform.indexOf(',')); 
}


/**
  *Fce pro získání Y souřadnice z atributu transform.       
  *
  *@param hodnotaTransform    hodnota, která je obsažena v atributu transform
  *@return                    y souřadnice objektu  
  */
function ziskaniYPosunutiObjektu(hodnotaTransform){
  return hodnotaTransform.substring(hodnotaTransform.indexOf(',')+1,hodnotaTransform.indexOf(')'));                   
}


/**
  *Fce pro získání prvních znaků z atributu d nacházejícího se u cesty path.
  *Vrátí vše kromě posledního čísla cesty.         
  *
  *@param hodnotaD  hodnota, která je obsažena v atributu d
  *@return          začátek cesty  
  */
function ziskaniZacatkuCesty(hodnotaD){
  return hodnotaD.substring(0, hodnotaD.lastIndexOf(' '));                   
}


/**
  *Fce vrátí pouze poslední číslo, které se nachází v atributu d cesty path.      
  *
  *@param hodnotaD  hodnota, která je obsažena v atributu d
  *@return          poslední souřadnice cesty 
  */
function ziskaniKonceCesty(hodnotaD){
  return hodnotaD.substring(hodnotaD.lastIndexOf(' '));                    
}


/**
  *Fce nastaví atribut visibility všech objektů na visible.   
  *
  */
function vseViditelne(){
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    _kolekceGrafickychObjektu[i].setAttribute('visibility', 'visible');
  }
}   
 


/**
  *Fce zjistí, zda je první hodnota ID potomkem druhé hodnoty ID. Pokud ano, 
  *vrátí true
  *
  *@param IdPotomka id eventuálního potomka
  *@param IdUzlu    id aktuálního uzlu
  *@return          vrátí true, když je potomek, nebo false, když není
  *    
  */
function jePotomek(IdPotomka, IdUzlu){
  poleIdPotomka=IdPotomka.split('_');
  poleIdUzlu=IdUzlu.split('_');  
  if(poleIdPotomka.length>poleIdUzlu.length){
    for(var i=0; i<poleIdUzlu.length; i++){
      if(poleIdPotomka[i]!=poleIdUzlu[i]){
        return false;
      }
    }
    return true;  
  }
  else{
    return false;
  }
} 


/**
  *Fce zjistí, zda se jedná o následníka, který je ve větvi, která se odděluje
  *od rodičovské, na prvním místě.  
  *
  *@param IdPotomka id eventuálního potomka
  *@param IdUzlu    id aktuálního uzlu
  *@return          vrátí true, když je potomek, nebo false, když není
  *    
  */
function jeNaslednikPrvniUrovne(IdNaslednika, IdUzlu){
  poleIdNaslednika=IdNaslednika.split('_');
  poleIdUzlu=IdUzlu.split('_');  
  if(poleIdNaslednika.length<=poleIdUzlu.length){
    for(var i=0; i<poleIdNaslednika.length; i++){
      if(i==(poleIdNaslednika.length-1)){
        if(Number(poleIdNaslednika[i])==(Number(poleIdUzlu[i])+1)){
          return true;  
        }
        return false;        
      }
      else{
        if(poleIdNaslednika[i]!=poleIdUzlu[i]){
          return false;
        }
      }
    }
    return true;  
  }
  else{
    return false;
  }
} 


/**
  *Fce zjistí, zda je první hodnota ID následníkem druhé hodnoty ID. Pokud ano, 
  *vrátí true
  *
  *@param IdNaslednika  id eventuálního následníka
  *@param IdUzlu        id aktuálního uzlu
  *@return              vrátí true, když je následník, nebo false, když není
  *    
  */
function jeNaslednik(IdNaslednika, IdUzlu){
  poleIdNaslednika=IdNaslednika.split('_');
  poleIdUzlu=IdUzlu.split('_');   
  if(poleIdNaslednika.length>poleIdUzlu.length){
    for(var i=0; i<poleIdUzlu.length; i++){
      if(poleIdNaslednika[i]<poleIdUzlu[i]){
        return false;
      }
      else{
        if(poleIdNaslednika[i]>poleIdUzlu[i]){
          return true;
        }
      }     
    }
  }
  else{
    for(var i=0; i<poleIdNaslednika.length; i++){
      if(poleIdNaslednika[i]<poleIdUzlu[i]){
        return false;
      }
      else{
        if(poleIdNaslednika[i]>poleIdUzlu[i]){
          return true;
        }
      }     
    }    
  }
  return false;
} 


/**
  *Fce zjistí, zda má uzel podle zadaného ID nějaké děti, jejichž
  *atribut visibility je nastaven na visible. Vrátí jejich součet. 
  *
  *@param IdUzlu        id aktuálního uzlu
  *@return              vrátí počet viditelných dětí konkrétního uzlu
  *    
  */
function pocetViditelnychDeti(IdUzlu){
  var poleIdUzlu=IdUzlu.split('_');
  var pocetDeti=0;
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel=_kolekceGrafickychObjektu[i];
    var IdVybranehoUzlu=vybranyUzel.getAttribute('id');
    var poleIdVybranehoUzlu=IdVybranehoUzlu.split('_');
    var maDeti=1;
    for(var iter=0; iter<poleIdUzlu.length; iter++){
      if(poleIdUzlu[iter]!=poleIdVybranehoUzlu[iter]){
        maDeti=0;
      }
    }
    if(IdUzlu==IdVybranehoUzlu){
      maDeti=0;
    }
    if(vybranyUzel.getAttribute('visibility')=='hidden'){
      maDeti=0;
    }
    pocetDeti=pocetDeti+maDeti;
  }
  return pocetDeti;
}

/**
  *Fci je předána událost, která fci vyvolala. Smyslem fce je posunout všechny
  *následníky, aby doléhali na uzel vyvolávající událost.     
  *
  *@param udalost     událost, která fci vyvolala  
  *@param typ         typ udává, zda-li jde o zabalení či rozbalení  
  *
  */
function zmenyPolohyUzlu(objekt, typ){
  var IdUzlu = objekt.getAttribute('id').substring(4);
  var pocetRadekPosunu=0;
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel = _kolekceGrafickychObjektu[i];
    var idVybranehoUzlu = vybranyUzel.getAttribute('id');
    if(jePotomek(idVybranehoUzlu ,IdUzlu)){
      if(pocetViditelnychDeti(idVybranehoUzlu)==0 && vybranyUzel.getAttribute('visibility')=='visible'){
        pocetRadekPosunu++;
      }
    }    
  }
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel = _kolekceGrafickychObjektu[i];
    var IdVybranehoUzlu = vybranyUzel.getAttribute('id');
    if(jeNaslednik(IdVybranehoUzlu ,IdUzlu)){
      if(typ=='rozbaleni'){        
        posunObjektu(IdVybranehoUzlu, (pocetRadekPosunu-1)*_vertikalniPosun);
        if(jeNaslednikPrvniUrovne(IdVybranehoUzlu ,IdUzlu)){
          zmenaSpojeni(IdVybranehoUzlu, -(pocetRadekPosunu-1)*_vertikalniPosun);
        }
      }     
      else{
        posunObjektu(IdVybranehoUzlu, -(pocetRadekPosunu-1)*_vertikalniPosun);
        if(jeNaslednikPrvniUrovne(IdVybranehoUzlu ,IdUzlu)){
          zmenaSpojeni(IdVybranehoUzlu, (pocetRadekPosunu-1)*_vertikalniPosun);
        }   
      }   
    }
  }  
} 

/**
  *Vertikální posun uzlu. Vždy se posouvá z aktuálního umístění.  
  *
  *@param IdObjektu     id objektu, kterým má být posunuto
  *@param posunPoOseY   číslo vyjadřující o kolik se posune     
  *
  */
function posunObjektu(IdObjektu, posunPoOseY){
  var objekt=ziskaniUzluPodleId(_kolekceGrafickychObjektu, IdObjektu);
  var stavajiciTransformace=objekt.getAttribute('transform');
  var x=Number(ziskaniXPosunutiObjektu(stavajiciTransformace));
  var y=Number(ziskaniYPosunutiObjektu(stavajiciTransformace));
  y=y+posunPoOseY;
  objekt.setAttribute('transform', 'translate('+x+' , '+y+')');
} 



/**
  *Fce změní velikosti úseček spojujících grafické uzly.
  *
  *@param IdObjektu     id uzlu, kterým má být posunuto
  *@param posunPoOseY   číslo vyjadřující o kolik se posune     
  *
  */
function zmenaSpojeni(IdObjektu, zmenaVelikosti){
  var vybranyIterator=null;
  for (var iter=0; iter<_kolekceGrafickychObjektu.length; iter++) {
    if(IdObjektu==_kolekceGrafickychObjektu[iter].getAttribute('id')){
      vybranyIterator=iter;
    }
  }
  var objekt=_kolekceSpojeni[vybranyIterator];  
  var stavajiciD=objekt.getAttribute('d');
  var zacatek=ziskaniZacatkuCesty(stavajiciD);
  var y=Number(ziskaniKonceCesty(stavajiciD));
  y=y+zmenaVelikosti;
  objekt.setAttribute('d', zacatek+' '+y);
} 



 
/**
  *Fce nastaví atribut visibility na hidden u všech dětí za každým 
  *uzlem se znaménkem plus.  
  *
  */
function zneviditelneniObjektu(){
  for (var i=0; i<_kolekcePlusMinus.length; i++) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#plus"){                 
      var IdRodice = _kolekcePlusMinus[i].getAttribute('id').substring(4);//odstraneni textu plus
      for (var iter=0; iter<_kolekceGrafickychObjektu.length; iter++) {
        var vybranyObjektId=_kolekceGrafickychObjektu[iter].getAttribute('id');
        if(jePotomek(vybranyObjektId, IdRodice)){
            _kolekceGrafickychObjektu[iter].setAttribute('visibility', 'hidden');   
        }                                             
      }
    }
  }
}  


/**
  *Rozbalení všech uzlů  
  *
  */
function rozbaleniVsechUzlu(){ 
  for (var i=0; i<_kolekcePlusMinus.length; i++) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#plus"){                 
      rizeniZmen(_kolekcePlusMinus[i]);
    }
  }   
} 

/**
  *Zabalení všech uzlů 
  *
  */
function zabaleniVsechUzlu(){ 
  rozbaleniVsechUzlu();
  for (var i=_kolekcePlusMinus.length-1; i>-1; i--) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#minus"){                 
      rizeniZmen(_kolekcePlusMinus[i]);
    }
  }   
}  
]]>
        </script>  
    </xsl:template>
 
    <!-- sablona pro opakovane symboly -->
    <xsl:template name="opakovaneSymboly">
        <defs>
            <symbol id="plus" visibility="inherit">
                <desc>plus</desc>
                <rect x="0" y="0" width="8" height="8"
                    fill="white" stroke="black" stroke-width="1" />           
                <line x1="1" y1="4" x2="7" y2="4"
                    stroke-width="1" stroke="black"/>                 
                <line x1="4" y1="1" x2="4" y2="7"
                    stroke-width="1" stroke="black"/>   
            </symbol>
                        
            <symbol id="minus" visibility="inherit">
                <desc>minus</desc>
                <rect x="0" y="0" width="8" height="8"
                    fill="white" stroke="black" stroke-width="1" /> 
                <line x1="1" y1="4" x2="7" y2="4"
                    stroke-width="1" stroke="black"/>   
            </symbol>
        </defs>
    </xsl:template>
        
        <!-- sablona pro objekty, ktere oteviraji nebo zaviraji vse-->
        <xsl:template name="rozbalitZabalit">
            <g class="rozbalitZabalit" visibility="visible" transform="translate({$odsazeniX}, 10)" onclick="zabaleniVsechUzlu();">
                <rect x="0" y="10" width="150" height="20"
                rx="1"
                fill="white" stroke="black" stroke-width="1" />  
                <text x="5" y="27"
                    font-family="Helvetica" font-size="14"
                    fill="black">Zabalit strom</text>
            </g>
            
            <g class="rozbalitZabalit" visibility="visible" transform="translate({$odsazeniX+180}, 10)" onclick="rozbaleniVsechUzlu();">
                <rect x="0" y="10" width="150" height="20"
                    rx="1"
                    fill="white" stroke="black" stroke-width="1" />  
                <text x="5" y="27"
                    font-family="Helvetica" font-size="14"
                    fill="black">Rozbalit strom</text>
            </g>
        </xsl:template>
 
    <!-- root sablona -->
    <xsl:template match="/">
        <xsl:variable name="logickyModel">
            <xsl:apply-templates select="node()[self::rng:*]" mode="prevedeniNaLM"/>
        </xsl:variable>

        <xsl:variable name="vyskaDokumentu">
            <xsl:value-of select="(count(($logickyModel//node())[not(node())]) * ($vyskaObjektu+$vertikalniVzdalenost))+$vertikalniVzdalenost+$odsazeniY"/>
        </xsl:variable>

        <xsl:variable name="sirkaDokumentu">
            <xsl:for-each select="$logickyModel//node()[not(node())]">
                <xsl:sort select="count(ancestor-or-self::*)" order="descending" data-type="number"/>
                <xsl:if test="position()=1">
                    <xsl:value-of select="count(ancestor-or-self::*)*($nejsirsiObjekt+$horizontalniVzdalenost)+$odsazeniX"/>
                </xsl:if>
            </xsl:for-each>
        </xsl:variable>
        
        <svg width="{$sirkaDokumentu}" height="{$vyskaDokumentu}" 
            onload="poNacteni(evt)">  
            <xsl:variable name="sirkaObjektu">
                <xsl:call-template name="sirkaObjektu"/>
            </xsl:variable>          
            <title>Logicky Relax NG model</title>
            <xsl:call-template name="ecmascript"/>
            <xsl:call-template name="opakovaneSymboly"/>
            <xsl:call-template name="rozbalitZabalit"/>
            <g id="_1" class="uzel" visibility="visible" transform="translate({$odsazeniX}, {$odsazeniY})" >
                <xsl:call-template name="root"/>
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 0 l 0 0 l 0 0"/>
                <xsl:if test="node()[self::rng:*]">
                    <use xlink:href='#minus' id="plus_{position()}" transform="translate(40, 16 )" onclick="zmenaStromu(evt);" class="plusminus"/>
                </xsl:if>
            </g>
            
            <xsl:apply-templates select="$logickyModel/node()">
                <xsl:with-param name="id-vetve" select="concat( '_', position())"/>
                <xsl:with-param name="xSouradnice" select="40+$horizontalniVzdalenost+$odsazeniX"/>
            </xsl:apply-templates>
        </svg>
    </xsl:template>

    <!-- sablona pro vsechny elementy z jmenneho prostoru rng -->
    <xsl:template match="*">
        <xsl:param name="id-vetve"/>
        <xsl:param name="xSouradnice" select="0"/>
        <xsl:variable name="xSouradnice" select="$xSouradnice"/>
        <xsl:variable name="sirkaObjektu">
            <xsl:call-template name="sirkaObjektu"/>
        </xsl:variable>
        <xsl:variable name="ySouradnice">
            <xsl:call-template name="ySouradnice"/>
        </xsl:variable>
        <g id="{$id-vetve}_{position()}" class="uzel" visibility="visible" transform="translate({$xSouradnice}, {$ySouradnice})">
        <xsl:call-template name="vyberObjektu"/>
        <xsl:call-template name="spojeniSRodicem"/>
            <xsl:if test="node()">
            <use xlink:href='#minus' id="plus{$id-vetve}_{position()}" transform="translate({$sirkaObjektu}, {$vyskaObjektu div 2 - 4} )" onclick="zmenaStromu(evt);" class="plusminus"/>
        </xsl:if>
        </g>

        <xsl:apply-templates select="*">
            <xsl:with-param name="id-vetve" select="concat($id-vetve, '_', position())"/>
            <xsl:with-param name="xSouradnice" select="$xSouradnice+$sirkaObjektu+$horizontalniVzdalenost"/>
        </xsl:apply-templates>
    </xsl:template>


    <!-- sablona pro vsechny elementy element -->
    <xsl:template name="element">
        <xsl:variable name="ns" select="(ancestor-or-self::rng:*/@ns)[last()]"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($ns)*7">
                    <xsl:value-of select="string-length($ns)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($ns)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>element</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="15,4 4,20 15,36 " /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="20,4 31,20 20,36 " /> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($ns)=0)">
                ns: <xsl:value-of select="$ns"/>
            </xsl:if>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy grammar -->
    <xsl:template name="grammar">
        <desc>grammar</desc>
        <rect x="0" y="0" width="103" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            {grammar}
        </text>        
    </xsl:template>
    
    <!-- sablona pro vsechny elementy start -->
    <xsl:template name="start">
        <desc>start</desc>
        <rect x="0" y="0" width="100" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />    
        <rect x="4" y="6" width="28" height="28"
            fill="none" stroke="#006000" stroke-width="2" />      
        <polygon fill="#006000" stroke="#006000" stroke-width="0"
            points="35,6 35,34 45,20" />      
        <text x="50" y="25"
            font-family="Helvetica" font-size="18"
            fill="#006000" >
            Start
        </text> 
        <xsl:if test="@combine='choice'">
            <line x1="18" y1="9" x2="18" y2="31"
                stroke-width="2" stroke="#006000"/>  
        </xsl:if>
        <xsl:if test="@combine='interleave'">
            <polyline fill="none" stroke="#006000" stroke-width="2"
                points="7,16 18,9 29,16 " /> 
        </xsl:if>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy text -->
    <xsl:template name="text">
        <desc>text</desc>
        <rect x="0" y="3" width="40" height="34"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            text
        </text>          
    </xsl:template>
    
    <!-- sablona pro vsechny elementy attribute -->
    <xsl:template name="attribute">
        <xsl:variable name="ns" select="@ns"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($ns)*7">
                    <xsl:value-of select="string-length($ns)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($ns)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>atribut</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="28"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            @
        </text> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($ns)=0)">
                ns: <xsl:value-of select="$ns"/>
            </xsl:if>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy root -->
    <xsl:template name="root">
        <desc>root</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />    
        <line x1="8" y1="36" x2="32" y2="4"
            stroke-width="2" stroke="#006000"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy group-->
    <xsl:template name="group">
        <desc>group</desc>
        <rect x="0" y="10" width="49" height="20"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />         
        <line x1="4" y1="20" x2="45" y2="20"
            stroke-width="2" stroke="#006000"/>        
        <rect x="4" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>        
        <rect x="16" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>         
        <rect x="28" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>         
        <rect x="40" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>    
    </xsl:template>
    
    <!-- sablona pro vsechny elementy interleave -->
    <xsl:template name="interleave">
        <desc>interleave</desc>
        <rect x="0" y="0" width="49" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />     
        <line x1="4" y1="20" x2="12" y2="20"
            stroke-width="2" stroke="#006000"/> 
        <rect x="12" y="7" width="25" height="26"
            rx="3"
            fill="none" stroke="#006000" stroke-width="2" />   
        <line x1="37" y1="20" x2="45" y2="20"
            stroke-width="2" stroke="#006000"/> 
        <rect x="22" y="4" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/> 
        <rect x="22" y="30" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy mixed -->
    <xsl:template name="mixed">
        <desc>mixed</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <line x1="6" y1="6" x2="6" y2="26"
            stroke-width="2" stroke="#006000"/>    
        <line x1="6" y1="6" x2="26" y2="6"
            stroke-width="2" stroke="#006000"/>  
        <line x1="6" y1="26" x2="16" y2="26"
            stroke-width="2" stroke="#006000"/>        
        <line x1="26" y1="6" x2="26" y2="16"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="16" x2="16" y2="36"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="16" x2="36" y2="16"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="36" x2="36" y2="16"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy choice -->
    <xsl:template name="choice">
        <desc>choice</desc>
        <rect x="0" y="1" width="40" height="38"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <line x1="30" y1="5" x2="30" y2="34"
            stroke-width="2" stroke="#006000"/>   
        <line x1="4" y1="21" x2="14" y2="21"
            stroke-width="2" stroke="#006000"/> 
        <line x1="14" y1="21" x2="30" y2="9"
            stroke-width="2" stroke="#006000"/> 
        <rect x="27" y="5" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/> 
        <rect x="27" y="17" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/>  
        <rect x="27" y="29" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy optional -->
    <xsl:template name="optional">
        <desc>optional</desc>
        <rect x="0" y="4" width="40" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            0..1
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy zeroOrMore -->
    <xsl:template name="zeroOrMore">
        <desc>zeroOrMore</desc>
        <rect x="0" y="4" width="45" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />  
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            0..<xsl:text disable-output-escaping="yes">&amp;</xsl:text>#8734;
        </text>       
    </xsl:template>
    
    <!-- sablona pro vsechny elementy oneOrMore -->
    <xsl:template name="oneOrMore">
        <desc>oneOrMore</desc>
        <rect x="0" y="4" width="45" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            1..<xsl:text disable-output-escaping="yes">&amp;</xsl:text>#8734;
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy empty -->
    <xsl:template name="empty">
        <desc>empty</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" /> 
        <ellipse
            cx="20" cy="20" rx="12" ry="13"
            fill="none" stroke="#006000" stroke-width="2"/> 
        <line x1="4" y1="36" x2="36" y2="4"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy data -->
    <xsl:template name="data">
        <xsl:variable name="dtL" select="(ancestor-or-self::rng:*/@datatypeLibrary)[last()]"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($dtL)*7">
                    <xsl:value-of select="string-length($dtL)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($dtL)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>data</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            d
        </text>       
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@type"/>
        </text>  
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($dtL)=0)">
                dtL: <xsl:value-of select="$dtL"/>
            </xsl:if>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy param -->
    <xsl:template name="param">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name)+string-length(text()))*9+48"/>
        <desc>param</desc>
        <rect x="0" y="5" width="{$sirkaObjektu}" height="30"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="#006000" stroke="#006000" stroke-width="2"
            points="20,10 20,30 9,20" /> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>: <xsl:value-of select="text()"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy value -->
    <xsl:template name="value">
        <xsl:variable name="sirkaObjektu" select="(string-length(text()))*9+40"/>
        <desc>value</desc>
        <rect x="0" y="5" width="{$sirkaObjektu}" height="30"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="4" y="11" width="18" height="18"
            fill="none" stroke="#006000" stroke-width="2" /> 
        <rect x="11" y="18" width="4" height="4"
            fill="#006000" stroke="#006000" stroke-width="2" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="text()"/>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy except -->
    <xsl:template name="except">
        <desc>except</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="10,4 22,4 22,36 " /> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy list -->
    <xsl:template name="list">
        <desc>list</desc>
        <rect x="0" y="0" width="30" height="39"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="12" y="4" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/>    
        <rect x="12" y="17" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/> 
        <rect x="12" y="30" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy ref -->
    <xsl:template name="ref">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>ref</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="60" y="30" width="13" height="13"
            fill="white" stroke="#006000" stroke-width="2" /> 
        <line x1="63" y1="40" x2="70" y2="33"
            stroke-width="2" stroke="#006000"/>  
        <polygon fill="#006000" stroke="#006000" stroke-width="1"
            points="70,33 70,38 65,33" /> 
        <text x="8" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy parentRef -->
    <xsl:template name="parentRef">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>parentRef</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="60" y="30" width="13" height="13"
            fill="white" stroke="#006000" stroke-width="2" /> 
        <line x1="63" y1="40" x2="70" y2="33"
            stroke-width="2" stroke="#006000"/>  
        <line x1="67" y1="40" x2="63" y2="36"
            stroke-width="2" stroke="#006000"/>  
        <polygon fill="#006000" stroke="#006000" stroke-width="1"
            points="70,33 70,38 65,33" /> 
        <text x="8" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy define -->
    <xsl:template name="define">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>define</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="4" y="6" width="28" height="28"
            fill="none" stroke="#006000" stroke-width="2" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy externalRef -->
    <xsl:template name="externalRef">
        <xsl:variable name="sirkaObjektu" select="(string-length(@href))*9+40"/>
        <desc>externalRef</desc>
        <rect x="0" y="2" width="{$sirkaObjektu}" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="none" stroke="#006000" stroke-width="2"
            points="4,20 14,10 14,17 24,17 24,23 14,23 14,30" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@href"/>
        </text> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy include -->
    <xsl:template name="include">
        <xsl:variable name="sirkaObjektu" select="(string-length(@href))*9+40"/>
        <desc>include</desc>
        <rect x="0" y="2" width="{$sirkaObjektu}" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="#006000" stroke="#006000" stroke-width="2"
            points="4,20 14,10 14,17 24,17 24,23 14,23 14,30" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@href"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy div -->
    <xsl:template name="div">
        <desc>div</desc>
        <rect x="0" y="0" width="150" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            {div}
        </text> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy notAllowed -->
    <xsl:template name="notAllowed">
        <desc>notAllowed</desc>
        <rect x="0" y="2" width="40" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <circle cx="20" cy="20" r="12"
            fill="#F2ACA9" stroke="#006000" stroke-width="2" /> 
        <line x1="10" y1="20" x2="30" y2="20"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy name -->
    <xsl:template name="name">
        <xsl:variable name="sirkaObjektu" select="(string-length(text()))*9+40"/>
        <desc>name</desc>
        <rect x="0" y="3" width="{$sirkaObjektu}" height="34"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            N
        </text>   
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="text()"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy nsName -->
    <xsl:template name="nsName">
        <xsl:variable name="sirkaObjektu" select="(string-length(@ns))*9+40"/>
        <desc>nsName</desc>
        <rect x="0" y="3" width="{$sirkaObjektu}" height="34"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            NS
        </text>
        
        <text x="50" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@ns"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy anyName -->
    <xsl:template name="anyName">
        <desc>anyName</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="10,4 20,35 30,4 " /> 
        <line x1="8" y1="15" x2="32" y2="15"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- prevedeni na LM -->
    <xsl:template match="rng:*" mode="prevedeniNaLM">
        <xsl:param name="pouziteOdkazy"/>
        
        
        <xsl:choose>
            
            <xsl:when test="local-name()='ref'">
                <xsl:variable name="reference" select="@name"/>
                <xsl:choose>
                    <xsl:when test="count($pouziteOdkazy/node()[@name=$reference])&lt;1">
                        <xsl:element name="define">
                            <xsl:if test="@name">
                                <xsl:attribute name="name">
                                    <xsl:value-of select="@name"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@ns">
                                <xsl:attribute name="ns">
                                    <xsl:value-of select="@ns"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@datatypeLibrary">
                                <xsl:attribute name="datatypeLibrary">
                                    <xsl:value-of select="@datatypeLibrary"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:choose>
                                <xsl:when test="count(//rng:define[@name=$reference])=1">
                                    <xsl:apply-templates select="//rng:define[@name=$reference]/node()" mode="prevedeniNaLM">
                                        <xsl:with-param name="pouziteOdkazy">
                                            <xsl:copy-of select="$pouziteOdkazy"/>
                                            <xsl:element name="ref">
                                                <xsl:if test="@name">
                                                    <xsl:attribute name="name">
                                                        <xsl:value-of select="@name"/>
                                                    </xsl:attribute>
                                                </xsl:if>
                                            </xsl:element>
                                        </xsl:with-param>
                                    </xsl:apply-templates>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:variable name="combine" select="(//rng:define[@name=$reference]/@combine)[1]"/>
                                    <xsl:choose>
                                        <xsl:when test="$combine='choice'">
                                            <xsl:element name="choice">
                                                <xsl:for-each select="//rng:define[@name=$reference]">
                                                     <group>
                                                        <xsl:apply-templates mode="prevedeniNaLM">
                                                            <xsl:with-param name="pouziteOdkazy">
                                                                <xsl:copy-of select="$pouziteOdkazy"/>
                                                                <xsl:element name="ref">
                                                                    <xsl:if test="@name">
                                                                        <xsl:attribute name="name">
                                                                            <xsl:value-of select="@name"/>
                                                                        </xsl:attribute>
                                                                    </xsl:if>
                                                                </xsl:element>
                                                            </xsl:with-param>
                                                        </xsl:apply-templates>
                                                    </group>
                                                </xsl:for-each>                                        
                                            </xsl:element>
                                        </xsl:when>
                                        <xsl:when test="$combine='interleave'">
                                            <xsl:element name="interleave">
                                                <xsl:for-each select="//rng:define[@name=$reference]">
                                                    <group>
                                                        <xsl:apply-templates mode="prevedeniNaLM">
                                                            <xsl:with-param name="pouziteOdkazy">
                                                                <xsl:copy-of select="$pouziteOdkazy"/>
                                                                <xsl:element name="ref">
                                                                    <xsl:if test="@name">
                                                                        <xsl:attribute name="name">
                                                                            <xsl:value-of select="@name"/>
                                                                        </xsl:attribute>
                                                                    </xsl:if>
                                                                </xsl:element>
                                                            </xsl:with-param>
                                                        </xsl:apply-templates>
                                                    </group>
                                                </xsl:for-each>  
                                            </xsl:element>
                                        </xsl:when>
                                    </xsl:choose>
                                </xsl:otherwise>
                            </xsl:choose>      
                        </xsl:element>   
                    </xsl:when>
                    
                    <xsl:otherwise>
                        <xsl:element name="ref">
                            <xsl:if test="@name">
                                <xsl:attribute name="name">
                                    <xsl:value-of select="@name"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@ns">
                                <xsl:attribute name="ns">
                                    <xsl:value-of select="@ns"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:if test="@datatypeLibrary">
                                <xsl:attribute name="datatypeLibrary">
                                    <xsl:value-of select="@datatypeLibrary"/>
                                </xsl:attribute>
                            </xsl:if>
                        </xsl:element>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            
            <xsl:when test="local-name()='define'">
            </xsl:when>
            
            <xsl:when test="local-name()='data'">
                <xsl:element name="text"/>
            </xsl:when>
            
            <xsl:when test="local-name()='start' and count(preceding-sibling::rng:start)>0">
            </xsl:when>
            
            <xsl:when test="local-name()='start'">
                <xsl:variable name="combineStart" select="(//rng:start/@combine)[1]"/>
                <xsl:choose>
                    <xsl:when test="$combineStart='choice'">
                        <start>
                        <xsl:element name="choice">
                            <xsl:for-each select="//rng:start">
                                <xsl:element name="group">
                                    <xsl:apply-templates mode="prevedeniNaLM">
                                        <xsl:with-param name="pouziteOdkazy">
                                            <xsl:copy-of select="$pouziteOdkazy"/>
                                        </xsl:with-param>
                                    </xsl:apply-templates>
                                </xsl:element>
                            </xsl:for-each>                                        
                        </xsl:element>
                        </start>
                    </xsl:when>
                    <xsl:when test="$combineStart='interleave'">
                        <start>
                        <xsl:element name="interleave">
                            <xsl:for-each select="//rng:start">
                                <xsl:element name="group">
                                    <xsl:apply-templates mode="prevedeniNaLM">
                                        <xsl:with-param name="pouziteOdkazy">
                                            <xsl:copy-of select="$pouziteOdkazy"/>
                                        </xsl:with-param>
                                    </xsl:apply-templates>
                                </xsl:element>
                            </xsl:for-each>  
                        </xsl:element>
                         </start>
                    </xsl:when>
                    <xsl:otherwise>
                        <start>
                        <xsl:apply-templates mode="prevedeniNaLM">
                            <xsl:with-param name="pouziteOdkazy">
                                <xsl:copy-of select="$pouziteOdkazy"/>
                            </xsl:with-param>
                        </xsl:apply-templates>
                        </start>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            
            <xsl:when test="local-name()='mixed'">
                <xsl:element name="interleave">
                    <xsl:if test="@ns">
                        <xsl:attribute name="ns">
                            <xsl:value-of select="@ns"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@datatypeLibrary">
                        <xsl:attribute name="datatypeLibrary">
                            <xsl:value-of select="@datatypeLibrary"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:element name="text"/>
                    <xsl:choose>
                        <xsl:when test="count(node())>1">
                            <xsl:element name="group">
                                <xsl:apply-templates select="node()[self::rng:*]" mode="prevedeniNaLM">
                                    <xsl:with-param name="pouziteOdkazy">
                                        <xsl:copy-of select="$pouziteOdkazy"/>
                                    </xsl:with-param>
                                </xsl:apply-templates> 
                            </xsl:element>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:apply-templates select="node()[self::rng:*]" mode="prevedeniNaLM">
                                <xsl:with-param name="pouziteOdkazy">
                                    <xsl:copy-of select="$pouziteOdkazy"/>
                                </xsl:with-param>
                            </xsl:apply-templates> 
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:element>
            </xsl:when>
            
            <xsl:when test="local-name()='attribute' and not(node()[local-name()='text'])">
                <xsl:element name="{name()}">
                    <xsl:if test="@name">
                        <xsl:attribute name="name">
                            <xsl:value-of select="@name"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@ns">
                        <xsl:attribute name="ns">
                            <xsl:value-of select="@ns"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@datatypeLibrary">
                        <xsl:attribute name="datatypeLibrary">
                            <xsl:value-of select="@datatypeLibrary"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:element name="text">
                    </xsl:element>
                    <xsl:apply-templates select="node()[self::rng:*]" mode="prevedeniNaLM">
                        <xsl:with-param name="pouziteOdkazy">
                            <xsl:copy-of select="$pouziteOdkazy"/>
                        </xsl:with-param>
                    </xsl:apply-templates> 
                </xsl:element>
            </xsl:when>
            
            <xsl:otherwise>
                <xsl:element name="{name()}">
                    <xsl:if test="@name">
                        <xsl:attribute name="name">
                            <xsl:value-of select="@name"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@ns">
                        <xsl:attribute name="ns">
                            <xsl:value-of select="@ns"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@datatypeLibrary">
                        <xsl:attribute name="datatypeLibrary">
                            <xsl:value-of select="@datatypeLibrary"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@type">
                        <xsl:attribute name="type">
                            <xsl:value-of select="@type"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@combine">
                        <xsl:attribute name="combine">
                            <xsl:value-of select="@combine"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="@href">
                        <xsl:attribute name="href">
                            <xsl:value-of select="@href"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:apply-templates select="node()[self::rng:*]" mode="prevedeniNaLM">
                        <xsl:with-param name="pouziteOdkazy">
                            <xsl:copy-of select="$pouziteOdkazy"/>
                        </xsl:with-param>
                    </xsl:apply-templates> 
                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
       
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:rng="http://relaxng.org/ns/structure/1.0"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
>

    <!-- definice vystupu -->
    <xsl:output method="xml" 
        indent="yes" 
        encoding="UTF-8" 
        media-type="image/svg" 
        doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" 
        doctype-public="-//W3C//DTD SVG 1.1//EN" />
    
    <!-- prejmenovani jmenneho prostoru pro vystup -->
    <xsl:namespace-alias stylesheet-prefix="rng" result-prefix=""/>
    
    <!-- odstrani bile mezery, ktere jsou potomky -->
    <xsl:strip-space elements="rng:*"/>

    <!-- nejsirsi objekt -->
    <xsl:variable name="nejsirsiObjekt">
        <xsl:value-of select="150"/>
    </xsl:variable>

    <!-- rozmer y pro cely dokument -->
    <xsl:variable name="vyskaDokumentu">
        <xsl:value-of select="(count((//node())[not(node())]) * ($vyskaObjektu+$vertikalniVzdalenost))+$vertikalniVzdalenost+$odsazeniY"/>
    </xsl:variable>
    
    <!-- rozmer x pro cely dokument -->
    <xsl:variable name="sirkaDokumentu">
        <xsl:for-each select="//node()[not(node())]">
            <xsl:sort select="count(ancestor-or-self::*)" order="descending" data-type="number"/>
            <xsl:if test="position()=1">
                <xsl:value-of select="count(ancestor-or-self::*)*($nejsirsiObjekt+$horizontalniVzdalenost)+$odsazeniX"/>
            </xsl:if>
        </xsl:for-each>

    </xsl:variable>

    <!-- odsazeni ze shora -->
    <xsl:variable name="odsazeniY" select="50"/>
    
    <!-- odsazeni z prava -->
    <xsl:variable name="odsazeniX" select="10"/>

    <!-- vyska vsech grafickych prvku -->
    <xsl:variable name="vyskaObjektu" select="40"/>
    
    <!-- vertikalni vzdalenost grafickych prvku -->
    <xsl:variable name="vertikalniVzdalenost" select="10"/>
    
    <!-- horizontalni vzdalenost grafickych prvku -->
    <xsl:variable name="horizontalniVzdalenost" select="20"/>
    
    
    
    
    <!-- sablona pro sirku grafickych prvku -->
    <xsl:template name="sirkaObjektu"> 
        <xsl:variable name="objekt">
            <xsl:call-template name="vyberObjektu"/>            
        </xsl:variable>
        <xsl:value-of select="$objekt/rect[1]/@width"  xpath-default-namespace="http://www.w3.org/2000/svg"/>
    </xsl:template>


    <!-- sablona pro vyber vhodneho objektu -->
    <xsl:template name="vyberObjektu">
        <xsl:choose>
            <xsl:when test="local-name()='element'">
                <xsl:call-template name="element"/>                
            </xsl:when>
            <xsl:when test="local-name()='grammar'">
                <xsl:call-template name="grammar"/>                
            </xsl:when>
            <xsl:when test="local-name()='text'">
                <xsl:call-template name="text"/>                
            </xsl:when>
            <xsl:when test="local-name()='start'">
                <xsl:call-template name="start"/>                
            </xsl:when>
            <xsl:when test="local-name()='attribute'">
                <xsl:call-template name="attribute"/>                
            </xsl:when>
            <xsl:when test="local-name()='group'">
                <xsl:call-template name="group"/>                
            </xsl:when>
            <xsl:when test="local-name()='interleave'">
                <xsl:call-template name="interleave"/>                
            </xsl:when>
            <xsl:when test="local-name()='mixed'">
                <xsl:call-template name="mixed"/>                
            </xsl:when>
            <xsl:when test="local-name()='choice'">
                <xsl:call-template name="choice"/>                
            </xsl:when>
            <xsl:when test="local-name()='optional'">
                <xsl:call-template name="optional"/>                
            </xsl:when>
            <xsl:when test="local-name()='zeroOrMore'">
                <xsl:call-template name="zeroOrMore"/>                
            </xsl:when>
            <xsl:when test="local-name()='oneOrMore'">
                <xsl:call-template name="oneOrMore"/>                
            </xsl:when>
            <xsl:when test="local-name()='empty'">
                <xsl:call-template name="empty"/>                
            </xsl:when>
            <xsl:when test="local-name()='data'">
                <xsl:call-template name="data"/>                
            </xsl:when>
            <xsl:when test="local-name()='param'">
                <xsl:call-template name="param"/>                
            </xsl:when>
            <xsl:when test="local-name()='value'">
                <xsl:call-template name="value"/>                
            </xsl:when>
            <xsl:when test="local-name()='except'">
                <xsl:call-template name="except"/>                
            </xsl:when>
            <xsl:when test="local-name()='list'">
                <xsl:call-template name="list"/>                
            </xsl:when>
            <xsl:when test="local-name()='ref'">
                <xsl:call-template name="ref"/>                
            </xsl:when>
            <xsl:when test="local-name()='parentRef'">
                <xsl:call-template name="parentRef"/>                
            </xsl:when>
            <xsl:when test="local-name()='define'">
                <xsl:call-template name="define"/>                
            </xsl:when>
            <xsl:when test="local-name()='externalRef'">
                <xsl:call-template name="externalRef"/>                
            </xsl:when>
            <xsl:when test="local-name()='include'">
                <xsl:call-template name="include"/>                
            </xsl:when>
            <xsl:when test="local-name()='div'">
                <xsl:call-template name="div"/>                
            </xsl:when>
            <xsl:when test="local-name()='notAllowed'">
                <xsl:call-template name="notAllowed"/>                
            </xsl:when>
            <xsl:when test="local-name()='name'">
                <xsl:call-template name="name"/>                
            </xsl:when>
            <xsl:when test="local-name()='nsName'">
                <xsl:call-template name="nsName"/>                
            </xsl:when>
            <xsl:when test="local-name()='anyName'">
                <xsl:call-template name="anyName"/>                
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="text"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- sablona pro zjisteni y souradnic jakehokoliv objektu 
        reprezentujiciho RelaxNG schema -->
    <xsl:template name="ySouradnice">
        <xsl:value-of select="(count(((preceding::node()|ancestor::node())[self::rng:*])[not(node()[self::rng:*])]) * ($vyskaObjektu+$vertikalniVzdalenost))+$odsazeniY"/>
    </xsl:template>
 
    <!-- sablona pro spojeni objektu s rodicem -->
    <xsl:template name="spojeniSRodicem">
        <xsl:variable name="vzdalenostKPredchudci" select="count((preceding-sibling::*[1]/descendant-or-self::node())[not(node())]) * ($vyskaObjektu+$vertikalniVzdalenost)"/>
        <xsl:choose>
            <xsl:when test="position()=1">
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -12 0 l 0 0"/>
            </xsl:when>
            <xsl:when test="not(position()=1 or position()=last())">            
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -10 0 l 0 -{$vzdalenostKPredchudci}"/>
            </xsl:when>
            <xsl:when test="position()=last()">
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 {$vyskaObjektu div 2} l -10 0 l 0 -{$vzdalenostKPredchudci}"/>
            </xsl:when>
        </xsl:choose>   
    </xsl:template>
 
    <!-- sablona pro ecmascript -->
    <xsl:template name="ecmascript">
        <script type="text/ecmascript"> 
<![CDATA[
//Ecmascript

//Globální proměnné začínající podtržítkem.
var _kolekceSouradnicSpojeni = [];
var _kolekceGrafickychObjektu = [];
var _kolekceSouradnicTransform = [];
var _kolekceSpojeni = [];
var _kolekcePlusMinus = [];
var _svgDokument = null;
var _vertikalniPosun = 50;
            

/**
  *Fce vyvolaná po načtení svg obrázku, která načte kolekce grafických objektů.
  *
  *@param udalost   událost, která fci vyvolala
  */
function poNacteni(udalost) { 
  _svgDokument = udalost.target.ownerDocument;  
  _kolekceSpojeni = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('path'), 'spojeni');
  _kolekceSouradnicSpojeni = ziskaniAtributuZUzlu(_kolekceSpojeni, 'd');  
  _kolekceGrafickychObjektu = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('g'), 'uzel'); 
  _kolekceSouradnicTransform = ziskaniAtributuZUzlu(_kolekceGrafickychObjektu, 'transform');
  _kolekcePlusMinus = ziskaniUzluPodleTridy(_svgDokument.getElementsByTagName('use'), 'plusminus');     
}


/**
  *Fce, která z kolekce uzlů vrátí jen ty, které náleží do určité třídy.
  *
  *@param uzly    kolekce uzlů, které se mají prohledávat
  *@param trida   název třídy  
  *@return        kolekce uzlů příslušné třídy
  */
function ziskaniUzluPodleTridy(uzly, trida){
  var vysledneUzly = [];
  for (var i=0; i<uzly.length; i++) {
    if(uzly[i].getAttribute('class')==trida){
      vysledneUzly.push(uzly[i]);
    }
  }
  return vysledneUzly;  
}


/**
  *Fce, která nalezne uzel podle Id.
  *
  *@param uzly    kolekce uzlů, které se mají prohledávat
  *@param trida   id Uzlu  
  *@return        kolekce uzlů příslušné třídy
  */
function ziskaniUzluPodleId(uzly, hledaneId){
  var vysledek = null;
  for (var i=0; i<uzly.length; i++) {
    if(uzly[i].getAttribute('id')==hledaneId){
      vysledek=uzly[i];
    }
  }
  return vysledek;  
}


/**
  *Fce, která z kolekce uzlů vrátí stejně velkou kolekci, která bude obsahovat
  *namísto uzlů jen hodnoty určitého atributu.   
  *
  *@param uzly      kolekce uzlů, které se mají prohledávat
  *@param atribut   název atriutu, který se nachází ve všech uzlech  
  *@return          kolekce hodnot atributů
  */
function ziskaniAtributuZUzlu(uzly, atribut){
  var vysledneUzly = [];
  for (var i=0; i<uzly.length; i++) {
    vysledneUzly.push(uzly[i].getAttribute(atribut));
  }
  return vysledneUzly;  
}


/**
  *U objektu use, který fci vyvolal, se změní odkaz ze známénka plus na mínus 
  *nebo obráceně.     
  *
  *@param udalost   událost, která fci vyvolala
  */
function zmenaPlusMinus(uzel){
  var soucasneZnamenko=uzel.getAttribute('xlink:href');
  if(soucasneZnamenko=="#minus"){
    uzel.setAttribute('xlink:href', '#plus');
  }else{
    uzel.setAttribute('xlink:href', '#minus');          
  }                
}


/**
  *Fce se vyvolá při kliknutí na znaménko plus nebo minus v obrázku. Tím se
  *změní visuální hodnota celého stromu - některé větve se zabalí nebo naopak
  *jiné rozbalí.        
  *
  *@param udalost   událost, která fci vyvolala
  */
function zmenaStromu(udalost){
  var objekt=udalost.target; 
  rizeniZmen(objekt); 
}


/**
  *Fce, která řídí změny ve stromu.        
  *
  *@param objekt   objekt, který fci vyvolal
  */
function rizeniZmen(objekt){
  var soucasneZnamenko=objekt.getAttribute('xlink:href');
  var idUzlu=objekt.getAttribute('id').substring(4);
  var uzel=ziskaniUzluPodleId(_kolekceGrafickychObjektu, idUzlu);
  var jeViditelny=uzel.getAttribute('visibility');
  if(jeViditelny=='visible'){
    zmenaPlusMinus(objekt);
    if(soucasneZnamenko=="#plus"){
      typ='rozbaleni';
      vseViditelne();   
      zneviditelneniObjektu();
      zmenyPolohyUzlu(objekt, typ); 
    }else{
      typ='zabaleni'; 
      zmenyPolohyUzlu(objekt, typ); 
      vseViditelne();   
      zneviditelneniObjektu();         
    }
  }
}


/**
  *Fce pro získání X souřadnice z atributu transform.       
  *
  *@param hodnotaTransform    hodnota, která je obsažena v atributu transform
  *@return                    x souřadnice objektu  
  */
function ziskaniXPosunutiObjektu(hodnotaTransform){                      
  return hodnotaTransform.substring(10, hodnotaTransform.indexOf(',')); 
}


/**
  *Fce pro získání Y souřadnice z atributu transform.       
  *
  *@param hodnotaTransform    hodnota, která je obsažena v atributu transform
  *@return                    y souřadnice objektu  
  */
function ziskaniYPosunutiObjektu(hodnotaTransform){
  return hodnotaTransform.substring(hodnotaTransform.indexOf(',')+1,hodnotaTransform.indexOf(')'));                   
}


/**
  *Fce pro získání prvních znaků z atributu d nacházejícího se u cesty path.
  *Vrátí vše kromě posledního čísla cesty.         
  *
  *@param hodnotaD  hodnota, která je obsažena v atributu d
  *@return          začátek cesty  
  */
function ziskaniZacatkuCesty(hodnotaD){
  return hodnotaD.substring(0, hodnotaD.lastIndexOf(' '));                   
}


/**
  *Fce vrátí pouze poslední číslo, které se nachází v atributu d cesty path.      
  *
  *@param hodnotaD  hodnota, která je obsažena v atributu d
  *@return          poslední souřadnice cesty 
  */
function ziskaniKonceCesty(hodnotaD){
  return hodnotaD.substring(hodnotaD.lastIndexOf(' '));                    
}


/**
  *Fce nastaví atribut visibility všech objektů na visible.   
  *
  */
function vseViditelne(){
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    _kolekceGrafickychObjektu[i].setAttribute('visibility', 'visible');
  }
}   
 


/**
  *Fce zjistí, zda je první hodnota ID potomkem druhé hodnoty ID. Pokud ano, 
  *vrátí true
  *
  *@param IdPotomka id eventuálního potomka
  *@param IdUzlu    id aktuálního uzlu
  *@return          vrátí true, když je potomek, nebo false, když není
  *    
  */
function jePotomek(IdPotomka, IdUzlu){
  poleIdPotomka=IdPotomka.split('_');
  poleIdUzlu=IdUzlu.split('_');  
  if(poleIdPotomka.length>poleIdUzlu.length){
    for(var i=0; i<poleIdUzlu.length; i++){
      if(poleIdPotomka[i]!=poleIdUzlu[i]){
        return false;
      }
    }
    return true;  
  }
  else{
    return false;
  }
} 


/**
  *Fce zjistí, zda se jedná o následníka, který je ve větvi, která se odděluje
  *od rodičovské, na prvním místě.  
  *
  *@param IdPotomka id eventuálního potomka
  *@param IdUzlu    id aktuálního uzlu
  *@return          vrátí true, když je potomek, nebo false, když není
  *    
  */
function jeNaslednikPrvniUrovne(IdNaslednika, IdUzlu){
  poleIdNaslednika=IdNaslednika.split('_');
  poleIdUzlu=IdUzlu.split('_');  
  if(poleIdNaslednika.length<=poleIdUzlu.length){
    for(var i=0; i<poleIdNaslednika.length; i++){
      if(i==(poleIdNaslednika.length-1)){
        if(Number(poleIdNaslednika[i])==(Number(poleIdUzlu[i])+1)){
          return true;  
        }
        return false;        
      }
      else{
        if(poleIdNaslednika[i]!=poleIdUzlu[i]){
          return false;
        }
      }
    }
    return true;  
  }
  else{
    return false;
  }
} 


/**
  *Fce zjistí, zda je první hodnota ID následníkem druhé hodnoty ID. Pokud ano, 
  *vrátí true
  *
  *@param IdNaslednika  id eventuálního následníka
  *@param IdUzlu        id aktuálního uzlu
  *@return              vrátí true, když je následník, nebo false, když není
  *    
  */
function jeNaslednik(IdNaslednika, IdUzlu){
  poleIdNaslednika=IdNaslednika.split('_');
  poleIdUzlu=IdUzlu.split('_');   
  if(poleIdNaslednika.length>poleIdUzlu.length){
    for(var i=0; i<poleIdUzlu.length; i++){
      if(poleIdNaslednika[i]<poleIdUzlu[i]){
        return false;
      }
      else{
        if(poleIdNaslednika[i]>poleIdUzlu[i]){
          return true;
        }
      }     
    }
  }
  else{
    for(var i=0; i<poleIdNaslednika.length; i++){
      if(poleIdNaslednika[i]<poleIdUzlu[i]){
        return false;
      }
      else{
        if(poleIdNaslednika[i]>poleIdUzlu[i]){
          return true;
        }
      }     
    }    
  }
  return false;
} 


/**
  *Fce zjistí, zda má uzel podle zadaného ID nějaké děti, jejichž
  *atribut visibility je nastaven na visible. Vrátí jejich součet. 
  *
  *@param IdUzlu        id aktuálního uzlu
  *@return              vrátí počet viditelných dětí konkrétního uzlu
  *    
  */
function pocetViditelnychDeti(IdUzlu){
  var poleIdUzlu=IdUzlu.split('_');
  var pocetDeti=0;
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel=_kolekceGrafickychObjektu[i];
    var IdVybranehoUzlu=vybranyUzel.getAttribute('id');
    var poleIdVybranehoUzlu=IdVybranehoUzlu.split('_');
    var maDeti=1;
    for(var iter=0; iter<poleIdUzlu.length; iter++){
      if(poleIdUzlu[iter]!=poleIdVybranehoUzlu[iter]){
        maDeti=0;
      }
    }
    if(IdUzlu==IdVybranehoUzlu){
      maDeti=0;
    }
    if(vybranyUzel.getAttribute('visibility')=='hidden'){
      maDeti=0;
    }
    pocetDeti=pocetDeti+maDeti;
  }
  return pocetDeti;
}

/**
  *Fci je předána událost, která fci vyvolala. Smyslem fce je posunout všechny
  *následníky, aby doléhali na uzel vyvolávající událost.     
  *
  *@param udalost     událost, která fci vyvolala  
  *@param typ         typ udává, zda-li jde o zabalení či rozbalení  
  *
  */
function zmenyPolohyUzlu(objekt, typ){
  var IdUzlu = objekt.getAttribute('id').substring(4);
  var pocetRadekPosunu=0;
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel = _kolekceGrafickychObjektu[i];
    var idVybranehoUzlu = vybranyUzel.getAttribute('id');
    if(jePotomek(idVybranehoUzlu ,IdUzlu)){
      if(pocetViditelnychDeti(idVybranehoUzlu)==0 && vybranyUzel.getAttribute('visibility')=='visible'){
        pocetRadekPosunu++;
      }
    }    
  }
  for (var i=0; i<_kolekceGrafickychObjektu.length; i++) {
    var vybranyUzel = _kolekceGrafickychObjektu[i];
    var IdVybranehoUzlu = vybranyUzel.getAttribute('id');
    if(jeNaslednik(IdVybranehoUzlu ,IdUzlu)){
      if(typ=='rozbaleni'){        
        posunObjektu(IdVybranehoUzlu, (pocetRadekPosunu-1)*_vertikalniPosun);
        if(jeNaslednikPrvniUrovne(IdVybranehoUzlu ,IdUzlu)){
          zmenaSpojeni(IdVybranehoUzlu, -(pocetRadekPosunu-1)*_vertikalniPosun);
        }
      }     
      else{
        posunObjektu(IdVybranehoUzlu, -(pocetRadekPosunu-1)*_vertikalniPosun);
        if(jeNaslednikPrvniUrovne(IdVybranehoUzlu ,IdUzlu)){
          zmenaSpojeni(IdVybranehoUzlu, (pocetRadekPosunu-1)*_vertikalniPosun);
        }   
      }   
    }
  }  
} 

/**
  *Vertikální posun uzlu. Vždy se posouvá z aktuálního umístění.  
  *
  *@param IdObjektu     id objektu, kterým má být posunuto
  *@param posunPoOseY   číslo vyjadřující o kolik se posune     
  *
  */
function posunObjektu(IdObjektu, posunPoOseY){
  var objekt=ziskaniUzluPodleId(_kolekceGrafickychObjektu, IdObjektu);
  var stavajiciTransformace=objekt.getAttribute('transform');
  var x=Number(ziskaniXPosunutiObjektu(stavajiciTransformace));
  var y=Number(ziskaniYPosunutiObjektu(stavajiciTransformace));
  y=y+posunPoOseY;
  objekt.setAttribute('transform', 'translate('+x+' , '+y+')');
} 



/**
  *Fce změní velikosti úseček spojujících grafické uzly.
  *
  *@param IdObjektu     id uzlu, kterým má být posunuto
  *@param posunPoOseY   číslo vyjadřující o kolik se posune     
  *
  */
function zmenaSpojeni(IdObjektu, zmenaVelikosti){
  var vybranyIterator=null;
  for (var iter=0; iter<_kolekceGrafickychObjektu.length; iter++) {
    if(IdObjektu==_kolekceGrafickychObjektu[iter].getAttribute('id')){
      vybranyIterator=iter;
    }
  }
  var objekt=_kolekceSpojeni[vybranyIterator];  
  var stavajiciD=objekt.getAttribute('d');
  var zacatek=ziskaniZacatkuCesty(stavajiciD);
  var y=Number(ziskaniKonceCesty(stavajiciD));
  y=y+zmenaVelikosti;
  objekt.setAttribute('d', zacatek+' '+y);
} 



 
/**
  *Fce nastaví atribut visibility na hidden u všech dětí za každým 
  *uzlem se znaménkem plus.  
  *
  */
function zneviditelneniObjektu(){
  for (var i=0; i<_kolekcePlusMinus.length; i++) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#plus"){                 
      var IdRodice = _kolekcePlusMinus[i].getAttribute('id').substring(4);//odstraneni textu plus
      for (var iter=0; iter<_kolekceGrafickychObjektu.length; iter++) {
        var vybranyObjektId=_kolekceGrafickychObjektu[iter].getAttribute('id');
        if(jePotomek(vybranyObjektId, IdRodice)){
            _kolekceGrafickychObjektu[iter].setAttribute('visibility', 'hidden');   
        }                                             
      }
    }
  }
}  


/**
  *Rozbalení všech uzlů  
  *
  */
function rozbaleniVsechUzlu(){ 
  for (var i=0; i<_kolekcePlusMinus.length; i++) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#plus"){                 
      rizeniZmen(_kolekcePlusMinus[i]);
    }
  }   
} 

/**
  *Zabalení všech uzlů 
  *
  */
function zabaleniVsechUzlu(){ 
  rozbaleniVsechUzlu();
  for (var i=_kolekcePlusMinus.length-1; i>-1; i--) {
    if(_kolekcePlusMinus[i].getAttribute('xlink:href')=="#minus"){                 
      rizeniZmen(_kolekcePlusMinus[i]);
    }
  }   
}  
]]>
        </script>  
    </xsl:template>
 
    <!-- sablona pro opakovane symboly -->
    <xsl:template name="opakovaneSymboly">
        <defs>
            <symbol id="plus" visibility="inherit">
                <desc>plus</desc>
                <rect x="0" y="0" width="8" height="8"
                    fill="white" stroke="black" stroke-width="1" />           
                <line x1="1" y1="4" x2="7" y2="4"
                    stroke-width="1" stroke="black"/>                 
                <line x1="4" y1="1" x2="4" y2="7"
                    stroke-width="1" stroke="black"/>   
            </symbol>
                        
            <symbol id="minus" visibility="inherit">
                <desc>minus</desc>
                <rect x="0" y="0" width="8" height="8"
                    fill="white" stroke="black" stroke-width="1" /> 
                <line x1="1" y1="4" x2="7" y2="4"
                    stroke-width="1" stroke="black"/>   
            </symbol>
        </defs>
    </xsl:template>
        
        <!-- sablona pro objekty, ktere oteviraji nebo zaviraji vse-->
        <xsl:template name="rozbalitZabalit">
            <g class="rozbalitZabalit" visibility="visible" transform="translate({$odsazeniX}, 10)" onclick="zabaleniVsechUzlu();">
                <rect x="0" y="10" width="150" height="20"
                rx="1"
                fill="white" stroke="black" stroke-width="1" />  
                <text x="5" y="27"
                    font-family="Helvetica" font-size="14"
                    fill="black">Zabalit strom</text>
            </g>
            
            <g class="rozbalitZabalit" visibility="visible" transform="translate({$odsazeniX+180}, 10)" onclick="rozbaleniVsechUzlu();">
                <rect x="0" y="10" width="150" height="20"
                    rx="1"
                    fill="white" stroke="black" stroke-width="1" />  
                <text x="5" y="27"
                    font-family="Helvetica" font-size="14"
                    fill="black">Rozbalit strom</text>
            </g>
        </xsl:template>
 
    <!-- root sablona -->
    <xsl:template match="/">
        <svg width="{$sirkaDokumentu}" height="{$vyskaDokumentu}" 
            onload="poNacteni(evt)">  
            <xsl:variable name="sirkaObjektu">
                <xsl:call-template name="sirkaObjektu"/>
            </xsl:variable>          
            <title>Uplny Relax NG model</title>
            <xsl:call-template name="ecmascript"/>
            <xsl:call-template name="opakovaneSymboly"/>
            <xsl:call-template name="rozbalitZabalit"/>
            <g id="_1" class="uzel" visibility="visible" transform="translate({$odsazeniX}, {$odsazeniY})" >
                <xsl:call-template name="root"/>
                <path class="spojeni" fill="none" stroke="black" stroke-width="1"
                    d="M 0 0 l 0 0 l 0 0"/>
                <xsl:if test="node()[self::rng:*]">
                    <use xlink:href='#minus' id="plus_{position()}" transform="translate(40, 16 )" onclick="zmenaStromu(evt);" class="plusminus"/>
                </xsl:if>
            </g>
            <xsl:apply-templates select="node()[self::rng:*]">
                <xsl:with-param name="id-vetve" select="concat( '_', position())"/>
                <xsl:with-param name="xSouradnice" select="40+$horizontalniVzdalenost+$odsazeniX"/>
            </xsl:apply-templates>
        </svg>
    </xsl:template>

    <!-- sablona pro vsechny elementy z jmenneho prostoru rng -->
    <xsl:template match="rng:*">
        <xsl:param name="id-vetve"/>
        <xsl:param name="xSouradnice" select="0"/>
        <xsl:variable name="xSouradnice" select="$xSouradnice"/>
        <xsl:variable name="sirkaObjektu">
            <xsl:call-template name="sirkaObjektu"/>
        </xsl:variable>
        <xsl:variable name="ySouradnice">
            <xsl:call-template name="ySouradnice"/>
        </xsl:variable>
        <g id="{$id-vetve}_{position()}" class="uzel" visibility="visible" transform="translate({$xSouradnice}, {$ySouradnice})">
        <xsl:call-template name="vyberObjektu"/>
        <xsl:call-template name="spojeniSRodicem"/>
            <xsl:if test="node()[self::rng:*]">
            <use xlink:href='#minus' id="plus{$id-vetve}_{position()}" transform="translate({$sirkaObjektu}, {$vyskaObjektu div 2 - 4} )" onclick="zmenaStromu(evt);" class="plusminus"/>
        </xsl:if>
        </g>
        <xsl:apply-templates select="rng:*">
            <xsl:with-param name="id-vetve" select="concat($id-vetve, '_', position())"/>
            <xsl:with-param name="xSouradnice" select="$xSouradnice+$sirkaObjektu+$horizontalniVzdalenost"/>
        </xsl:apply-templates>
    </xsl:template>


    <!-- sablona pro vsechny elementy element -->
    <xsl:template name="element">
        <xsl:variable name="ns" select="(ancestor-or-self::rng:*/@ns)[last()]"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($ns)*7">
                    <xsl:value-of select="string-length($ns)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($ns)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>element</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="15,4 4,20 15,36 " /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="20,4 31,20 20,36 " /> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($ns)=0)">
                ns: <xsl:value-of select="$ns"/>
            </xsl:if>
        </text>
    </xsl:template>

    <!-- sablona pro vsechny elementy grammar -->
    <xsl:template name="grammar">
        <desc>grammar</desc>
        <rect x="0" y="0" width="103" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            {grammar}
        </text>        
    </xsl:template>
    
    <!-- sablona pro vsechny elementy start -->
    <xsl:template name="start">
        <desc>start</desc>
        <rect x="0" y="0" width="100" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />    
        <rect x="4" y="6" width="28" height="28"
            fill="none" stroke="#006000" stroke-width="2" />      
        <polygon fill="#006000" stroke="#006000" stroke-width="0"
            points="35,6 35,34 45,20" />      
        <text x="50" y="25"
            font-family="Helvetica" font-size="18"
            fill="#006000" >
            Start
        </text> 
        <xsl:if test="@combine='choice'">
            <line x1="18" y1="9" x2="18" y2="31"
                stroke-width="2" stroke="#006000"/>  
        </xsl:if>
        <xsl:if test="@combine='interleave'">
            <polyline fill="none" stroke="#006000" stroke-width="2"
                points="7,16 18,9 29,16 " /> 
        </xsl:if>
        <xsl:if test="@combine='choice'">
            <line x1="18" y1="9" x2="18" y2="31"
                stroke-width="2" stroke="#006000"/>  
        </xsl:if>
        <xsl:if test="@combine='interleave'">
            <polyline fill="none" stroke="#006000" stroke-width="2"
                points="7,16 18,9 29,16 " /> 
        </xsl:if>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy text -->
    <xsl:template name="text">
        <desc>text</desc>
        <rect x="0" y="3" width="40" height="34"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            text
        </text>          
    </xsl:template>
    
    <!-- sablona pro vsechny elementy attribute -->
    <xsl:template name="attribute">
        <xsl:variable name="ns" select="@ns"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($ns)*7">
                    <xsl:value-of select="string-length($ns)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($ns)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>atribut</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="28"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            @
        </text> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($ns)=0)">
                ns: <xsl:value-of select="$ns"/>
            </xsl:if>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy root -->
    <xsl:template name="root">
        <desc>root</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />    
        <line x1="8" y1="36" x2="32" y2="4"
            stroke-width="2" stroke="#006000"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy group-->
    <xsl:template name="group">
        <desc>group</desc>
        <rect x="0" y="10" width="49" height="20"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />         
        <line x1="4" y1="20" x2="45" y2="20"
            stroke-width="2" stroke="#006000"/>        
        <rect x="4" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>        
        <rect x="16" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>         
        <rect x="28" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>         
        <rect x="40" y="17" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/>    
    </xsl:template>
    
    <!-- sablona pro vsechny elementy interleave -->
    <xsl:template name="interleave">
        <desc>interleave</desc>
        <rect x="0" y="0" width="49" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />     
        <line x1="4" y1="20" x2="12" y2="20"
            stroke-width="2" stroke="#006000"/> 
        <rect x="12" y="7" width="25" height="26"
            rx="3"
            fill="none" stroke="#006000" stroke-width="2" />   
        <line x1="37" y1="20" x2="45" y2="20"
            stroke-width="2" stroke="#006000"/> 
        <rect x="22" y="4" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/> 
        <rect x="22" y="30" width="5" height="6"
            fill="#006000" stroke="none" stroke-width="0"/> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy mixed -->
    <xsl:template name="mixed">
        <desc>mixed</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <line x1="6" y1="6" x2="6" y2="26"
            stroke-width="2" stroke="#006000"/>    
        <line x1="6" y1="6" x2="26" y2="6"
            stroke-width="2" stroke="#006000"/>  
        <line x1="6" y1="26" x2="16" y2="26"
            stroke-width="2" stroke="#006000"/>        
        <line x1="26" y1="6" x2="26" y2="16"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="16" x2="16" y2="36"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="16" x2="36" y2="16"
            stroke-width="2" stroke="#006000"/> 
        <line x1="16" y1="36" x2="36" y2="16"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy choice -->
    <xsl:template name="choice">
        <desc>choice</desc>
        <rect x="0" y="1" width="40" height="38"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <line x1="30" y1="5" x2="30" y2="34"
            stroke-width="2" stroke="#006000"/>   
        <line x1="4" y1="21" x2="14" y2="21"
            stroke-width="2" stroke="#006000"/> 
        <line x1="14" y1="21" x2="30" y2="9"
            stroke-width="2" stroke="#006000"/> 
        <rect x="27" y="5" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/> 
        <rect x="27" y="17" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/>  
        <rect x="27" y="29" width="6" height="5"
            fill="#006000" stroke="none" stroke-width="0"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy optional -->
    <xsl:template name="optional">
        <desc>optional</desc>
        <rect x="0" y="4" width="40" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            0..1
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy zeroOrMore -->
    <xsl:template name="zeroOrMore">
        <desc>zeroOrMore</desc>
        <rect x="0" y="4" width="45" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" />  
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            0..<xsl:text disable-output-escaping="yes">&amp;</xsl:text>#8734;
        </text>       
    </xsl:template>
    
    <!-- sablona pro vsechny elementy oneOrMore -->
    <xsl:template name="oneOrMore">
        <desc>oneOrMore</desc>
        <rect x="0" y="4" width="45" height="32"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            1..<xsl:text disable-output-escaping="yes">&amp;</xsl:text>#8734;
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy empty -->
    <xsl:template name="empty">
        <desc>empty</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" /> 
        <ellipse
            cx="20" cy="20" rx="12" ry="13"
            fill="none" stroke="#006000" stroke-width="2"/> 
        <line x1="4" y1="36" x2="36" y2="4"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy data -->
    <xsl:template name="data">
        <xsl:variable name="dtL" select="(ancestor-or-self::rng:*/@datatypeLibrary)[last()]"/>        
        <xsl:variable name="sirkaObjektu">
            <xsl:choose>
                <xsl:when test="string-length(@name)*9&lt;string-length($dtL)*7">
                    <xsl:value-of select="string-length($dtL)*7+48"/>
                </xsl:when>
                <xsl:when test="string-length(@name)*9&gt;string-length($dtL)*7">
                    <xsl:value-of select="string-length(@name)*9+40"/>            
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="50"/>
                </xsl:otherwise>
            </xsl:choose> 
        </xsl:variable>  
        <desc>data</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#FFFFCC" stroke="black" stroke-width="1" />        
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            d
        </text>       
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@type"/>
        </text>  
        <text x="35" y="36"
            font-family="Helvetica" font-size="10"
            fill="black" >
            <xsl:if test="not(string-length($dtL)=0)">
                dtL: <xsl:value-of select="$dtL"/>
            </xsl:if>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy param -->
    <xsl:template name="param">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name)+string-length(text()))*9+48"/>
        <desc>param</desc>
        <rect x="0" y="5" width="{$sirkaObjektu}" height="30"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="#006000" stroke="#006000" stroke-width="2"
            points="20,10 20,30 9,20" /> 
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>: <xsl:value-of select="text()"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy value -->
    <xsl:template name="value">
        <xsl:variable name="sirkaObjektu" select="(string-length(text()))*9+40"/>
        <desc>value</desc>
        <rect x="0" y="5" width="{$sirkaObjektu}" height="30"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="4" y="11" width="18" height="18"
            fill="none" stroke="#006000" stroke-width="2" /> 
        <rect x="11" y="18" width="4" height="4"
            fill="#006000" stroke="#006000" stroke-width="2" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="text()"/>
        </text>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy except -->
    <xsl:template name="except">
        <desc>except</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="10,4 22,4 22,36 " /> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy list -->
    <xsl:template name="list">
        <desc>list</desc>
        <rect x="0" y="0" width="30" height="39"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="12" y="4" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/>    
        <rect x="12" y="17" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/> 
        <rect x="12" y="30" width="6" height="5"
            fill="#006000" stroke="#006000" stroke-width="1"/>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy ref -->
    <xsl:template name="ref">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>ref</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="60" y="30" width="13" height="13"
            fill="white" stroke="#006000" stroke-width="2" /> 
        <line x1="63" y1="40" x2="70" y2="33"
            stroke-width="2" stroke="#006000"/>  
        <polygon fill="#006000" stroke="#006000" stroke-width="1"
            points="70,33 70,38 65,33" /> 
        <text x="8" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy parentRef -->
    <xsl:template name="parentRef">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>parentRef</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="60" y="30" width="13" height="13"
            fill="white" stroke="#006000" stroke-width="2" /> 
        <line x1="63" y1="40" x2="70" y2="33"
            stroke-width="2" stroke="#006000"/>  
        <line x1="67" y1="40" x2="63" y2="36"
            stroke-width="2" stroke="#006000"/>  
        <polygon fill="#006000" stroke="#006000" stroke-width="1"
            points="70,33 70,38 65,33" /> 
        <text x="8" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy define -->
    <xsl:template name="define">
        <xsl:variable name="sirkaObjektu" select="(string-length(@name))*9+40"/>
        <desc>define</desc>
        <rect x="0" y="0" width="{$sirkaObjektu}" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <rect x="4" y="6" width="28" height="28"
            fill="none" stroke="#006000" stroke-width="2" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@name"/>
        </text>  
        <xsl:if test="@combine='choice'">
        <line x1="18" y1="9" x2="18" y2="31"
            stroke-width="2" stroke="#006000"/>  
        </xsl:if>
        <xsl:if test="@combine='interleave'">
        <polyline fill="none" stroke="#006000" stroke-width="2"
        points="7,16 18,9 29,16 " /> 
        </xsl:if>
    </xsl:template>
    
    <!-- sablona pro vsechny elementy externalRef -->
    <xsl:template name="externalRef">
        <xsl:variable name="sirkaObjektu" select="(string-length(@href))*9+40"/>
        <desc>externalRef</desc>
        <rect x="0" y="2" width="{$sirkaObjektu}" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="none" stroke="#006000" stroke-width="2"
            points="4,20 14,10 14,17 24,17 24,23 14,23 14,30" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@href"/>
        </text> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy include -->
    <xsl:template name="include">
        <xsl:variable name="sirkaObjektu" select="(string-length(@href))*9+40"/>
        <desc>include</desc>
        <rect x="0" y="2" width="{$sirkaObjektu}" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polygon fill="#006000" stroke="#006000" stroke-width="2"
            points="4,20 14,10 14,17 24,17 24,23 14,23 14,30" /> 
        <text x="40" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@href"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy div -->
    <xsl:template name="div">
        <desc>div</desc>
        <rect x="0" y="0" width="150" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="26"
            font-family="Helvetica" font-size="20"
            fill="#006000" >
            {div}
        </text> 
    </xsl:template>
    
    <!-- sablona pro vsechny elementy notAllowed -->
    <xsl:template name="notAllowed">
        <desc>notAllowed</desc>
        <rect x="0" y="2" width="40" height="36"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <circle cx="20" cy="20" r="12"
            fill="#F2ACA9" stroke="#006000" stroke-width="2" /> 
        <line x1="10" y1="20" x2="30" y2="20"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
    
    <!-- sablona pro vsechny elementy name -->
    <xsl:template name="name">
        <xsl:variable name="sirkaObjektu" select="(string-length(text()))*9+40"/>
        <desc>name</desc>
        <rect x="0" y="3" width="{$sirkaObjektu}" height="34"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            N
        </text>   
        <text x="35" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="text()"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy nsName -->
    <xsl:template name="nsName">
        <xsl:variable name="sirkaObjektu" select="(string-length(@ns))*9+40"/>
        <desc>nsName</desc>
        <rect x="0" y="3" width="{$sirkaObjektu}" height="34"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <text x="4" y="30"
            font-family="Helvetica" font-size="30"
            fill="#006000" >
            NS
        </text>
        
        <text x="50" y="25"
            font-family="Helvetica" font-size="15"
            fill="black" >
            <xsl:value-of select="@ns"/>
        </text>  
    </xsl:template>
    
    <!-- sablona pro vsechny elementy anyName -->
    <xsl:template name="anyName">
        <desc>anyName</desc>
        <rect x="0" y="0" width="40" height="40"
            rx="5"
            fill="#ECEAE7" stroke="black" stroke-width="1" /> 
        <polyline fill="none" stroke="#006000" stroke-width="2"
            points="10,4 20,35 30,4 " /> 
        <line x1="8" y1="15" x2="32" y2="15"
            stroke-width="2" stroke="#006000"/>   
    </xsl:template>
       
</xsl:stylesheet>

OpenPGP digital signature

Read the original blog entry...

IoT & Smart Cities Stories
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use of real time applications accelerate, legacy networks are no longer able to architecturally support cloud adoption and deliver the performance and security required by highly distributed enterprises. These outdated solutions have become more costly and complicated to implement, install, manage, and maintain.SD-WAN offers unlimited capabilities for accessing the benefits of the cloud and Internet. ...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
SYS-CON Events announced today that Silicon India has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Published in Silicon Valley, Silicon India magazine is the premiere platform for CIOs to discuss their innovative enterprise solutions and allows IT vendors to learn about new solutions that can help grow their business.
DXWorldEXPO LLC announced today that "IoT Now" was named media sponsor of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...