dynarex 1.1.29 → 1.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/dynarex.rb +15 -13
  2. metadata +1 -1
@@ -276,23 +276,25 @@ EOF
276
276
 
277
277
  def to_xslt(opt={})
278
278
  h = {limit: -1}.merge(opt)
279
- xslt = DynarexXSLT.new(schema: @schema, xslt_schema: @xslt_schema).to_xslt
280
-
281
- if h[:limit] > 0 then
282
- s = "[position() < #{h[:limit]}]"
283
- doc = Rexle.new(xslt)
284
- e = doc.root.element('xsl:template/channel/*[2]')
285
- e.attributes[:select] = e.attributes[:select] + s
286
- return doc.xml pretty: true
287
- end
288
-
279
+ xslt = DynarexXSLT.new(schema: @schema, xslt_schema: @xslt_schema).to_xslt
289
280
  return xslt
290
281
  end
291
282
 
292
283
  def to_rss(opt={}, xslt=nil)
293
- xslt ||= self.to_xslt(opt)
294
- xml = Rexslt.new(xslt, self.to_xml).to_xml
295
- "<rss version='2.0'>%s</rss>" % xml
284
+
285
+ unless xslt then
286
+ h = {limit: 11}.merge(opt)
287
+ doc = Rexle.new(self.to_xslt)
288
+ e = doc.element('//xsl:apply-templates[2]')
289
+ v = e.attributes[:select]
290
+ e.attributes[:select] = v + "[position() &lt; #{h[:limit]}]"
291
+ doc2 = Rexle.new "<xsl:sort order='descending' data-type='number' select='@id'/>"
292
+ e.add doc2.root
293
+ xslt = doc.xml
294
+ end
295
+
296
+ xml = Rexslt.new(xslt, self.to_xml).to_s
297
+ Rexle.new("<rss version='2.0'>%s</rss>" % xml).xml(pretty: true)
296
298
  end
297
299
 
298
300
  def xpath(x)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.29
5
+ version: 1.1.30
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson