Welcome!

Open Source Cloud Authors: Liz McMillan, Yeshim Deniz, Elizabeth White, Pat Romanski, Zakia Bouachraoui

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
Tapping into blockchain revolution early enough translates into a substantial business competitiveness advantage. Codete comprehensively develops custom, blockchain-based business solutions, founded on the most advanced cryptographic innovations, and striking a balance point between complexity of the technologies used in quickly-changing stack building, business impact, and cost-effectiveness. Codete researches and provides business consultancy in the field of single most thrilling innovative te...
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understa...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
CloudEXPO has been the M&A capital for Cloud companies for more than a decade with memorable acquisition news stories which came out of CloudEXPO expo floor. DevOpsSUMMIT New York faculty member Greg Bledsoe shared his views on IBM's Red Hat acquisition live from NASDAQ floor. Acquisition news was announced during CloudEXPO New York which took place November 12-13, 2019 in New York City.
OpsRamp is an enterprise IT operation platform provided by US-based OpsRamp, Inc. It provides SaaS services through support for increasingly complex cloud and hybrid computing environments from system operation to service management. The OpsRamp platform is a SaaS-based, multi-tenant solution that enables enterprise IT organizations and cloud service providers like JBS the flexibility and control they need to manage and monitor today's hybrid, multi-cloud infrastructure, applications, and wor...
The Master of Science in Artificial Intelligence (MSAI) provides a comprehensive framework of theory and practice in the emerging field of AI. The program delivers the foundational knowledge needed to explore both key contextual areas and complex technical applications of AI systems. Curriculum incorporates elements of data science, robotics, and machine learning-enabling you to pursue a holistic and interdisciplinary course of study while preparing for a position in AI research, operations, ...
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
Atmosera delivers modern cloud services that maximize the advantages of cloud-based infrastructures. Offering private, hybrid, and public cloud solutions, Atmosera works closely with customers to engineer, deploy, and operate cloud architectures with advanced services that deliver strategic business outcomes. Atmosera's expertise simplifies the process of cloud transformation and our 20+ years of experience managing complex IT environments provides our customers with the confidence and trust tha...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
Intel is an American multinational corporation and technology company headquartered in Santa Clara, California, in the Silicon Valley. It is the world's second largest and second highest valued semiconductor chip maker based on revenue after being overtaken by Samsung, and is the inventor of the x86 series of microprocessors, the processors found in most personal computers (PCs). Intel supplies processors for computer system manufacturers such as Apple, Lenovo, HP, and Dell. Intel also manufactu...