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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 531d10bd42deb16c83caf1d4f3beb6da9e1ec6cb9f88281ce7b93737c1dfc0b0
4
- data.tar.gz: a4d34afe21106986a29a2de16c6d3d25df816da6b8cec0154b85394711e0095e
3
+ metadata.gz: a89aecd58a11c79ff2bb5ad89a8a2c7d1673e8d0bfcf5f31cccbe52b6129a3b4
4
+ data.tar.gz: ef2fc21339bb537f328ddd13032c99d03415e145d5ede468ebae99a42bf847f6
5
5
  SHA512:
6
- metadata.gz: f6a3eb1435df8e8d89624d79ea8ec08e04df0aca249056e84f5555e449a7a47f290267a9b9144113fcf9b5e8489822121d7da7d84188a7e7a05f767069e66208
7
- data.tar.gz: 1f273f78518584972476dddbebc3b97e72d00d4a7f1cc5173e0416995b52887d57b9d60b226aebd4385b100d8269b3aff801f825955d7a8db8c176b6fffb5772
6
+ metadata.gz: 48f4496159c7d3b0932c84678aa8eb84813ee4e4ff00a66bc2d4001009c578287b0717542b26927e750777f32faa601f08a7f9331b852ea061b5188d2e7d3d1c
7
+ data.tar.gz: 450e60d17a11d85e06adecfe7ad8d17ab1d1e416584e3c9d5d4007053844b13f3e9440fbebce29b0940fd9d054748c16b556fbf66c3b079f46cc59545aa54111
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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
- a = a_element.zip(a_html).map.with_index do |a,i|
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
- out << scan_e(a, tag)
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
- tag = a.shift
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
- out << indent + "<%s>\n" % tag
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 + "</%s>\n" % tag
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, tag, indent + ' ')
145
+ out << scan_e(a, tags.last, indent + ' ')
107
146
  else
108
147
  out << indent + ' ' + a.first + "\n"
109
148
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordx-xslt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- v"�K)�C2jFU�^�h+k��W��Z�?�!��[jY �8��C$
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