--- a/plcopen/Makefile Tue Sep 24 11:55:59 2019 +0200
+++ b/plcopen/Makefile Fri Aug 09 12:07:33 2019 +0200
@@ -1,13 +1,23 @@
+# Makefile to generate XSLT stylesheets from ysl2 files in the same directory +# hg clone https://pep.foundation/dev/repos/yml2/ +# It should be just fine if yml2 is cloned just asside beremiz +# otherwise, point yml2path to yml2 source directory +# make yml2path=path/to/yml/dir +yml2path ?= $(abspath ../../yml2) ysl2files := $(wildcard *.ysl2)
xsltfiles := $(patsubst %.ysl2, %.xslt, $(ysl2files))
-%.xslt: %.ysl2 yslt_noindent.yml2
- $(yml)/yml2c -I $(yml) $< -o $@.tmp
+%.xslt: %.ysl2 ../yslt_noindent.yml2 + $(yml2path)/yml2c -I $(yml2path):../ $< -o $@.tmp xmlstarlet fo $@.tmp > $@
--- a/plcopen/XSLTModelQuery.py Tue Sep 24 11:55:59 2019 +0200
+++ b/plcopen/XSLTModelQuery.py Fri Aug 09 12:07:33 2019 +0200
@@ -8,13 +8,14 @@
import util.paths as paths
from plcopen.structures import StdBlckLibs
+from XSLTransform import XSLTransform ScriptDirectory = paths.AbsDir(__file__)
-class XSLTModelQuery(object):
+class XSLTModelQuery(XSLTransform): """ a class to handle XSLT queries on project and libs """
def __init__(self, controller, xsltpath, ext=None):
# arbitrary set debug to false, updated later
@@ -31,19 +32,12 @@
- # parse and compile. "beremiz" arbitrary namespace for extensions
- self.xslt = etree.XSLT(
- os.path.join(ScriptDirectory, xsltpath),
- extensions={("beremiz", name): call for name, call in xsltext})
+ XSLTransform.__init__(self, + os.path.join(ScriptDirectory, xsltpath), def _process_xslt(self, root, debug, **kwargs):
- res = self.xslt(root, **{k: etree.XSLT.strparam(v) for k, v in kwargs.iteritems()})
- # print(self.xslt.error_log)
+ return self.transform(root, **kwargs) # -------------------------------------------------------------------------------
# Helpers functions for translating list of arguments
--- a/plcopen/yslt_noindent.yml2 Tue Sep 24 11:55:59 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform",
- xmlns:exsl='http://exslt.org/common',
- extension-element-prefixes='exsl'
- decl function(name) alias template {
- decl call(name) alias call-template {
- decl apply(select) alias apply-templates {