Skip to content

Commit

Permalink
Merge pull request #96 from metanorma/resource_adoc
Browse files Browse the repository at this point in the history
04-schemas.adoc added as jar resource, #58
  • Loading branch information
Intelligent2013 authored Nov 25, 2023
2 parents f155f32 + 67d82bb commit 56d32e8
Show file tree
Hide file tree
Showing 6 changed files with 849 additions and 29 deletions.
54 changes: 27 additions & 27 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You will need the `maven` build tool and `make`.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <XML-FileName>
java -Xss5m -jar target/stepmod2mn-1.23.jar <XML-FileName>
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/resource_docs/draughting_elements/resource.xml
java -Xss5m -jar target/stepmod2mn-1.23.jar data/resource_docs/draughting_elements/resource.xml
----

NOTE: resulted AsciiDoc found in data/resource_docs/draughting_elements/document.adoc
Expand All @@ -34,28 +34,28 @@ NOTE: resulted AsciiDoc found in data/resource_docs/draughting_elements/document

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <XML-FileName> [--output <AsciiDoc-FileName>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <XML-FileName> [--output <AsciiDoc-FileName>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/resource_docs/draughting_elements/resource.xml --output result_dir/draughting_elements/document.adoc
java -Xss5m -jar target/stepmod2mn-1.23.jar data/resource_docs/draughting_elements/resource.xml --output result_dir/draughting_elements/document.adoc
----

=== Convert all resource.xml and module.xml in the specified folder and sub-folders into the Metanorma AsciiDoc format:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Input-folder>
java -Xss5m -jar target/stepmod2mn-1.23.jar <Input-folder>
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/
java -Xss5m -jar target/stepmod2mn-1.23.jar data/
----

NOTE: the result AsciiDocs will be saved in the folder with the source resource.xml and module.xml files.
Expand All @@ -65,57 +65,57 @@ NOTE: the result AsciiDocs will be saved in the folder with the source resource.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Input-folder> [--output <Output-folder>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <Input-folder> [--output <Output-folder>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/ --output documents/
java -Xss5m -jar target/stepmod2mn-1.23.jar data/ --output documents/
----


=== Convert all resource.xml and module.xml in the specified folder and sub-folders into the Metanorma AsciiDoc format, except specified documents:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Input-folder> [--exclude <documents list>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <Input-folder> [--exclude <documents list>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/ --exclude "machining_features"
java -Xss5m -jar target/stepmod2mn-1.23.jar data/ --exclude "machining_features"
----

=== Convert only specified documents resource.xml and module.xml in the specified folder and sub-folders into the Metanorma AsciiDoc format:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Input-folder> [--include-only <documents list>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <Input-folder> [--include-only <documents list>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar data/ --include-only "fundamentals_of_product_description_and_support kinematics"
java -Xss5m -jar target/stepmod2mn-1.23.jar data/ --include-only "fundamentals_of_product_description_and_support kinematics"
----

=== Convert the documents specified in the publication index xml file in the tags 'resource_docs' and 'modules' into the Metanorma AsciiDoc format:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Publication-Index-XML-FileName>
java -Xss5m -jar target/stepmod2mn-1.23.jar <Publication-Index-XML-FileName>
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar publication/part1000/CR_PMI_5/publication_index.xml
java -Xss5m -jar target/stepmod2mn-1.23.jar publication/part1000/CR_PMI_5/publication_index.xml
----

NOTE: the resulted AsciiDocs will be saved in the folder with the source resource.xml and module.xml files.
Expand All @@ -127,29 +127,29 @@ and save them into the output folder:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Publication-Index-XML-FileName> [--output <Output-folder>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <Publication-Index-XML-FileName> [--output <Output-folder>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar publication/part1000/CR_PMI_5/publication_index.xml --output documents/
java -Xss5m -jar target/stepmod2mn-1.23.jar publication/part1000/CR_PMI_5/publication_index.xml --output documents/
----


=== Convert the specified type of the document (resource_docs or modules) in the publication index xml file into the Metanorma AsciiDoc format:

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar <Publication-Index-XML-FileName> [--type <resource_docs or modules>]
java -Xss5m -jar target/stepmod2mn-1.23.jar <Publication-Index-XML-FileName> [--type <resource_docs or modules>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.22.jar publication/part1000/CR_PMI_5/publication_index.xml --type resource_docs
java -Xss5m -jar target/stepmod2mn-1.23.jar publication/part1000/CR_PMI_5/publication_index.xml --type resource_docs
----

NOTE: the resulted AsciiDocs will be saved in the folder with the source resource.xml (or module.xml) files.
Expand All @@ -161,42 +161,42 @@ NOTE: the Metanorma collection file 'metanorma.yml' will be saved in the 3 level

[source,sh]
----
java -jar target/stepmod2mn-1.22.jar <start folder to process xml maps files> --svg
java -jar target/stepmod2mn-1.23.jar <start folder to process xml maps files> --svg
----

e.g.

[source,sh]
----
java -jar target/stepmod2mn-1.22.jar data/resources --svg
java -jar target/stepmod2mn-1.23.jar data/resources --svg
----

=== Generate SVG images for the XML in the specified folder and sub-folders, and save them in the output folder:

[source,sh]
----
java -jar target/stepmod2mn-1.22.jar <start folder to process xml maps files> --svg [--output <Output-folder>]
java -jar target/stepmod2mn-1.23.jar <start folder to process xml maps files> --svg [--output <Output-folder>]
----

e.g.

[source,sh]
----
java -jar target/stepmod2mn-1.22.jar data/resources --svg --output schemas/
java -jar target/stepmod2mn-1.23.jar data/resources --svg --output schemas/
----

=== Generate SVG image for Express Imagemap XML and Image:

[source,sh]
----
java -jar stepmod2mn-1.22.jar --xml <Express Imagemap XML file path> --image <Image file name> [--svg <resulted SVG map file or folder>]
java -jar stepmod2mn-1.23.jar --xml <Express Imagemap XML file path> --image <Image file name> [--svg <resulted SVG map file or folder>]
----

e.g.

[source,sh]
----
java -jar stepmod2mn-1.22.jar --xml data\resource_docs\fundamentals_of_product_description_and_support\schema_diagexpg1.xml --image schema_diagexpg1.gif --svg schema_diagexpg1.svg
java -jar stepmod2mn-1.23.jar --xml data\resource_docs\fundamentals_of_product_description_and_support\schema_diagexpg1.xml --image schema_diagexpg1.gif --svg schema_diagexpg1.svg
----


Expand All @@ -216,7 +216,7 @@ Update version in `pom.xml`, e.g.:
----
<groupId>org.metanorma</groupId>
<artifactId>stepmod2mn</artifactId>
<version>1.22</version>
<version>1.23</version>
<name>STEPmod XML to Metanorma AsciiDoc converter</name>
----

Expand All @@ -227,8 +227,8 @@ Tag the same version in Git:

[source,xml]
----
git tag v1.22
git push origin v1.22
git tag v1.23
git push origin v1.23
----

Then the corresponding GitHub release will be automatically created at:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.metanorma</groupId>
<artifactId>stepmod2mn</artifactId>
<version>1.22</version>
<version>1.23</version>
<name>STEPmod XML to Metanorma AsciiDoc converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/metanorma/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@ public static void copyFile(String sourceFilename, String targetFilename) {
}
}

public static void copyFileFromResource(String sourceFilename, String targetFilename) {
try {
InputStream stream = getStreamFromResources(stepmod2mn.class.getClassLoader(), sourceFilename);
if(stream == null) {
System.err.println("Cannot get resource \"" + sourceFilename + "\" from Jar file.");
}
Path target = Paths.get(targetFilename);
Files.copy(stream, target, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception ex) {
System.err.println("Cannot copy the resource file \"" + sourceFilename + "\" to the file " + targetFilename + ": " + ex);
}
}

public static void FlushTempFolder(Path tmpfilepath) {
if (Files.exists(tmpfilepath)) {
//Files.deleteIfExists(tmpfilepath);
Expand Down
Loading

0 comments on commit 56d32e8

Please sign in to comment.