onix 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/onix.rb +1 -1
- data/lib/onix/normaliser.rb +6 -9
- data/spec/normaliser_spec.rb +1 -0
- data/support/switch-onix-2.1-short-to-reference.xsl +23 -0
- metadata +2 -1
data/CHANGELOG
CHANGED
data/lib/onix.rb
CHANGED
data/lib/onix/normaliser.rb
CHANGED
@@ -39,10 +39,10 @@ module ONIX
|
|
39
39
|
def initialize(oldfile, newfile)
|
40
40
|
raise ArgumentError, "#{oldfile} does not exist" unless File.file?(oldfile)
|
41
41
|
raise ArgumentError, "#{newfile} already exists" if File.file?(newfile)
|
42
|
-
raise "
|
43
|
-
raise "isutf8 app not found"
|
44
|
-
raise "iconv app not found"
|
45
|
-
raise "sed app not found"
|
42
|
+
raise "xsltproc app not found" unless app_available?("xsltproc")
|
43
|
+
raise "isutf8 app not found" unless app_available?("isutf8")
|
44
|
+
raise "iconv app not found" unless app_available?("iconv")
|
45
|
+
raise "sed app not found" unless app_available?("sed")
|
46
46
|
|
47
47
|
@oldfile = oldfile
|
48
48
|
@newfile = newfile
|
@@ -98,11 +98,8 @@ module ONIX
|
|
98
98
|
def to_reference_tags(src, dest)
|
99
99
|
inpath = File.expand_path(src)
|
100
100
|
outpath = File.expand_path(dest)
|
101
|
-
xsltpath = File.dirname(__FILE__) + "/../../support/switch-onix-
|
102
|
-
|
103
|
-
# saxon instead.
|
104
|
-
#`xsltproc -o #{outpath} #{xsltpath} #{inpath}`
|
105
|
-
`java -jar /usr/share/java/saxon.jar #{inpath} #{xsltpath} > #{outpath}`
|
101
|
+
xsltpath = File.dirname(__FILE__) + "/../../support/switch-onix-2.1-short-to-reference.xsl"
|
102
|
+
`xsltproc -o #{outpath} #{xsltpath} #{inpath}`
|
106
103
|
end
|
107
104
|
|
108
105
|
# ensure the file is valid utf8, then make sure it's declared as such
|
data/spec/normaliser_spec.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
|
3
|
+
<xsl:variable name="target"><xsl:choose>
|
4
|
+
<xsl:when test="/ONIXMessage">short</xsl:when>
|
5
|
+
<xsl:otherwise>reference</xsl:otherwise>
|
6
|
+
</xsl:choose></xsl:variable>
|
7
|
+
<xsl:output method="xml" doctype-system="http://www.editeur.org/onix/2.1/reference/onix-international.dtd"/>
|
8
|
+
<xsl:template match="*">
|
9
|
+
<xsl:variable name="target-name">
|
10
|
+
<xsl:choose>
|
11
|
+
<xsl:when test="$target='short'"><xsl:value-of select="@shortname"/></xsl:when>
|
12
|
+
<xsl:otherwise><xsl:value-of select="@refname"/></xsl:otherwise>
|
13
|
+
</xsl:choose>
|
14
|
+
</xsl:variable>
|
15
|
+
<xsl:element name="{$target-name}">
|
16
|
+
<xsl:copy-of select="@*[not(name()='refname' or name()='shortname')]"/>
|
17
|
+
<xsl:apply-templates select="*|text()"/>
|
18
|
+
</xsl:element>
|
19
|
+
</xsl:template>
|
20
|
+
<xsl:template match="text()">
|
21
|
+
<xsl:copy/>
|
22
|
+
</xsl:template>
|
23
|
+
</xsl:stylesheet>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- support/switch-onix-tagnames-1.1.xsl
|
112
112
|
- support/extract.rb
|
113
113
|
- support/entities.txt
|
114
|
+
- support/switch-onix-2.1-short-to-reference.xsl
|
114
115
|
- spec/header_spec.rb
|
115
116
|
- spec/product_spec.rb
|
116
117
|
- spec/reader_spec.rb
|