Skip to content

Commit

Permalink
sect_3_defs.xsl and module.xsl updated for ISO 10303-2 terms, #144
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Apr 25, 2024
1 parent 342acb6 commit f00d9a3
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 42 deletions.
186 changes: 148 additions & 38 deletions src/main/resources/stepmod.base_xsl/module.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2803,16 +2803,30 @@ this document, may be provided to support implementations. If the information
<xsl:apply-templates select="." mode="output_clause_issue">
<xsl:with-param name="clause" select="'normrefs'"/>
</xsl:apply-templates>
<!-- output the normative reference explicitly defined in the module -->
<xsl:apply-templates select="/module/normrefs/normref">
<xsl:with-param name="current_module" select="$current_module"/>
</xsl:apply-templates>
<!-- output the default normative reference and any implicit in the
module through the ARM and MIM -->
<xsl:call-template name="output_default_normrefs">
<xsl:with-param name="module_number" select="$module_number"/>
<xsl:with-param name="current_module" select="$current_module"/>
</xsl:call-template>

<xsl:variable name="normative_references">
<!-- output the normative reference explicitly defined in the module -->
<xsl:apply-templates select="/module/normrefs/normref">
<xsl:with-param name="current_module" select="$current_module"/>
</xsl:apply-templates>
<!-- output the default normative reference and any implicit in the
module through the ARM and MIM -->
<xsl:call-template name="output_default_normrefs">
<xsl:with-param name="module_number" select="$module_number"/>
<xsl:with-param name="current_module" select="$current_module"/>
</xsl:call-template>
</xsl:variable>

<xsl:copy-of select="$normative_references"/>

<xsl:if test="not(contains($normative_references, '* [[[ref10303-2,'))">
<!-- * [[[ref10303-2,ISO 10303-2]]] _Industrial automation systems and integration — Product data representation and exchange— Part 2: Vocabulary_</xsl:text> -->
<xsl:variable name="normref_10303_2"><normref.inc ref="ref10303-2"/></xsl:variable>
<xsl:apply-templates select="xalan:nodeset($normref_10303_2)/*">
<xsl:with-param name="current_resource" select="."/>
</xsl:apply-templates>
</xsl:if>

</xsl:template>
<!-- output the default normative reference and any implicit in the
module through the ARM and MIM -->
Expand Down Expand Up @@ -3609,7 +3623,11 @@ test="document('../data/basic/normrefs.xml')/normref.list/normref[@id=$normref]/
<!-- normref stdnumber are 10303-1107 whereas module numbers are
1107, so remove the 10303- -->
<xsl:variable name="part_no" select="substring-after($normref/stdref/stdnumber,'-')"/>
<xsl:if test="$module_number!=$part_no">
<!-- from https://github.com/metanorma/stepmod2mn/issues/145#issuecomment-2076664788
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-'))">
<!-- <h2>
<xsl:value-of select="concat('3.1.',$section_no,
' Terms defined in ',$stdnumber)"/>
Expand Down Expand Up @@ -3673,34 +3691,125 @@ test="document('../data/basic/normrefs.xml')/normref.list/normref[@id=$normref]/
<xsl:if test="not(contains($normref_ids,$normrefid))">
<xsl:variable name="module_node" select="$module_xml_document/module"/>
<xsl:variable name="stdnumber" select="concat('ISO/',$module_node/@status,'&#160;10303-',$module_node/@part)"/>
<!-- output the section header for the normative reference
that is defining terms -->
<!-- <h2>
<xsl:value-of select="concat('3.',$section_no,
' Terms defined in ', $stdnumber)"/>
</h2> -->
<xsl:call-template name="insertHeaderADOC">
<xsl:with-param name="id" select="concat('sec_3.',$section_no)"/>
<xsl:with-param name="level" select="3"/>
<xsl:with-param name="header" select="concat('Terms defined in ', $stdnumber)"/>
</xsl:call-template>
<!-- <p> -->
<!-- RBN Changed due to request from ISO
For the purposes of this part of ISO 10303, -->
<xsl:call-template name="insertParagraph">
<xsl:with-param name="text">
For the purposes of this document,
the following terms defined in
<xsl:value-of select="$stdnumber"/>
apply:

