Skip to content

Commit

Permalink
Merge pull request #180 from metanorma/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
Intelligent2013 authored Apr 28, 2024
2 parents 040bc5d + 46450da commit 821c32e
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 51 deletions.
56 changes: 28 additions & 28 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.51.jar <XML-FileName>
java -Xss5m -jar target/stepmod2mn-1.52.jar <XML-FileName>
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar data/resource_docs/draughting_elements/resource.xml
java -Xss5m -jar target/stepmod2mn-1.52.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.51.jar <XML-FileName> [--output <AsciiDoc-FileName>]
java -Xss5m -jar target/stepmod2mn-1.52.jar <XML-FileName> [--output <AsciiDoc-FileName>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar data/resource_docs/draughting_elements/resource.xml --output result_dir/draughting_elements/document.adoc
java -Xss5m -jar target/stepmod2mn-1.52.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.51.jar <Input-folder>
java -Xss5m -jar target/stepmod2mn-1.52.jar <Input-folder>
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar data/
java -Xss5m -jar target/stepmod2mn-1.52.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.51.jar <Input-folder> [--output <Output-folder>]
java -Xss5m -jar target/stepmod2mn-1.52.jar <Input-folder> [--output <Output-folder>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar data/ --output documents/
java -Xss5m -jar target/stepmod2mn-1.52.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.51.jar <Input-folder> [--exclude <documents or part numbers list>]
java -Xss5m -jar target/stepmod2mn-1.52.jar <Input-folder> [--exclude <documents or part numbers list>]
----

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar data/ --exclude "machining_features 104"
java -Xss5m -jar target/stepmod2mn-1.52.jar data/ --exclude "machining_features 104"
----

=== 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.51.jar <Input-folder> [--include-only <documents list>]
java -Xss5m -jar target/stepmod2mn-1.52.jar <Input-folder> [--include-only <documents list>]
----

e.g.

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

=== Generate Metanorma collection files (metanorma.yml and collection.yml) for the documents specified in the publication index xml file in the tags 'resource_docs' and 'modules':

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

e.g.

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

NOTE: the Metanorma collection files .yml will be saved in the 3 level up folder (usually, source repository's root folder).
Expand All @@ -125,14 +125,14 @@ and save them into the output folder:

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

e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar iso-10303-srl/iso-10303-stepmod-wg12/publication/part1000/CR_PMI_5/publication_index.xml --output iso-10303-srl/
java -Xss5m -jar target/stepmod2mn-1.52.jar iso-10303-srl/iso-10303-stepmod-wg12/publication/part1000/CR_PMI_5/publication_index.xml --output iso-10303-srl/
----

NOTE: the output folder should contains the folder with the generated .adoc (usually, 'documents'). You can specify this folder obviously by the parameter '--input-documents':
Expand All @@ -141,7 +141,7 @@ e.g.

[source,sh]
----
java -Xss5m -jar target/stepmod2mn-1.51.jar iso-10303-srl/iso-10303-stepmod-wg12/publication/part1000/CR_PMI_5/publication_index.xml --output iso-10303-srl/CR_PMI_5 --input-documents iso-10303-srl/documents
java -Xss5m -jar target/stepmod2mn-1.52.jar iso-10303-srl/iso-10303-stepmod-wg12/publication/part1000/CR_PMI_5/publication_index.xml --output iso-10303-srl/CR_PMI_5 --input-documents iso-10303-srl/documents
----

NOTE: the Metanorma collection files (.yml) will be saved in the folder 'iso-10303-srl/CR_PMI_5' and the references point to the documents in the folder iso-10303-srl/documents.
Expand All @@ -151,14 +151,14 @@ NOTE: the Metanorma collection files (.yml) will be saved in the folder 'iso-103

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

e.g.

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

NOTE: the Metanorma collection file 'metanorma.yml' will be saved in the 3 level up folder (usually, source repository's root folder).
Expand All @@ -168,42 +168,42 @@ NOTE: the Metanorma collection file 'metanorma.yml' will be saved in the 3 level

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

e.g.

[source,sh]
----
java -jar target/stepmod2mn-1.51.jar data/resources --svg
java -jar target/stepmod2mn-1.52.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.51.jar <start folder to process xml maps files> --svg [--output <Output-folder>]
java -jar target/stepmod2mn-1.52.jar <start folder to process xml maps files> --svg [--output <Output-folder>]
----

e.g.

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

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

[source,sh]
----
java -jar stepmod2mn-1.51.jar --xml <Express Imagemap XML file path> --image <Image file name> [--svg <resulted SVG map file or folder>]
java -jar stepmod2mn-1.52.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.51.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.52.jar --xml data\resource_docs\fundamentals_of_product_description_and_support\schema_diagexpg1.xml --image schema_diagexpg1.gif --svg schema_diagexpg1.svg
----


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

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

[source,xml]
----
git tag v1.51
git push origin v1.51
git tag v1.52
git push origin v1.52
----

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.51</version>
<version>1.52</version>
<name>STEPmod XML to Metanorma AsciiDoc converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/metanorma/stepmod2mn.java
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,19 @@ public String generateSVGs(String xmlFilesPath, String image, String outPathDocu
}
outPath = Paths.get(outPathSchemas, kind).toString();
} else {
isSVGmap = true;
String folderDocumentName = "";
if (attPart.matches("^\\d+\\-\\d+$")) {
folderDocumentName = "iso-" + attPart;
if (attPart.isEmpty()) {
System.out.println("[ERROR] No part number. Skip '" + xmlFile +"' processing.");
xmlFile = null;
} else {
folderDocumentName = Constants.ISO_STANDARD_PREFIX + attPart;
isSVGmap = true;
String folderDocumentName = "";
if (attPart.matches("^\\d+\\-\\d+$")) {
folderDocumentName = "iso-" + attPart;
} else {
folderDocumentName = Constants.ISO_STANDARD_PREFIX + attPart;
}
outPath = Paths.get(outPath, folderDocumentName).toString();
}
outPath = Paths.get(outPath, folderDocumentName).toString();
}
} else {
xmlFile = null;
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/stepmod.base_xsl/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,8 @@ or name()='screen' or name()='ul' or name()='example' or name()='note' or name()
<xsl:template name="error_message">
<xsl:param name="message"/>
<xsl:param name="inline" select="'yes'"/>
<xsl:param name="insert_newline" select="'yes'"/>
<xsl:param name="comment" select="'no'"/>
<xsl:param name="linebreakchar" select="'#'"/>
<xsl:param name="warning_gif" select="'../../../../images/warning.gif'"/>

Expand All @@ -1625,7 +1627,9 @@ or name()='screen' or name()='ul' or name()='example' or name()='note' or name()

<xsl:if test="contains($INLINE_ERRORS,'yes')">
<xsl:if test="contains($inline,'yes')">
<xsl:text>&#xa;</xsl:text>
<xsl:if test="$insert_newline = 'yes'">
<xsl:text>&#xa;</xsl:text>
</xsl:if>
<!-- <br/>
<IMG
SRC="{$warning_gif}" ALT="[warning:]"
Expand All @@ -1642,6 +1646,7 @@ width="20" height="20"/> -->
</xsl:call-template>
</i>
</font> -->
<xsl:if test="$comment = 'yes'">// </xsl:if>
<xsl:text>_</xsl:text>
<xsl:call-template name="output_line_breaks">
<xsl:with-param name="str" select="$message_"/>
Expand Down Expand Up @@ -2556,7 +2561,7 @@ width="20" height="20"/> -->
<!-- <xsl:value-of
select="concat('../../../modules/',$module,
'/sys/3_defs',$FILE_EXT)"/> -->
<xsl:value-of select="'termsdefns'"/>
<xsl:value-of select="'defns'"/>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:value-of
Expand Down Expand Up @@ -5008,6 +5013,7 @@ is case sensitive.')"/>
<!-- Flag a warning if the defnition starts with a an the
A phrase should NOT end in a period -->
<xsl:template match="def" mode="check_phrase">
<xsl:param name="insert_newline">yes</xsl:param>
<xsl:variable name="UPPER">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<xsl:variable name="LOWER">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="defn" select="translate(normalize-space(text()), $LOWER, $UPPER)"/>
Expand All @@ -5025,20 +5031,26 @@ is case sensitive.')"/>
<xsl:with-param
name="message"
select="concat('Error defn2, module: ',/*/@name,' - definition should not start with an article i.e A or a.')"/>
<xsl:with-param name="comment" select="'yes'"/>
<xsl:with-param name="insert_newline" select="$insert_newline"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($defn, 'AN ')">
<xsl:call-template name="error_message">
<xsl:with-param
name="message"
select="concat('Error defn2, module: ',/*/@name,' - definition should not start with an article i.e An or an.')"/>
<xsl:with-param name="comment" select="'yes'"/>
<xsl:with-param name="insert_newline" select="$insert_newline"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($defn, 'THE ')">
<xsl:call-template name="error_message">
<xsl:with-param
name="message"
select="concat('Error defn2, module: ',/*/@name,' - definition should not start with an article i.e The or the.')"/>
<xsl:with-param name="comment" select="'yes'"/>
<xsl:with-param name="insert_newline" select="$insert_newline"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
Expand Down
21 changes: 17 additions & 4 deletions src/main/resources/stepmod.base_xsl/module.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,10 @@ TT remove since locke is no longer available.
</xsl:when>
<xsl:otherwise>
<xsl:if test="not(substring-after(.,'This document specifies'))">
<!-- Commented, see https://github.com/metanorma/iso-10303-srl/issues/201#issuecomment-2081298354 -->
<xsl:call-template name="error_message">
<xsl:with-param name="inline" select="'yes'"/>
<xsl:with-param name="comment" select="'yes'"/>
<xsl:with-param name="warning_gif" select="'../../../../images/warning.gif'"/>
<xsl:with-param name="message" select="'Error P2: Introduction does not start with required text: This document specifies .'"/>
</xsl:call-template>
Expand Down Expand Up @@ -3629,7 +3631,9 @@ test="document('../data/basic/normrefs.xml')/normref.list/normref[@id=$normref]/
it means all "ISO 10303-*" parts should be omitted, because ISO 10303-2 is a new publication that includes all terms.
This means once we include ISO 10303-2 in the source,
we do not need to import any other term from any ISO 10303-* document. -->
<xsl:if test="$module_number!=$part_no and not(contains($stdnumber, 'ISO 10303-'))">
<!-- <xsl:if test="$module_number!=$part_no and not(contains($stdnumber, 'ISO 10303-'))"> -->
<xsl:if test="$module_number!=$part_no and normalize-space(java:matches(java:java.lang.String.new($stdnumber), $ISO_10303_regex)) = 'false'">

<!-- <h2>
<xsl:value-of select="concat('3.1.',$section_no,
' Terms defined in ',$stdnumber)"/>
Expand Down Expand Up @@ -3698,7 +3702,8 @@ test="document('../data/basic/normrefs.xml')/normref.list/normref[@id=$normref]/
it means all "ISO 10303-*" parts should be omitted, because ISO 10303-2 is a new publication that includes all terms.
This means once we include ISO 10303-2 in the source,
we do not need to import any other term from any ISO 10303-* document. -->
<xsl:if test="not(contains($stdnumber, 'ISO 10303-'))">
<!-- <xsl:if test="not(contains($stdnumber, 'ISO 10303-'))"> -->
<xsl:if test="normalize-space(java:matches(java:java.lang.String.new($stdnumber), $ISO_10303_regex)) = 'false'">
<!-- output the section header for the normative reference
that is defining terms -->
<!-- <h2>
Expand Down Expand Up @@ -4167,14 +4172,22 @@ $module_ok,' Check the normatives references')"/>
<xsl:with-param name="index_term2">term</xsl:with-param>
</xsl:call-template>
<!-- <xsl:apply-templates select="def"/> -->
<xsl:apply-templates select="def" mode="check_phrase">
<xsl:with-param name="insert_newline">no</xsl:with-param>
</xsl:apply-templates>
<xsl:call-template name="insertParagraph">
<xsl:with-param name="text">
<xsl:apply-templates select="def"/>
<xsl:apply-templates select="def">
<xsl:with-param name="check_phrase">no</xsl:with-param>
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="def">
<xsl:apply-templates select="." mode="check_phrase"/>
<xsl:param name="check_phrase">yes</xsl:param>
<xsl:if test="$check_phrase = 'yes'">
<xsl:apply-templates select="." mode="check_phrase"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="refdata">
Expand Down
Loading

0 comments on commit 821c32e

Please sign in to comment.