lib/csl/style.rb in csl-1.0.0.pre1 vs lib/csl/style.rb in csl-1.0.0.pre2
- old
+ new
@@ -13,28 +13,27 @@
include Loader
attr_accessor :default
def parse(data)
- node = CSL.parse!(data)
+ node = CSL.parse!(data, self)
raise ParseError, "root node is not a style: #{node.inspect}" unless
node.is_a?(self)
node
end
-
end
attr_defaults :version => Schema.version, :xmlns => Schema.namespace
- attr_struct :xmlns, :version, :'style-class', :'default-locale',
+ attr_struct :xmlns, :version, :class, :'default-locale',
:'initialize-with-hyphen', :'page-range-format',
:'demote-non-dropping-particle', *Schema.attr(:name, :names)
- attr_children :'style-options', :info, :locale, :macro, :citation,
- :bibliography
+ attr_children :'style-options', :info, :locale, :macro,
+ :citation, :bibliography
alias metadata info
alias options style_options
alias locales locale
@@ -44,10 +43,22 @@
children[:locale] = []
children[:macro] = []
yield self if block_given?
end
+
+ def validate
+ Schema.validate self
+ end
+ def valid?
+ validate.empty?
+ end
+ private
+
+ def preamble
+ Schema.preamble.dup
+ end
end
end
\ No newline at end of file