Zapis na serwer na Gecko/Webkit/Opera.
authorLukasz Rekucki <lrekucki@gmail.com>
Sun, 8 Nov 2009 13:31:12 +0000 (14:31 +0100)
committerLukasz Rekucki <lrekucki@gmail.com>
Sun, 8 Nov 2009 13:31:12 +0000 (14:31 +0100)
apps/explorer/views.py
platforma/static/css/html.css
platforma/static/js/lib/codemirror/codemirror.js [changed mode: 0644->0755]
platforma/static/js/models.js
platforma/static/js/views/html.js
platforma/static/xsl/html2wl_client.xsl
platforma/static/xsl/wl2html_client.xsl
platforma/templates/base.html
platforma/templates/explorer/editor.html
platforma/templates/renderer.html

index 46cdd4e..fd99f27 100755 (executable)
@@ -11,6 +11,8 @@ from django.core.urlresolvers import reverse
 from django.http import HttpResponse
 from django.utils import simplejson as json
 from django.views.generic.simple import direct_to_template
 from django.http import HttpResponse
 from django.utils import simplejson as json
 from django.views.generic.simple import direct_to_template
+from django.shortcuts import render_to_response
+from django.template import RequestContext
 from django.contrib.auth.decorators import login_required
 
 from api.models import PullRequest
 from django.contrib.auth.decorators import login_required
 
 from api.models import PullRequest
@@ -29,11 +31,13 @@ def ajax_login_required(view):
 def display_editor(request, path):
     user = request.GET.get('user', request.user.username)
     log.info(user)
 def display_editor(request, path):
     user = request.GET.get('user', request.user.username)
     log.info(user)
-    
-    return direct_to_template(request, 'explorer/editor.html', extra_context={
+
+    return render_to_response('explorer/editor.html',
+        mimetype="text/html",
+        dictionary = {
             'fileid': path,
             'euser': user
             'fileid': path,
             'euser': user
-    })
+        }, context_instance=RequestContext(request))
     
 #
 # View all files
     
 #
 # View all files
@@ -122,5 +126,5 @@ def pull_requests(request):
 # Testing
 #
 def renderer_test(request):
 # Testing
 #
 def renderer_test(request):
-    return direct_to_template(request, 'renderer.html', mimetype="text/html",
+    return direct_to_template(request, 'renderer.html', mimetype="application/xhtml+xml",
         extra_context = {} )
\ No newline at end of file
         extra_context = {} )
\ No newline at end of file
index 5d4e08c..acbeac2 100755 (executable)
 /* = Footnotes and themes = */
 /* ======================== */
 
 /* = Footnotes and themes = */
 /* ======================== */
 
-.htmlview .theme-begin, .htmlview .theme-end {
+.htmlview .begin, .htmlview .end {
     background: green;
 }
 
     background: green;
 }
 
-.htmlview .theme-ref {
+.htmlview .motyw {
     position: absolute;
     right: -8em;
     
     position: absolute;
     right: -8em;
     
      padding: 3px 5px;
 
      text-decoration: none;
      padding: 3px 5px;
 
      text-decoration: none;
-     z-index: 10;
+     z-index: 11;
  }
  
 
  }
  
 