<!-- from https://github.com/metanorma/stepmod2mn/issues/145#issuecomment-2076664788
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-'))">
<!-- output the section header for the normative reference
that is defining terms -->
<!-- <h2>
<xsl:value-of select="concat('3.',$section_no,
' Terms defined in ', $stdnumber)"/>
</h2> -->
<xsl:call-template name="insertHeaderADOC">
<xsl:with-param name="id" select="concat('sec_3.',$section_no)"/>
<xsl:with-param name="level" select="3"/>
<xsl:with-param name="header" select="concat('Terms defined in ', $stdnumber)"/>
</xsl:call-template>
<!-- <p> -->
<!-- RBN Changed due to request from ISO
For the purposes of this part of ISO 10303, -->
<xsl:call-template name="insertParagraph">
<xsl:with-param name="text">
For the purposes of this document,
the following terms defined in
<xsl:value-of select="$stdnumber"/>
apply:
</xsl:with-param>
</xsl:call-template>
<!-- </p> -->
<!-- <ul> -->
<!-- now output the terms -->
<xsl:apply-templates select="/module/normrefs/normref.inc[@module.name=$module]/term.ref" mode="module"/>
<xsl:text>&#xa;&#xa;</xsl:text>
<!-- </ul> -->
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="error_message">
<xsl:with-param name="message">
<xsl:value-of select="concat('Error ref 2: ',
$module_ok,' Check the normatives references')"/>
</xsl:with-param>
</xsl:call-template>
<!-- </p> -->
<!-- <ul> -->
<!-- now output the terms -->
<xsl:apply-templates select="/module/normrefs/normref.inc[@module.name=$module]/term.ref" mode="module"/>
<xsl:text>&#xa;&#xa;</xsl:text>
<!-- </ul> -->
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="contains($first,'resource:')">
<xsl:variable name="resource" select="substring-after($first,'resource:')"/>
<!-- should never get here -->
</xsl:when>
</xsl:choose>
<xsl:call-template name="output_normrefs_terms_rec">
<xsl:with-param name="normrefs" select="$rest"/>
<xsl:with-param name="normref_ids" select="$normref_ids"/>
<xsl:with-param name="section" select="$section_no"/>
<xsl:with-param name="module_number" select="$module_number"/>
<xsl:with-param name="current_module" select="$current_module"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- end of recursion -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="get_list_normrefs_terms_rec">
<xsl:param name="normrefs"/>
<xsl:param name="normref_ids"/>
<xsl:param name="section"/>
<xsl:param name="module_number"/>
<xsl:param name="current_module"/>
<xsl:choose>
<xsl:when test="$normrefs">
<xsl:variable name="first" select="substring-before(substring-after($normrefs,','),',')"/>
<xsl:variable name="section_no" select="$section+1"/>
<xsl:variable name="rest" select="substring-after(substring-after($normrefs,','),',')"/>
<xsl:choose>
<xsl:when test="contains($first,'normref:')">
<xsl:variable name="ref" select="substring-after($first,'normref:')"/>
<xsl:variable name="normrefs_xml_document" select="document(concat($path, '../../../data/basic/normrefs.xml'))"/>
<xsl:variable name="normref" select="$normrefs_xml_document/normref.list/normref[@id=$ref]"/>
<!-- get the number of the standard -->
<xsl:variable name="stdnumber" select="concat($normref/stdref/orgname, ' ',$normref/stdref/stdnumber)"/>
<!-- output the section header for the normative reference that is
defining terms
IGNORE if the normative ref is referring to this module
-->
<!-- normref stdnumber are 10303-1107 whereas module numbers are
1107, so remove the 10303- -->
<xsl:variable name="part_no" select="substring-after($normref/stdref/stdnumber,'-')"/>
<xsl:if test="$module_number!=$part_no">
<item><xsl:value-of select="$stdnumber"/></item>
</xsl:if>
</xsl:when>
<!-- a term defined in another module -->
<xsl:when test="contains($first,'module:')">
<xsl:variable name="module" select="substring-after($first,'module:')"/>
<xsl:variable name="module_dir">
<xsl:call-template name="module_directory">
<xsl:with-param name="module" select="$module"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="module_ok">
<xsl:call-template name="check_module_exists">
<xsl:with-param name="module" select="$module"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$module_ok='true'">
<xsl:variable name="module_xml" select="concat($module_dir,'/module.xml')"/>
<xsl:variable name="module_xml_document" select="document($module_xml)"/>
<xsl:variable name="normrefid" select="concat('10303-',$module_xml_document/module/@part)"/>
<!-- check to see if the terms for the module have been output
as part of normative references -->
<xsl:if test="not(contains($normref_ids,$normrefid))">
<xsl:variable name="module_node" select="$module_xml_document/module"/>
<xsl:variable name="stdnumber" select="concat('ISO/',$module_node/@status,'&#160;10303-',$module_node/@part)"/>
<item><xsl:value-of select="$stdnumber"/></item>
</xsl:if>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -3731,6 +3840,7 @@ $module_ok,' Check the normatives references')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- build a list of normrefs that are used by the module and have terms
defined in them
The list comprises:
Expand Down
75 changes: 71 additions & 4 deletions src/main/resources/stepmod.base_xsl/sect_3_defs.xsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="./document_xsl.xsl" ?>
<!-- <?xml-stylesheet type="text/xsl" href="./document_xsl.xsl" ?> -->

