diff --git a/src/main/java/org/metanorma/stepmod2mn.java b/src/main/java/org/metanorma/stepmod2mn.java index 4f71191..285ac6a 100644 --- a/src/main/java/org/metanorma/stepmod2mn.java +++ b/src/main/java/org/metanorma/stepmod2mn.java @@ -35,7 +35,7 @@ */ public class stepmod2mn { - static final String CMD = "java -Xss5m -jar stepmod2mn.jar [options -o, -v, -b -t -e ]"; + static final String CMD = "java -Xss5m -jar stepmod2mn.jar [options -o, -v, -b -t -e -inc ]"; static final String CMD_SVGscope = "java -jar stepmod2mn.jar --svg"; static final String CMD_SVG = "java -jar stepmod2mn.jar --xml --image [--svg ] [-v]"; @@ -139,6 +139,12 @@ public class stepmod2mn { .hasArg() .required(false) .build()); + addOption(Option.builder("inc") + .longOpt("include-only") + .desc("process specified documents only (list in the quotes, spaces separated)") + .hasArg() + .required(false) + .build()); addOption(Option.builder("v") .longOpt("version") .desc("display application version") @@ -162,6 +168,7 @@ public class stepmod2mn { String outputPathSchemas = ""; List excludeList = new ArrayList<>(); + List includeOnlyList = new ArrayList<>(); /** * Main method. * @@ -286,6 +293,11 @@ public static void main(String[] args) throws ParseException { excludeList = Arrays.asList(cmd.getOptionValue("exclude").split(" ")); } + List includeOnlyList = new ArrayList<>(); + if (cmd.hasOption("include-only")) { + includeOnlyList = Arrays.asList(cmd.getOptionValue("include-only").split(" ")); + } + String inputFolder = ""; List> inputOutputFiles = new ArrayList<>(); @@ -416,9 +428,6 @@ public static void main(String[] args) throws ParseException { File fileIn = new File(filenameIn); File fileOut = new File(filenameOut); stepmod2mn app = new stepmod2mn(); - System.out.println(String.format(INPUT_LOG, XML_INPUT, filenameIn)); - System.out.println(String.format(OUTPUT_LOG, Constants.FORMAT.toUpperCase(), filenameOut)); - System.out.println(); app.setBoilerplatePath(boilerplatePath); if (Util.isUrl(filenameIn)) { resourcePath = Util.getParentUrl(filenameIn); @@ -430,6 +439,7 @@ public static void main(String[] args) throws ParseException { app.setRepositoryIndexPath(repositoryIndexPath); app.setOutputPathSchemas(outputPathSchemas); app.setExcludeList(excludeList); + app.setIncludeOnlyList(includeOnlyList); boolean res = app.convertstepmod2mn(filenameIn, fileOut); if (!res) { badInputOutputFiles.add(entry); @@ -488,8 +498,11 @@ public static void main(String[] args) throws ParseException { //private void convertstepmod2mn(File fXMLin, File fileOut) throws IOException, TransformerException, SAXParseException { private boolean convertstepmod2mn(String xmlFilePath, File fileOut) throws IOException, TransformerException, SAXParseException { try { + + System.out.println(String.format(INPUT_LOG, XML_INPUT, xmlFilePath)); + Source srcXSL = null; - + String bibdataFileName = fileOut.getName(); // get linearized XML with default attributes substitution from DTD @@ -505,10 +518,18 @@ private boolean convertstepmod2mn(String xmlFilePath, File fileOut) throws IOExc String documentName = XMLUtils.getTextByXPath(linearizedXML, "*/@name"); if (excludeList.contains(documentName)) { - System.out.println(" '" + documentName + "' excluded from the processing."); + System.out.println("The document '" + documentName + "' excluded from the processing."); + return false; + } + + if (!includeOnlyList.isEmpty() && !includeOnlyList.contains(documentName)) { + System.out.println("The document '" + documentName + "' skipped from the processing."); return false; } + System.out.println(String.format(OUTPUT_LOG, Constants.FORMAT.toUpperCase(), fileOut.toString())); + System.out.println(); + System.out.println("Transforming..."); // load linearized xml @@ -627,6 +648,10 @@ public void setExcludeList(List excludeList) { this.excludeList = excludeList; } + public void setIncludeOnlyList(List includeOnlyList) { + this.includeOnlyList = includeOnlyList; + } + public void setRepositoryIndexPath(String repositoryIndexPath) { this.repositoryIndexPath = repositoryIndexPath; }