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
master
Mike Gerwitz 2018-05-29 10:50:31 -04:00
parent fafbf3921e
commit 2a9196d940
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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 ) );