old mode 100644 (file)
new mode 100755 (executable)
index 97e2657..4eb5fb7
@@ -55,9 +55,9 @@ var CodeMirror = (function(){
 
   function wrapLineNumberDiv(place) {
     return function(node) {
 
   function wrapLineNumberDiv(place) {
     return function(node) {
-      var container = document.createElement("DIV"),
-          nums = document.createElement("DIV"),
-          scroller = document.createElement("DIV");
+      var container = document.createElement("div"),
+          nums = document.createElement("div"),
+          scroller = document.createElement("div");
       container.style.position = "relative";
       nums.style.position = "absolute";
       nums.style.height = "100%";
       container.style.position = "relative";
       nums.style.position = "absolute";
       nums.style.height = "100%";
@@ -98,7 +98,7 @@ var CodeMirror = (function(){
     function update() {
       var diff = 20 + Math.max(doc.body.offsetHeight, frame.offsetHeight) - scroller.offsetHeight;
       for (var n = Math.ceil(diff / 10); n > 0; n--) {
     function update() {
       var diff = 20 + Math.max(doc.body.offsetHeight, frame.offsetHeight) - scroller.offsetHeight;
       for (var n = Math.ceil(diff / 10); n > 0; n--) {
-        var div = document.createElement("DIV");
+        var div = document.createElement("div");
         div.appendChild(document.createTextNode(nextNum++));
         scroller.appendChild(div);
       }
         div.appendChild(document.createTextNode(nextNum++));
         scroller.appendChild(div);
       }
@@ -120,7 +120,7 @@ var CodeMirror = (function(){
     this.options = options = options || {};
     setDefaults(options, CodeMirrorConfig);
 
     this.options = options = options || {};
     setDefaults(options, CodeMirrorConfig);
 
-    var frame = this.frame = document.createElement("IFRAME");
+    var frame = this.frame = document.createElement("iframe");
     if (options.iframeClass) frame.className = options.iframeClass;
     frame.frameBorder = 0;
     frame.src = "javascript:false;";
     if (options.iframeClass) frame.className = options.iframeClass;
     frame.frameBorder = 0;
     frame.src = "javascript:false;";
index d2869ed..d0e7df1 100755 (executable)
@@ -99,16 +99,19 @@ Editor.HTMLModel = Editor.Model.extend({
     },
 
     asWLML: function(element) 
     },
 
     asWLML: function(element) 
-    {        
-        var result = this.wlmlXSL.transformToFragment(element, document);
+    {
+        console.log("Source", element);
+        var doc = this.parser.parseFromString(this.serializer.serializeToString(element), 'text/xml');
+
+        var result = this.wlmlXSL.transformToDocument(doc);
 
         if(!result) {
 
         if(!result) {
-            console.log(this.wlmlXSL.transformToDocument(element));
+            console.log("Failed", this.wlmlXSL, doc);
             throw "Failed to transform fragment";
         }
         
             throw "Failed to transform fragment";
         }
         
-        console.log("Transform result:", result);
-        return this.serializer.serializeToString(result);
+        console.log("Transformed", doc, " to: ", result.documentElement);
+        return this.serializer.serializeToString(result.documentElement);
     },
 
     updateWithWLML: function($element, text)
     },
 
     updateWithWLML: function($element, text)
@@ -131,6 +134,7 @@ Editor.HTMLModel = Editor.Model.extend({
             throw "WLML->HTML transformation failed.";
         
         $element.replaceWith(result);
             throw "WLML->HTML transformation failed.";
         
         $element.replaceWith(result);
+        this.set('state', 'dirty');
     },
 
     createXSLT: function(xslt_doc) {
     },
 
     createXSLT: function(xslt_doc) {
@@ -201,20 +205,23 @@ Editor.HTMLModel = Editor.Model.extend({
 
     save: function(message) {
         if (this.get('state') == 'dirty') {
 
     save: function(message) {
         if (this.get('state') == 'dirty') {
-            this.set('state', 'updating');
-            messageCenter.addMessage('info', 'xmlsave', 'Zapisuję XML...');
+            this.set('state', 'saving');
+            
+            messageCenter.addMessage('info', 'htmlsave', 'Zapisuję HTML...');
+            var wlml = this.asWLML(this.get('data'));
 
             var payload = {
 
             var payload = {
-                contents: this.get('data'),
+                contents: wlml,
                 revision: this.get('revision'),
                 user: this.document.get('user')
             };
                 revision: this.get('revision'),
                 user: this.document.get('user')
             };
+
             if (message) {
                 payload.message = message;
             }
 
             $.ajax({
             if (message) {
                 payload.message = message;
             }
 
             $.ajax({
-                url: this.serverURL,
+                url: this.textURL,
                 type: 'post',
                 dataType: 'json',
                 data: payload,
                 type: 'post',
                 dataType: 'json',
                 data: payload,
@@ -227,19 +234,19 @@ Editor.HTMLModel = Editor.Model.extend({
     },
 
     saveSucceeded: function(data) {
     },
 
     saveSucceeded: function(data) {
-        if (this.get('state') != 'updating') {
+        if (this.get('state') != 'saving') {
             alert('erroneous state:', this.get('state'));
         }
         this.set('revision', data.revision);
         this.set('state', 'updated');
             alert('erroneous state:', this.get('state'));
         }
         this.set('revision', data.revision);
         this.set('state', 'updated');
-        messageCenter.addMessage('success', 'xmlsave', 'Zapisałem XML :-)');
+        messageCenter.addMessage('success', 'htmlsave', 'Zapisałem :-)');
     },
 
     saveFailed: function() {
     },
 
     saveFailed: function() {
-        if (this.get('state') != 'updating') {
+        if (this.get('state') != 'saving') {
             alert('erroneous state:', this.get('state'));
         }
             alert('erroneous state:', this.get('state'));
         }
-        messageCenter.addMessage('error', 'xmlsave', 'Nie udało mi się zapisać XML. Spróbuj ponownie :-(');
+        messageCenter.addMessage('error', 'htmlsave', 'Nie udało mi się zapisać.');
         this.set('state', 'dirty');
     },
 
         this.set('state', 'dirty');
     },
 
index 8aff5f0..0b1234c 100755 (executable)
@@ -106,9 +106,17 @@ var HTMLView = View.extend({
         this.$docbase = $('.htmlview', this.element);
         this.$addThemeButton = $('.htmlview-toolbar .html-add-motive', this.element);
 
         this.$docbase = $('.htmlview', this.element);
         this.$addThemeButton = $('.htmlview-toolbar .html-add-motive', this.element);
 
+        this.$debugButton = $('.htmlview-toolbar .html-serialize', this.element);
+
         this.updatePrintLink();
         this.$docbase.bind('click', this.itemClicked.bind(this));
         this.$addThemeButton.click( this.addTheme.bind(this) );
         this.updatePrintLink();
         this.$docbase.bind('click', this.itemClicked.bind(this));
         this.$addThemeButton.click( this.addTheme.bind(this) );
+        this.$debugButton.click( this.serialized.bind(this) );
+    },
+
+    serialized: function() {
+        this.model.set('state', 'dirty');
+        console.log( this.model.serializer.serializeToString(this.model.get('data')) );        
     },
 
     renderPart: function($e, html) {
     },
 
     renderPart: function($e, html) {
@@ -360,7 +368,7 @@ var HTMLView = View.extend({
         {
             var range = selection.getRangeAt(i);
             console.log(i, range.startContainer, range.endContainer);
         {
             var range = selection.getRangeAt(i);
             console.log(i, range.startContainer, range.endContainer);
-            var date = Date.now();
+            var date = (new Date()).getTime();
             var random = Math.floor(4000000000*Math.random());
             var id = (''+date) + '-' + (''+random);
 
             var random = Math.floor(4000000000*Math.random());
             var id = (''+date) + '-' + (''+random);
 
@@ -372,17 +380,20 @@ var HTMLView = View.extend({
 
             // insert theme-ref
             
 
             // insert theme-ref
             
-            var elem = $('<span x-node="motyw" class="theme-ref">Nowy motyw</span>');
-            elem.attr('x-attrib-id', 'm'+id);
+            var elem = $('<span x-editable="true" x-node="motyw" class="motyw">Nowy motyw</span>');
+            elem.attr('x-attr-qname-'+id, 'id');
+            elem.attr('x-attr-value-'+id, 'm'+id);
             spoint.insertNode(elem[0]);
 
             // insert theme-begin
             spoint.insertNode(elem[0]);
 
             // insert theme-begin
-            elem = $('<span x-node="begin"></span>');
-            elem.attr('x-attrib-id', 'b'+id);
+            elem = $('<span x-node="begin" class="begin"></span>');
+            elem.attr('x-attr-qname-'+id, 'id');
+            elem.attr('x-attr-value-'+id, 'b'+id);
             spoint.insertNode(elem[0]);
             
             spoint.insertNode(elem[0]);
             
-            elem = $('<span x-node="end" class="theme-end"></span>');
-            elem.attr('x-attrib-id', 'e'+id);
+            elem = $('<span x-node="end" class="end"></span>');
+            elem.attr('x-attr-qname-'+id, 'id');
+            elem.attr('x-attr-value-'+id, 'e'+id);
             epoint.insertNode(elem[0]);
         }
 
             epoint.insertNode(elem[0]);
         }
 
index d92a4d3..726a404 100755 (executable)
@@ -1,56 +1,93 @@
 <xsl:stylesheet \r
     version="1.0"\r
 <xsl:stylesheet \r
     version="1.0"\r
+\r
     xmlns:html="http://www.w3.org/1999/xhtml"\r
     xmlns:html="http://www.w3.org/1999/xhtml"\r
-    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\r
+    xmlns:dc="http://purl.org/dc/elements/1.1/"\r
+>\r
 \r
 \r
-    <xsl:output method="xml" encoding="utf-8" omit-xml-declaration = "yes" />\r
+    <xsl:output method="xml" encoding="utf-8" indent="yes"/>\r
     <!--\r
         Ten dokument definiuję przekształcenie odwrotne do wl2html\r
     <!--\r
         Ten dokument definiuję przekształcenie odwrotne do wl2html\r
-    -->   \r
+    -->\r
+\r
+\r
+    <xsl:template match="comment()"><xsl:copy /></xsl:template>\r
+\r
+    <!-- libxslt has fuck-ed prorities -->\r
+    <!-- <xsl:template match="@*[not(starts-with(name(), 'x-')) and name() != 'class']">\r
+        <xsl:message>Boom!: <xsl:value-of select="name()" /></xsl:message>\r
+    </xsl:template> -->\r
+\r
+    <xsl:template match="@*" priority="0" />\r
 \r
     <!-- Specjalne reguły dla przypisów -->\r
 \r
     <!-- Specjalne reguły dla przypisów -->\r
-    <xsl:template match="*[@x-annotation-box]|*[@X-ANNOTATION-BOX]">\r
+    <xsl:template match="*[@x-annotation-box]">\r
         <xsl:apply-templates select="node()" />\r
     </xsl:template>\r
         <xsl:apply-templates select="node()" />\r
     </xsl:template>\r
-   \r
+\r
     <xsl:template match="*[@x-node]">\r
     <xsl:template match="*[@x-node]">\r
-        <xsl:element name="{@x-node}">            \r
-            <xsl:apply-templates select="@*|node()" />\r
+        <xsl:element name="{@x-node}" namespace="{@x-ns}">\r
+            <xsl:apply-templates select="@*" />\r
+            <xsl:apply-templates select="node()" />\r
         </xsl:element>\r
         </xsl:element>\r
-    </xsl:template>\r
+    </xsl:template>   \r
 \r
 \r
-    <xsl:template match="*[@X-NODE]">\r
-        <xsl:element name="{@X-NODE}">\r
-            <xsl:apply-templates select="@*|node()" />\r
-        </xsl:element>\r
-    </xsl:template>\r
+    <xsl:template match="*[@x-node = 'out-of-flow-text']"><xsl:value-of select="@x-content" /></xsl:template>\r
 \r
     <!-- Specjalne reguły dla wersów -->\r
 \r
     <!-- Specjalne reguły dla wersów -->\r
-    <xsl:template match="*[@x-node = 'wers' or @X-NODE = 'wers']">\r
+    <xsl:template match="*[@x-node = 'wers']">\r
         <xsl:apply-templates select="node()" />\r
         <xsl:apply-templates select="node()" />\r
-        <xsl:if test="position() != last()"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
+        <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
     </xsl:template>\r
 \r
     <xsl:template match="*[starts-with(@x-node, 'wers_')]">\r
     </xsl:template>\r
 \r
     <xsl:template match="*[starts-with(@x-node, 'wers_')]">\r
-        <xsl:element name="{@x-node}">            \r
-            <xsl:apply-templates select="@*|node()" />\r
-        </xsl:element>\r
-        <xsl:if test="position() != last()"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
+        <xsl:element name="{@x-node}" namespace="{@x-ns}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
+        <xsl:if test="count(following-sibling::*[starts-with(@x-node, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
+    </xsl:template>\r
+    \r
+    <xsl:template match="@*[starts-with(name(), 'x-attr-qname-')]">\r
+        <xsl:variable name="attr-id" select="substring-after(name(), 'x-attr-qname-')" />\r
+        <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('x-attr-ns-', $attr-id)]}">\r
+            <xsl:value-of select="parent::*/@*[name() = concat('x-attr-value-', $attr-id)]" />\r
+        </xsl:attribute>\r
     </xsl:template>\r
 \r
     </xsl:template>\r
 \r
-    <xsl:template match="*[starts-with(@X-NODE, 'wers_')]">\r
-        <xsl:element name="{@X-NODE}">\r
-            <xsl:apply-templates select="@*|node()" />\r
+    <!-- upper case duplicates for the brain-dead Firefox -->\r
+\r
+    <xsl:template match="@*[starts-with(name(), 'X-ATTR-QNAME-')]">\r
+        <xsl:variable name="attr-id" select="substring-after(name(), 'X-ATTR-QNAME-')" />\r
+        <xsl:attribute name="{.}" namespace="{parent::*/@*[name() = concat('X-ATTR-NS-', $attr-id)]}">\r
+            <xsl:value-of select="parent::*/@*[name() = concat('X-ATTR-VALUE-', $attr-id)]" />\r
+        </xsl:attribute>\r
+    </xsl:template>\r
+\r
+    <xsl:template match="*[@X-ANNOTATION-BOX]">\r
+        <xsl:apply-templates select="node()" />\r
+    </xsl:template>\r
+\r
+    <xsl:template match="*[@X-NODE]">\r
+        <xsl:element name="{@X-NODE}" namespace="{@X-NS}">\r
+            <xsl:apply-templates select="@*" />\r
+            <xsl:apply-templates select="node()" />\r
         </xsl:element>\r
         </xsl:element>\r
-        <xsl:if test="position() != last()"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
     </xsl:template>\r
 \r
     </xsl:template>\r
 \r
-    <!-- Użycie zmiennych jako argumenty dla translate, psuję Chrome/Safari :( -->\r
-    <xsl:template match="@*[starts-with(translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'x-attrib-')]">\r
-        <xsl:attribute name="{substring-after(translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'x-attrib-')}"><xsl:value-of select="." /></xsl:attribute>\r
+    <xsl:template match="*[@X-NODE = 'out-of-flow-text']"><xsl:value-of select="@X-CONTENT" /></xsl:template>\r
+\r
+    <!-- Specjalne reguły dla wersów -->\r
+    <xsl:template match="*[@X-NODE = 'wers']">\r
+        <xsl:apply-templates select="node()" />\r
+        <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
     </xsl:template>\r
 \r
     </xsl:template>\r
 \r
-    <xsl:template match="@*" /><!--[A:<xsl:value-of select="name()" />]</xsl:template> -->\r
+    <xsl:template match="*[starts-with(@X-NODE, 'wers_')]">\r
+        <xsl:element name="{@X-NODE}" namespace="{@X-NS}"><xsl:apply-templates select="@*|node()" /></xsl:element>\r
+        <xsl:if test="count(following-sibling::*[starts-with(@X-NODE, 'wers')]) > 0"><xsl:text>/&#x000a;</xsl:text></xsl:if>\r
+    </xsl:template>\r
+\r
+    \r
     \r
     <xsl:template match="*" />\r
 </xsl:stylesheet>
\ No newline at end of file
     \r
     <xsl:template match="*" />\r
 </xsl:stylesheet>
\ No newline at end of file
index 7a7da8c..234ea5c 100755 (executable)
@@ -5,7 +5,7 @@
     <!--
         Dokument ten opisuje jednoznaczne przekształcenie WLML 0.1 -> XHTML.
     -->        
     <!--
         Dokument ten opisuje jednoznaczne przekształcenie WLML 0.1 -> XHTML.
     -->        
-    <xsl:output method="html" encoding="utf-8" indent="yes" />
+    <xsl:output method="xml" encoding="utf-8" indent="no" />
 
     <xsl:template match="/">
         <xsl:apply-templates select="chunk|utwor" />
 
     <xsl:template match="/">
         <xsl:apply-templates select="chunk|utwor" />
     -->
 
     <xsl:template match="utwor">
     -->
 
     <xsl:template match="utwor">
-        <xsl:apply-templates select="child::*[name() = local-name()]">
-            <xsl:with-param name="mixed" select="false()" />
-        </xsl:apply-templates>
+        <div>
+            <xsl:call-template name="standard-attributes" />
+            <xsl:apply-templates select="child::*">
+                <xsl:with-param name="mixed" select="false()" />
+            </xsl:apply-templates>
+        </div>
     </xsl:template>    
     
     <!-- 
     </xsl:template>    
     
     <!-- 
@@ -42,7 +45,8 @@
 
     <xsl:template match="opowiadanie|powiesc">
         <xsl:param name="mixed" />
 
     <xsl:template match="opowiadanie|powiesc">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
@@ -51,7 +55,8 @@
 
     <xsl:template match="liryka_l|liryka_lp">
         <xsl:param name="mixed" />
 
     <xsl:template match="liryka_l|liryka_lp">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
@@ -60,7 +65,8 @@
 
     <xsl:template match="dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
         <xsl:param name="mixed" />
 
     <xsl:template match="dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
@@ -69,7 +75,8 @@
 
     <xsl:template match="wywiad">
         <xsl:param name="mixed" />
 
     <xsl:template match="wywiad">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
@@ -92,7 +99,8 @@
     -->
     <xsl:template match="autor_utworu">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="autor_utworu">
         <xsl:param name="mixed" />
-        <h2 class="{name()}" x-editable="true" x-node="{name()}">
+        <h2 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="nazwa_utworu">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="nazwa_utworu">
         <xsl:param name="mixed" />
-        <h1 class="{name()}" x-editable="true" x-node="{name()}">
+        <h1 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="dzielo_nadrzedne">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="dzielo_nadrzedne">
         <xsl:param name="mixed" />
-        <h2 class="{name()}" x-editable="true" x-node="{name()}">
+        <h2 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="podtytul">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="podtytul">
         <xsl:param name="mixed" />
-        <h3 class="{name()}" x-editable="true" x-node="{name()}">
+        <h3 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="nota">
         <xsl:param name="mixed" />
 
     <xsl:template match="nota">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
     -->
     <xsl:template match="dedykacja">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="dedykacja">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
     -->
     <xsl:template match="motto">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="motto">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
             <xsl:apply-templates select="child::node()">
-                <xsl:with-param name="mixed" select="false()" />
+                <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
         </div>
     </xsl:template>
 
     <xsl:template match="motto_podpis">
         <xsl:param name="mixed" />
             </xsl:apply-templates>
         </div>
     </xsl:template>
 
     <xsl:template match="motto_podpis">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="lista_osob">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="lista_osob">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
 
     <xsl:template match="naglowek_listy">
         <xsl:param name="mixed" />
 
     <xsl:template match="naglowek_listy">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="lista_osoba">
         <xsl:param name="mixed" />
 
     <xsl:template match="lista_osoba">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
+            <xsl:call-template name="context-menu" />
+            <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="true()" />
+            </xsl:apply-templates>
+        </p>
+    </xsl:template>
+
+    <!--  Tagi obejmujące inne komentarze wprowadzające
+        przed tekstem dramatu (składane razem z listą osób):
+
+        <miejsce_czas> komentarze-wprowadzające </miejsce_czas>
+    -->
+    <xsl:template match="miejsce_czas">
+        <xsl:param name="mixed" />
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="naglowek_czesc">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="naglowek_czesc">
         <xsl:param name="mixed" />
-        <h2 class="{name()}" x-editable="true" x-node="{name()}">
+        <h2 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="naglowek_rozdzial">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="naglowek_rozdzial">
         <xsl:param name="mixed" />
-        <h3 class="{name()}" x-editable="true" x-node="{name()}">
+        <h3 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     -->
     <xsl:template match="naglowek_podrozdzial">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="naglowek_podrozdzial">
         <xsl:param name="mixed" />
-        <h4 class="{name()}" x-editable="true" x-node="{name()}">
+        <h4 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="srodtytul">
         <xsl:param name="mixed" />
 
     <xsl:template match="srodtytul">
         <xsl:param name="mixed" />
-        <h2 class="{name()}" x-editable="true" x-node="{name()}">
+        <h2 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="naglowek_akt">
         <xsl:param name="mixed" />
 
     <xsl:template match="naglowek_akt">
         <xsl:param name="mixed" />
-        <h2 class="{name()}" x-editable="true" x-node="{name()}">
+        <h2 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="naglowek_scena">
         <xsl:param name="mixed" />
 
     <xsl:template match="naglowek_scena">
         <xsl:param name="mixed" />
-        <h3 class="{name()}" x-editable="true" x-node="{name()}">
+        <h3 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     
     <xsl:template match="naglowek_osoba">
         <xsl:param name="mixed" />
     
     <xsl:template match="naglowek_osoba">
         <xsl:param name="mixed" />
-        <h4 class="{name()}" x-editable="true" x-node="{name()}">
+        <h4 x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
     
     <xsl:template match="dlugi_cytat">
         <xsl:param name="mixed" />
     
     <xsl:template match="dlugi_cytat">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
     
     <xsl:template match="poezja_cyt">
         <xsl:param name="mixed" />
     
     <xsl:template match="poezja_cyt">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
 
     <xsl:template match="kwestia">
         <xsl:param name="mixed" />
 
     <xsl:template match="kwestia">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
 
     <xsl:template match="didaskalia">
         <xsl:param name="mixed" />
 
     <xsl:template match="didaskalia">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
             <xsl:apply-templates select="child::node()">
-                <xsl:with-param name="mixed" select="false()" />
+                <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
         </div>
     </xsl:template>
 
     <xsl:template match="wywiad_pyt">
         <xsl:param name="mixed" />
             </xsl:apply-templates>
         </div>
     </xsl:template>
 
     <xsl:template match="wywiad_pyt">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
 
     <xsl:template match="wywiad_odp">
         <xsl:param name="mixed" />
 
     <xsl:template match="wywiad_odp">
         <xsl:param name="mixed" />
-        <div class="{name()}" x-node="{name()}">
+        <div>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="false()" />
             </xsl:apply-templates>
 
     <xsl:template match="akap">
         <xsl:param name="mixed" />
 
     <xsl:template match="akap">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="akap_cd">
         <xsl:param name="mixed" />
 
     <xsl:template match="akap_cd">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
 
     <xsl:template match="akap_dialog">
         <xsl:param name="mixed" />
 
     <xsl:template match="akap_dialog">
         <xsl:param name="mixed" />
-        <p class="{name()}" x-editable="true" x-node="{name()}">
+        <p x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             <xsl:call-template name="context-menu" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
         ********
     -->
     <xsl:template match="strofa">
         ********
     -->
     <xsl:template match="strofa">
-        <div class="{name()}" x-editable="true" x-node="{name()}">
+        <div x-editable="true">
+            <xsl:call-template name="standard-attributes" />
             <xsl:call-template name="context-menu" />
             <xsl:call-template name="context-menu" />
+         
             <xsl:choose>
                 <xsl:when test="count(br) > 0">
                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
             <xsl:choose>
                 <xsl:when test="count(br) > 0">
                     <xsl:variable name="first-verse" select="br[1]/preceding-sibling::node()" />                    
     <xsl:template name="verse">
         <!-- the verse contents including the last br (if any) -->
         <xsl:param name="verse-content" />
     <xsl:template name="verse">
         <!-- the verse contents including the last br (if any) -->
         <xsl:param name="verse-content" />
-        
         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
         <!-- name of text nodes is '' == false -->
 
         <xsl:variable name="first-tag-name" select="name($verse-content/self::*)" />
         <!-- name of text nodes is '' == false -->
 
+        <!-- THIS IS A HORROR!!! -->
+        <!-- Possible variants: -->
         <xsl:choose>
         <xsl:choose>
-            <xsl:when test="starts-with($first-tag-name, 'wers')">
-                <p class="{$first-tag-name}" x-node="{$first-tag-name}">
-                <xsl:for-each select="$verse-content[name(.) != 'br']">
-                <xsl:apply-templates select=".">
+            <!-- Simple verse == not wers_ tags anywhere until the ending br -->
+            <xsl:when test="not($verse-content[starts-with(name(), 'wers_')])">
+                <p class="wers" x-node="wers">
+                <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
                     <xsl:with-param name="mixed" select="true()" />
                 </xsl:apply-templates>
                     <xsl:with-param name="mixed" select="true()" />
                 </xsl:apply-templates>
-                </xsl:for-each>
                 </p>
             </xsl:when>
 
             <xsl:otherwise>
                 </p>
             </xsl:when>
 
             <xsl:otherwise>
-                <p class="wers" x-node="wers">
-                <xsl:for-each select="$verse-content[name(.) != 'br']">
-                    <xsl:apply-templates select=".">
-                    <xsl:with-param name="mixed" select="true()" />
-                    </xsl:apply-templates>
-                </xsl:for-each>
-                </p>                
-            </xsl:otherwise>          
-            
-        </xsl:choose>       
+            <xsl:apply-templates select="$verse-content[local-name(.) != 'br']">
+                <xsl:with-param name="mixed" select="false()" />
+            </xsl:apply-templates>
+            </xsl:otherwise>
+        </xsl:choose>
     </xsl:template>
 
     <xsl:template match="wers_cd|wers_akap|wers_wciety">
         <xsl:param name="mixed" />
     </xsl:template>
 
     <xsl:template match="wers_cd|wers_akap|wers_wciety">
         <xsl:param name="mixed" />
-        <xsl:call-template name="copy-attributes" />
-        <xsl:apply-templates select="child::node()">
+        <p>
+            <xsl:call-template name="standard-attributes" />
+            <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
+        </p>
     </xsl:template>
     </xsl:template>
-    
+
+    <xsl:template match="br"><xsl:text>/</xsl:text></xsl:template>
+
 
     <!--
         *************
 
     <!--
         *************
     -->
     <xsl:template match="tytul_dziela">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="tytul_dziela">
         <xsl:param name="mixed" />
-        <em class="{name()}" x-node="{name()}">
+        <em>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
 
     <xsl:template match="wyroznienie|slowo_obce|mat|didask_tekst|osoba|wyp_osoba|www">
         <xsl:param name="mixed" />
 
     <xsl:template match="wyroznienie|slowo_obce|mat|didask_tekst|osoba|wyp_osoba|www">
         <xsl:param name="mixed" />
-        <em class="{name()}" x-node="{name()}">
+        <em>
+            <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
     -->
     <xsl:template match="sekcja_swiatlo">
         <xsl:param name="mixed" />
     -->
     <xsl:template match="sekcja_swiatlo">
         <xsl:param name="mixed" />
-        <br class="{name()}" x-node="{name()}" />
+        <br><xsl:call-template name="standard-attributes" /></br>
     </xsl:template>
 
     <xsl:template match="sekcja_asterysk">
         <xsl:param name="mixed" />
     </xsl:template>
 
     <xsl:template match="sekcja_asterysk">
         <xsl:param name="mixed" />
-        <hr class="{name()}" x-node="{name()}" />
+        <hr><xsl:call-template name="standard-attributes" /></hr>
     </xsl:template>
 
     <xsl:template match="separator_linia">
         <xsl:param name="mixed" />
     </xsl:template>
 
     <xsl:template match="separator_linia">
         <xsl:param name="mixed" />
-        <hr class="{name()}" x-node="{name()}" />
+        <hr><xsl:call-template name="standard-attributes" /></hr>
     </xsl:template>
 
     <xsl:template match="zastepnik_wersu">
         <xsl:param name="mixed" />
     </xsl:template>
 
     <xsl:template match="zastepnik_wersu">
         <xsl:param name="mixed" />
-        <hr class="{name()}" x-node="{name()}" />
+        <hr><xsl:call-template name="standard-attributes" /></hr>
     </xsl:template>
 
     <!--
     </xsl:template>
 
     <!--
         Przypisy i motywy
     -->
     <xsl:template match="pr|pa|pe|pt">       
         Przypisy i motywy
     -->
     <xsl:template match="pr|pa|pe|pt">       
-        <span class="annotation-inline-box" x-node="{name()}" x-editable="true">
+        <span x-editable="true">
+            <xsl:call-template name="standard-attributes">
+                <xsl:with-param name="extra-class" select="'annotation-inline-box'" />
+            </xsl:call-template>
             <a name="anchor-{generate-id(.)}" />
             <!-- the link to the non-inline version -->
             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
             <a name="anchor-{generate-id(.)}" />
             <!-- the link to the non-inline version -->
             <a href="#annotation-{generate-id(.)}" class="annotation"></a>
     </xsl:template>
 
     <xsl:template match="begin">        
     </xsl:template>
 
     <xsl:template match="begin">        
-        <span class="theme-begin" x-node="begin">
-            <xsl:call-template name="copy-attributes" />
+        <span>
+            <xsl:call-template name="standard-attributes" />
+        </span>
+    </xsl:template>
+
+    <xsl:template match="extra|uwaga">
+        <span>
+            <xsl:call-template name="standard-attributes" />
+            <xsl:apply-templates select="node()" />
         </span>
     </xsl:template>
 
     <xsl:template match="motyw">
         </span>
     </xsl:template>
 
     <xsl:template match="motyw">
-        <span class="theme-ref" x-node="motyw">
-            <xsl:call-template name="copy-attributes" />
+        <span x-editable="true">
+            <xsl:call-template name="standard-attributes" />
+            <xsl:call-template name="context-menu" />
             <xsl:value-of select="." />
         </span>
     </xsl:template>
 
     <xsl:template match="end">
             <xsl:value-of select="." />
         </span>
     </xsl:template>
 
     <xsl:template match="end">
-        <span class="theme-end" x-node="end">
-            <xsl:call-template name="copy-attributes" />
+        <span>
+            <xsl:call-template name="standard-attributes" />           
         </span>
     </xsl:template>
 
         </span>
     </xsl:template>
 
         <xsl:param name="mixed" />
         <xsl:choose>
             <xsl:when test="normalize-space(.) = ''" />
         <xsl:param name="mixed" />
         <xsl:choose>
             <xsl:when test="normalize-space(.) = ''" />
-            <xsl:when test="not($mixed)">
-                <span x-node="text" class="out-of-flow-text"
-                    x-content="{normalize-space(.)}"></span>
-            </xsl:when>
-            <xsl:otherwise>
-                <xsl:value-of select="." />
-            </xsl:otherwise>
+            <xsl:when test="not($mixed)"><span x-node="out-of-flow-text" class="out-of-flow-text"
+                    x-content="{.}"></span></xsl:when>
+            <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise>
         </xsl:choose>
     </xsl:template>
 
         </xsl:choose>
     </xsl:template>
 
+    <xsl:template match="comment()">
+        <xsl:comment><xsl:value-of select="." /></xsl:comment>
+    </xsl:template>
+
+    <xsl:template match="*[name() != local-name()]">
+        <div>
+            <xsl:call-template name="standard-attributes" />
+            <xsl:apply-templates select="child::node()">
+                <xsl:with-param name="mixed" select="true()" />
+            </xsl:apply-templates>
+        </div>
+    </xsl:template>
+
     <xsl:template match="*">
     <xsl:template match="*">
-        <div x-node="error" x-content="{name()}" />
+        <xsl:message terminate="no">
+        Unmatched tag <xsl:value-of select="name()" />
+        </xsl:message>
     </xsl:template>
 
     <xsl:template name="context-menu">
     </xsl:template>
 
     <xsl:template name="context-menu">
         </span>
     </xsl:template>
 
         </span>
     </xsl:template>
 
-    <xsl:template name="copy-attributes">
+    <xsl:template name="standard-attributes">
+        <xsl:param name="extra-class" />
+        <xsl:attribute name="class"><xsl:value-of select="local-name()" /><xsl:text>&#x0020;</xsl:text><xsl:value-of select="$extra-class" /></xsl:attribute>
+
+        <!-- we use upper-case attribute names, so we don't have to wory about HTML parsers -->
+        <xsl:attribute name="x-node"><xsl:value-of select="name()" /></xsl:attribute>
+
+        <xsl:if test="local-name() != name()">
+            <xsl:attribute name="x-ns"><xsl:value-of select="namespace-uri()" /></xsl:attribute>
+        </xsl:if>
+
         <xsl:for-each select="@*">
         <xsl:for-each select="@*">
-            <xsl:attribute name="x-attrib-{name(.)}"><xsl:value-of select="."/></xsl:attribute>
+            <xsl:variable name="id" select="generate-id()" />
+            <xsl:attribute name="x-attr-value-{$id}"><xsl:value-of select="."/></xsl:attribute>
+            <xsl:attribute name="x-attr-qname-{$id}"><xsl:value-of select="name()"/></xsl:attribute>
+            <xsl:if test="namespace-uri()">
+                <xsl:attribute name="x-attr-ns-{$id}"><xsl:value-of select="namespace-uri()"/></xsl:attribute>
+            </xsl:if>               
         </xsl:for-each>
     </xsl:template>
     
         </xsl:for-each>
     </xsl:template>
     
index 50c7bfe..597a432 100755 (executable)
@@ -1,6 +1,6 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://platforma.wolnelektury.pl/">
+<html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
         <title>{% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%}</title>
     <head>
         <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
         <title>{% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%}</title>
@@ -24,5 +24,6 @@
         <div id="content">{% block maincontent %} {% endblock %}</div>
         </div>
     {% block extrabody %}{% endblock %}
         <div id="content">{% block maincontent %} {% endblock %}</div>
         </div>
     {% block extrabody %}{% endblock %}
+    http://192.168.56.2:8000/editor/mickiewicz__pan_tadeusz__ksi%C4%99ga_1/
     </body>
 </html>
     </body>
 </html>
index 247f59c..f6a7630 100755 (executable)
@@ -65,6 +65,7 @@
                 <div class="htmlview-toolbar">
                     <a class="html-print-link" href="print" ui:baseref="{% url file_print fileid %}" target="_new">{% trans "Print version"  %}</a>
                     <button class="html-add-motive" type="button">Dodaj motyw</button>
                 <div class="htmlview-toolbar">
                     <a class="html-print-link" href="print" ui:baseref="{% url file_print fileid %}" target="_new">{% trans "Print version"  %}</a>
                     <button class="html-add-motive" type="button">Dodaj motyw</button>
+                    <button class="html-serialize" type="button">Serializuj</button>
                 </div>
                 
                <div class="htmlview">
                 </div>
                 
                <div class="htmlview">
index dabf338..84de36d 100755 (executable)
@@ -1,29 +1,46 @@
 {% extends "base.html" %}\r
 \r
 {% block extrahead %}\r
 {% extends "base.html" %}\r
 \r
 {% block extrahead %}\r
-<link rel="stylesheet" href="{{STATIC_URL}}css/html.css" type="text/css" charset="utf-8">\r
+<link rel="stylesheet" href="{{STATIC_URL}}css/html.css" type="text/css" charset="utf-8" />\r
+<script src="{{STATIC_URL}}js/lib/codemirror/codemirror.js" type="text/javascript" charset="utf-8"></script>\r
 {% endblock %}\r
 \r
 {% block maincontent %}\r
 \r
 {% endblock %}\r
 \r
 {% block maincontent %}\r
 \r
-<p>Source</p>\r
-<textarea id="source" cols="80" rows="10" ></textarea>\r
-\r
-<p>Rendered</p>\r
-<textarea id="dest" cols="80" rows="10" ></textarea>\r
-\r
-<button type="button" id="render">Render</button>\r
-<button type="button" id="unrender">Unrender</button>\r
-\r
-<div style="position: fixed; right: 0px; top: 0px; width: 640px; height: 300px; background: blue;">\r
-<div id="preview" class="htmlview">\r
-</div>\r
-</div>\r
+<!-- <button type="button" id="render">Render</button>\r
+\r
+<table width="100%" align="center">\r
+    <tr>\r
+        <td width="50%">\r
+                <textarea id="source" cols="70" rows="30" ></textarea>\r
+        </td>\r
+        <td width="50%">\r
+                <textarea id="dest" cols="70" rows="30" ></textarea>\r
+        </td>\r
+    </tr>\r
+</table>\r
+<iframe>\r
+    \r
+</iframe> -->\r
+<div id="target"> </div>\r
 {% endblock %}\r
 \r
 {% block extrabody %}\r
 {% endblock %}\r
 \r
 {% block extrabody %}\r
+\r
 <script type="text/javascript">\r
 <script type="text/javascript">\r
+<![CDATA[\r
+    var editor = new CodeMirror(CodeMirror.replace("target"), {\r
+  parserfile: ["tokenizejavascript.js", "parsejavascript.js"],\r
+  path: "{{STATIC_URL}}js/lib/codemirror",\r
+  stylesheet: "{{STATIC_URL}}css/xmlcolors.css",\r
+  content: "Hello world!"\r
+});\r
+]]>\r
+</script>\r
 \r
 \r
+{% comment %}\r
+<script type="text/javascript">\r
+<![CDATA[\r
     function serializeAttribute(attr, acc) {\r
         return acc + ' ' + attr.nodeName + '="'+ attr.nodeValue + '"';\r
     }\r
     function serializeAttribute(attr, acc) {\r
         return acc + ' ' + attr.nodeName + '="'+ attr.nodeValue + '"';\r
     }\r
@@ -41,6 +58,7 @@
         }\r
         \r
         acc += "<" + element.nodeName;\r
         }\r
         \r
         acc += "<" + element.nodeName;\r
+        \r
         for(var i=0; i < element.attributes.length; i++)\r
             acc = serializeAttribute(element.attributes.item(i), acc);\r
 \r
         for(var i=0; i < element.attributes.length; i++)\r
             acc = serializeAttribute(element.attributes.item(i), acc);\r
 \r
     }\r
 \r
     // w3c version first\r
     }\r
 \r
     // w3c version first\r
-    var xslt = new XSLTProcessor();\r
+    var there = new XSLTProcessor();\r
+    var here = new XSLTProcessor();\r
 \r
     $.ajax({\r
         url: "/static/xsl/wl2html_client.xsl",\r
         dataType: 'xml',\r
         success: function(data) {\r
 \r
     $.ajax({\r
         url: "/static/xsl/wl2html_client.xsl",\r
         dataType: 'xml',\r
         success: function(data) {\r
-            xslt.importStylesheet(data);\r
-            console.log('XSL loaded successfully');\r
+            there.importStylesheet(data);\r
+            console.log('There XSL loaded successfully');\r
+        },\r
+        async: false\r
+    });\r
+\r
+    $.ajax({\r
+        url: "/static/xsl/html2wl_client.xsl",\r
+        dataType: 'xml',\r
+        success: function(data) {\r
+            here.importStylesheet(data);\r
+            console.log('Here XSL loaded successfully');\r
         },\r
         async: false\r
     });\r
     \r
         },\r
         async: false\r
     });\r
     \r
-    $('#render').click(function() {\r
-        \r
-        var src = '<?xml version="1.0"?><chunk>'+$('#source').val()+'</chunk>';\r
+    $('#render').click(function()\r
+    {\r
+        src = $('#source').val();\r
         src = src.replace(/\/\s+/g, '<br />');\r
         var doc = (new DOMParser()).parseFromString(src, "text/xml");\r
         src = src.replace(/\/\s+/g, '<br />');\r
         var doc = (new DOMParser()).parseFromString(src, "text/xml");\r
-        // var string = (new XMLSerializer()).serializeToString(doc);\r
-        // console.log('rendering', string);\r
-        \r
-        var result = xslt.transformToFragment(doc, document);\r
-        var string =  serializeXML(result);\r
-        var dest = $('#dest');\r
-        dest.val( string );\r
-        $('#preview').html(string);\r
-    });    \r
+        // console.log("Parsed", doc);\r
+        var along = there.transformToDocument(doc).documentElement;\r
+        // console.log("HTML", along, serializeXML(along) );\r
+        var xfrm = here.transformToDocument(along).documentElement;\r
+        // console.log("WLML", xfrm, serializeXML(xfrm) );\r
+        var out = (new XMLSerializer()).serializeToString(xfrm);\r
+        $('#dest').val(out);\r
+    });\r
+]]>\r
 </script>\r
 </script>\r
+{% endcomment %}\r
 {% endblock %}
\ No newline at end of file
 {% endblock %}
\ No newline at end of file