<!--
$Id: sect_3_defs.xsl,v 1.10 2009/12/24 17:42:03 lothartklein Exp $
$Id: sect_3_defs.xsl,v 1.11 2010/02/03 12:10:33 robbod Exp $
Author: Rob Bodington, Eurostep Limited
Owner: Developed by Eurostep and supplied to NIST under contract.
Purpose:
-->
<!-- Updated: Alexander Dyuzhev, for stepmod2mn tool -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan"
version="1.0">

<!-- <xsl:import href="module.xsl"/> -->
Expand All @@ -23,7 +25,7 @@ $Id: sect_3_defs.xsl,v 1.10 2009/12/24 17:42:03 lothartklein Exp $
<!-- <xsl:output method="html"/> -->

<!-- overwrites the template declared in module.xsl -->
<xsl:template match="module" mode="terms_definitions_module">
<xsl:template match="module" mode="terms_definitions_module"> <!-- called from stepmod2mn.module.adoc.xsl -->
<!-- Output the terms identified in the normative references -->
<!--
ISO requested:
Expand Down Expand Up @@ -56,6 +58,24 @@ $Id: sect_3_defs.xsl,v 1.10 2009/12/24 17:42:03 lothartklein Exp $
</h2> -->

<xsl:text>&#xa;</xsl:text>

<!-- get a list of normative references that have terms defined -->
<xsl:variable name="normrefs">
<xsl:call-template name="normrefs_terms_list">
<xsl:with-param name="current_resource" select="./@part"/>
</xsl:call-template>
</xsl:variable>
<!-- list of the references -->
<xsl:variable name="list_ref">
<xsl:call-template name="get_list_normrefs_terms_rec">
<xsl:with-param name="normrefs" select="$normrefs"/>
<xsl:with-param name="normref_ids" select="$normrefs"/>
<xsl:with-param name="section" select="0"/>
<xsl:with-param name="resource_number" select="./@part"/>
<xsl:with-param name="current_resource" select="."/>
</xsl:call-template>
</xsl:variable>

<xsl:call-template name="insertHeaderADOC">
<xsl:with-param name="id" select="'defns'"/>
<xsl:with-param name="level" select="1"/>
Expand All @@ -68,15 +88,62 @@ $Id: sect_3_defs.xsl,v 1.10 2009/12/24 17:42:03 lothartklein Exp $
</a>
</h2> -->

<!-- from https://github.com/metanorma/stepmod2mn/issues/145#issuecomment-2076664788
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:variable name="attributes">
<xsl:if test="xalan:nodeset($list_ref)//item[contains(., 'ISO 10303-')]">source=ref10303-2</xsl:if>
</xsl:variable>

<xsl:call-template name="insertHeaderADOC">
<xsl:with-param name="id" select="'termsdefns'"/>
<xsl:with-param name="attributes" select="normalize-space($attributes)"/>
<xsl:with-param name="level" select="2"/>
<xsl:with-param name="header" select="'Terms and definitions'"/>
</xsl:call-template>

<xsl:if test="count(xalan:nodeset($list_ref)//item[contains(., 'ISO 10303-')]) = count(xalan:nodeset($list_ref)//item)">
<xsl:call-template name="insertHeaderADOC">
<xsl:with-param name="id" select="'termsdefns'"/>
<xsl:with-param name="id" select="'termsdefns'"/>
<xsl:with-param name="attributes" select="'heading=terms and definitions'"/>
<xsl:with-param name="level" select="2"/>
<xsl:with-param name="header" select="'Terms and definitions'"/>
</xsl:call-template>
</xsl:if>

<xsl:call-template name="output_terms">
<xsl:with-param name="module_number" select="./@part"/>
</xsl:call-template>

<!-- <p>For the purposes of this document, the terms and definitions given in ISO 10303-2 <sup><a href="#tobepub">1</a>)</sup> apply.</p>
<p>ISO and IEC maintain terminology databases for use in standardization
at the following addresses:</p>
<table>
<tr>
<td>— ISO Online browsing platform: available at <a href="https://www.iso.org/obp" target="_blank">https://www.iso.org/obp</a>;</td>
</tr>
<tr>
<td>— IEC Electropedia: available at <a href="https://www.electropedia.org/" target="_blank">https://www.electropedia.org/</a>.</td>
</tr>
</table>
<xsl:call-template name="output_abbreviations">
<xsl:with-param name="section" select="2"/>
</xsl:call-template>
<table width="500">
<tr>
<td><hr/></td>
</tr>
<tr>
<td>
<a name="tobepub">
<sup>1)</sup> Under preparation. Stage at time of publication: ISO/FDIS 10303-2:2023</a>
</td>
</tr>
</table> -->

</xsl:template>

</xsl:stylesheet>

0 comments on commit f00d9a3

Please sign in to comment.