Skip to content

Commit

Permalink
remove strip-space from preprocessing XSLT: metanorma/metanorma-ogc#614
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Dec 11, 2023
1 parent 389819e commit ea666ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions lib/isodoc/presentation_function/bibdata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ def bibdata(docxml)
end

def extension_insert(xml, path = [])
ins = xml.at(ns("//metanorma-extension")) ||
xml.at(ns("//bibdata"))&.after("<metanorma-extension/>")&.next_element ||
xml.root.elements.first.before("<metanorma-extension/>").previous_element
ins = extension_insert_pt(xml)
path.each do |n|
ins = ins.at(ns("./#{n}")) || ins.add_child("<#{n}/>").first
end
ins
end

def extension_insert_pt(xml)
xml.at(ns("//metanorma-extension")) ||
xml.at(ns("//bibdata"))&.after("<metanorma-extension/>")
&.next_element ||
xml.root.elements.first.before("<metanorma-extension/>")
.previous_element
end

def preprocess_xslt_insert(docxml)
content = ""
p = passthrough_xslt and content += p
Expand All @@ -42,7 +48,6 @@ def passthrough_xslt
<preprocess-xslt format="#{k}">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
Expand Down Expand Up @@ -142,7 +147,8 @@ def hash_translate(bibdata, hash, xpath, lang = @lang)
tag_translate(x, lang, hash[x.text])
end

# does not allow %Spellout and %Ordinal in the ordinal expression to be mixed
# does not allow %Spellout and %Ordinal in the ordinal expression
# to be mixed
def edition_translate(bibdata)
x = bibdata.at(ns("./edition")) or return
/^\d+$/.match?(x.text) or return
Expand Down Expand Up @@ -221,11 +227,9 @@ def trim_hash(hash)
end

def trim_hash1(hash)
return hash unless hash.is_a? Hash

hash.is_a?(Hash) or return hash
hash.each_with_object({}) do |(k, v), g|
next if blank?(v)

blank?(v) and next
g[k] = case v
when Hash then trim_hash1(hash[k])
when Array
Expand Down
2 changes: 1 addition & 1 deletion lib/isodoc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IsoDoc
VERSION = "2.7.2".freeze
VERSION = "2.7.3".freeze
end

0 comments on commit ea666ea

Please sign in to comment.