Skip to content

Commit

Permalink
do not process concept within Semantic XML term elements: #632
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Jan 1, 2025
1 parent 464bbdf commit c1515e1
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/isodoc/presentation_function/concepts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def concept(docxml)
end

def concept1(node)
node.ancestors("definition, termsource, related").empty? or return
xref = node&.at(ns("./xref/@target"))&.text or
return concept_render(node, ital: "true", ref: "true", bold: "false",
linkref: "true", linkmention: "false")
Expand Down
112 changes: 112 additions & 0 deletions spec/isodoc/terms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2461,4 +2461,116 @@
.at("//xmlns:terms").to_xml)))
.to be_equivalent_to Xml::C14n.format(output)
end

it "do not process concept markup in Semantic XML" do
input = <<~INPUT
<iso-standard xmlns="http://riboseinc.com/isoxml">
<bibdata><language>en</language></bibdata>
<sections>
<terms id="terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
<term id="paddy1"><preferred><expression><name>paddy</name></expression></preferred>
<definition><verbal-definition>
<ul>
<concept><refterm>term1</refterm>
<renderterm>term</renderterm>
<xref target='clause1'/>
</concept></li>
<li><concept><refterm>term1</refterm>
<renderterm>term</renderterm>
<xref target='clause1'/>
</concept></li>
</ul>
</verbal-definition></definition>
</term>
</terms>
</sections></iso-standard>
INPUT
output = <<~OUTPUT
<terms id="terms_and_definitions" obligation="normative" displayorder="2">
<title id="_">Terms and Definitions</title>
<fmt-title depth="1">
<span class="fmt-caption-label">
<semx element="autonum" source="terms_and_definitions">1</semx>
<span class="fmt-autonum-delim">.</span>
</span>
<span class="fmt-caption-delim">
<tab/>
</span>
<semx element="title" source="_">Terms and Definitions</semx>
</fmt-title>
<fmt-xref-label>
<span class="fmt-element-name">Clause</span>
<semx element="autonum" source="terms_and_definitions">1</semx>
</fmt-xref-label>
<term id="paddy1">
<fmt-name>
<span class="fmt-caption-label">
<semx element="autonum" source="terms_and_definitions">1</semx>
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="paddy1">1</semx>
<span class="fmt-autonum-delim">.</span>
</span>
</fmt-name>
<fmt-xref-label>
<span class="fmt-element-name">Clause</span>
<semx element="autonum" source="terms_and_definitions">1</semx>
<span class="fmt-autonum-delim">.</span>
<semx element="autonum" source="paddy1">1</semx>
</fmt-xref-label>
<preferred id="_">
<expression>
<name>paddy</name>
</expression>
</preferred>
<fmt-preferred>
<p>
<semx element="preferred" source="_">
<strong>paddy</strong>
</semx>
</p>
</fmt-preferred>
<definition id="_">
<verbal-definition>
<ul>
<concept>
<refterm>term1</refterm>
<renderterm>term</renderterm>
<xref target="clause1"/>
</concept>
</ul>
<li>
<concept>
<refterm>term1</refterm>
<renderterm>term</renderterm>
<xref target="clause1"/>
</concept>
</li>
</verbal-definition>
</definition>
<fmt-definition>
<semx element="definition" source="_">
<ul>
<em>term</em>
(
<xref target="clause1">[clause1]</xref>
)
</ul>
<li>
<em>term</em>
(
<xref target="clause1">[clause1]</xref>
)
</li>
</semx>
</fmt-definition>
</term>
</terms>
OUTPUT
expect(Xml::C14n.format(strip_guid(Nokogiri::XML(IsoDoc::PresentationXMLConvert
.new(presxml_options)
.convert("test", input, true))
.at("//xmlns:terms").to_xml)))
.to be_equivalent_to Xml::C14n.format(output)
end

end

0 comments on commit c1515e1

Please sign in to comment.