recordx-xslt 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/recordx-xslt.rb +47 -8
- metadata +1 -1
- metadata.gz.sig +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a89aecd58a11c79ff2bb5ad89a8a2c7d1673e8d0bfcf5f31cccbe52b6129a3b4
|
4
|
+
data.tar.gz: ef2fc21339bb537f328ddd13032c99d03415e145d5ede468ebae99a42bf847f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f4496159c7d3b0932c84678aa8eb84813ee4e4ff00a66bc2d4001009c578287b0717542b26927e750777f32faa601f08a7f9331b852ea061b5188d2e7d3d1c
|
7
|
+
data.tar.gz: 450e60d17a11d85e06adecfe7ad8d17ab1d1e416584e3c9d5d4007053844b13f3e9440fbebce29b0940fd9d054748c16b556fbf66c3b079f46cc59545aa54111
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/recordx-xslt.rb
CHANGED
@@ -32,7 +32,7 @@ HEADER
|
|
32
32
|
|
33
33
|
a_html = @xslt_schema.split('/').map do |x|
|
34
34
|
|
35
|
-
result = x.match(/(\w+)(?:[\(\[]([^\]\)]+)[\]\)])?(.*)/)
|
35
|
+
result = x.match(/([\w\>]+)(?:[\(\[]([^\]\)]+)[\]\)])?(.*)/)
|
36
36
|
name, children, remaining = result.captures if result
|
37
37
|
|
38
38
|
|
@@ -43,16 +43,39 @@ HEADER
|
|
43
43
|
|
44
44
|
puts ('a_html: ' + a_html.inspect).debug if @debug
|
45
45
|
|
46
|
-
|
46
|
+
rxmap = a_element.zip(a_html)
|
47
|
+
|
48
|
+
a = rxmap.map.with_index do |a,i|
|
47
49
|
|
48
50
|
out = []
|
49
51
|
tag = a.shift
|
52
|
+
puts 'tag: ' + tag.inspect if @debug
|
53
|
+
|
50
54
|
field = i > 0 ? 'records/' + tag : tag
|
51
55
|
out << "<xsl:template match='#{field}'>" + "\n"
|
52
56
|
a.flatten!(1)
|
57
|
+
puts 'a: ' + a.inspect if @debug
|
58
|
+
|
53
59
|
if a.last.is_a? Array then
|
54
60
|
|
55
|
-
|
61
|
+
if @debug then
|
62
|
+
puts 'before scan_e a: ' + a.inspect
|
63
|
+
puts 'before scan_e rxmap: ' + rxmap.inspect
|
64
|
+
puts 'before scan_e rxmap[i+1]: ' + rxmap[i+1].inspect
|
65
|
+
end
|
66
|
+
|
67
|
+
if rxmap[i+1] and rxmap[i+1][1][0] =~ />/ then
|
68
|
+
|
69
|
+
raw_body, rxtag = rxmap[i+1][1][0].split(/>/,2)
|
70
|
+
body = ["<%s>" % raw_body,"</%s>" % raw_body]
|
71
|
+
|
72
|
+
puts 'body: ' + body.inspect if @debug
|
73
|
+
rxmap[i+1][1][0] = rxtag
|
74
|
+
else
|
75
|
+
body = []
|
76
|
+
end
|
77
|
+
|
78
|
+
out << scan_e(a, tag, indent=' ', body)
|
56
79
|
out << "</xsl:template>\n\n"
|
57
80
|
else
|
58
81
|
out << " <%s>\n" % a.first
|
@@ -85,25 +108,41 @@ HEADER
|
|
85
108
|
|
86
109
|
end
|
87
110
|
|
88
|
-
def scan_e(a, prev_tag='', indent=' ')
|
111
|
+
def scan_e(a, prev_tag='', indent=' ', body=[])
|
89
112
|
|
90
113
|
out = []
|
91
114
|
|
92
115
|
unless a.first.is_a? Array then
|
93
116
|
|
94
|
-
|
117
|
+
raw_tags = a.shift
|
118
|
+
|
119
|
+
tags = raw_tags.split('>')
|
120
|
+
start_tags = tags.map {|x| "<%s>" % x }.join
|
121
|
+
end_tags = tags.reverse.map {|x| "</%s>" % x }
|
122
|
+
puts 'end_tags: ' + end_tags.inspect if @debug
|
123
|
+
puts 'body: ' + body.inspect if @debug
|
124
|
+
|
125
|
+
if body.any? then
|
126
|
+
end_tags.insert(-2, body[0])
|
127
|
+
end_tags[-1][0] = body[-1] #+ end_tags.last
|
128
|
+
end
|
129
|
+
puts '2. end_tags: ' + end_tags.inspect if @debug
|
95
130
|
|
96
|
-
|
131
|
+
puts 'prev_tag: ' + prev_tag.inspect if @debug
|
132
|
+
puts '_a: ' + a.inspect if @debug
|
133
|
+
|
134
|
+
out << indent + "%s\n" % start_tags
|
97
135
|
out << indent + " <xsl:apply-templates select='summary'/>\n"
|
136
|
+
out << indent + "%s\n" % end_tags[0..-2].join if end_tags.length > 1
|
98
137
|
out << indent + " <xsl:apply-templates select='records'/>\n"
|
99
|
-
out << indent + "
|
138
|
+
out << indent + "%s\n" % end_tags[-1]
|
100
139
|
out << "</xsl:template>\n\n"
|
101
140
|
out << "<xsl:template match='%s/summary'>\n" % [prev_tag]
|
102
141
|
|
103
142
|
a.flatten!(1)
|
104
143
|
|
105
144
|
if a.last.is_a? Array then
|
106
|
-
out << scan_e(a,
|
145
|
+
out << scan_e(a, tags.last, indent + ' ')
|
107
146
|
else
|
108
147
|
out << indent + ' ' + a.first + "\n"
|
109
148
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
DzB��Ք��g���1���75����M����:Y�h�,@zW�?��*�h���/3VHM4K�p�,=p �� ��&Z߉��0�Zi�ٽ�+'�B��H�V���VP�fZ`
|
1
|
+
�\>��X㶄���]��!0?K��KW ��}�(���^��ĭ�<�֪?��9���~��d�x�8�h��h}(�8�X����t�P.?n~�J�U�3��d��!mN�?:`��/`,��e��l�l�'nɪ�8���,�d���w8�c�����N#�p�
|
2
|
+
����9' ��P�r'�2�
|