Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-05-29 10:50:31 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-05-29 10:50:53 -0400
commit2a9196d9408304567f7501f7d692be3b42cf702f (patch)
treeda3d38866204d1cf772b8a2fa65b5d03c6b43e41 /src
parentfafbf3921eae6c53539f4c5de24e801365ec4af3 (diff)
downloadtame-2a9196d9408304567f7501f7d692be3b42cf702f.tar.gz
tame-2a9196d9408304567f7501f7d692be3b42cf702f.tar.bz2
tame-2a9196d9408304567f7501f7d692be3b42cf702f.zip
Add __path-root param
* src/current/include/dslc-base.xsl (__path-root): New param. * src/current/src/com/lovullo/dslc/DslCompiler.java (DslCompiler)[compile]: Resolve TAME root path. [_transform]: Set it. DEV-3115
Diffstat (limited to 'src')
-rw-r--r--src/current/include/dslc-base.xsl10
-rw-r--r--src/current/src/com/lovullo/dslc/DslCompiler.java11
2 files changed, 20 insertions, 1 deletions
diff --git a/src/current/include/dslc-base.xsl b/src/current/include/dslc-base.xsl
index b7a0447..ab501e7 100644
--- a/src/current/include/dslc-base.xsl
+++ b/src/current/include/dslc-base.xsl
@@ -29,6 +29,16 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<!--
+ Absolute path to root of TAME
+
+ Relative paths between files in XSLT can be flaky because most operations
+ are relative to the root stylesheet (not the filename of the stylesheet
+ that a particular line of code is executing in). Using absolute paths
+ mitigates that definitively.
+-->
+<xsl:param name="__path-root" />
+
<!--
Package source path, stripped of its extension
diff --git a/src/current/src/com/lovullo/dslc/DslCompiler.java b/src/current/src/com/lovullo/dslc/DslCompiler.java
index 4958787..0c33abf 100644
--- a/src/current/src/com/lovullo/dslc/DslCompiler.java
+++ b/src/current/src/com/lovullo/dslc/DslCompiler.java
@@ -1,7 +1,7 @@
/**
* TAME compiler fontend
*
- * Copyright (C) 2016 R-T Specialty, LLC.
+ * Copyright (C) 2016, 2018 R-T Specialty, LLC.
*
* This file is part of the Liza Data Collection Framework
*
@@ -29,6 +29,8 @@
package com.lovullo.dslc;
import java.io.*;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Map;
import java.util.HashMap;
import javax.xml.XMLConstants;
@@ -41,12 +43,15 @@ import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
+
+// TODO: Decouple from rater/ path assumptions
public class DslCompiler
{
private static class _DslCompiler
{
private Validator _xsd;
private HashMap<String,Transformer> _xsl;
+ private Path _pathRoot;
public _DslCompiler()
@@ -86,6 +91,9 @@ public class DslCompiler
System.exit( 4 );
}
+ // root path of TAME
+ _pathRoot = Paths.get( "rater/tame" ).toRealPath();
+
// transform to dest
File destfile = new File( dest );
try
@@ -134,6 +142,7 @@ public class DslCompiler
String relroot = new String( new char[ dircount ] ).replace( "\0", "../" );
Transformer t = _xsl.get( cmd );
+ t.setParameter( "__path-root", _pathRoot.toString() );
t.setParameter( "__srcpkg", srcpkg );
t.setParameter( "__relroot", relroot );
t.setParameter( "__rseed", (int)( Math.random() * 10e6 ) );