From 26767cc88c0548ad7978021796d0ccc4c9f7ffed Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 2 Jun 2007 11:27:06 +0100 Subject: 0.53.0, pre-build, see changelog, library naming changed for scm, placed under v0 (instead of 0.53) --- lib/sisu/v0/xml_format.rb | 339 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 lib/sisu/v0/xml_format.rb (limited to 'lib/sisu/v0/xml_format.rb') diff --git a/lib/sisu/v0/xml_format.rb b/lib/sisu/v0/xml_format.rb new file mode 100644 index 00000000..2db28b25 --- /dev/null +++ b/lib/sisu/v0/xml_format.rb @@ -0,0 +1,339 @@ +=begin + * Name: SiSU information Structuring Universe - Structured information, Serialized Units + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download.html + + * Description: xml template + + * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Ralph Amissah + + * License: GPL 2 or later + + Summary of GPL 2 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + http://www.fsf.org/licenses/gpl.html + http://www.gnu.org/copyleft/gpl.html + http://www.jus.uio.no/sisu/gpl2.fsf + + SiSU was first released to the public on January 4th 2005 + + SiSU uses: + + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + © Ralph Amissah 1997, current 2007. + All Rights Reserved. + + * Ralph Amissah: ralph@amissah.com + ralph.amissah@gmail.com + + * Notes: tidy -xml index.xml >> index.tidy +=end +module SiSU_XML_format + require "#{SiSU_lib}/param" + include SiSU_Param + include SiSU_Viz + class Paragraph_number + def initialize(md,paranum) + @md=md + @paranum=/(\d+)/m.match(paranum)[1] + end + def display + p_num_display=@paranum.gsub(/(\d+)/, + '' + + '  \1') + p_num_display + end + def name + p_num_name=@paranum.gsub(/(\d+)/,'') + p_num_name + end + def goto + p_num_goto=@paranum.gsub(/(\d+)/,'') + p_num_goto + end + end + class Head_information + def initialize #dc rdf + @dc_title=@dc_subtitle=@dc_creator=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@dc_relation=@dc_coverage=@dc_rights=@copyright=@owner=@keywords='' + @sfx,@pdf,@md=@@md.sfx,@@md.pdf,@@md + # DublinCore 1 - title + @rdfurl=%{ rdf:about="http://www.jus.uio.no/lm/toc"\n} + if @md.dc_title + @dc_title=%{\n} + #if @md.subtitle + # #@rdf_title=%{ dc.title="#{seg_name}#{@md.title} - #{@md.subtitle}"\n} + # @dc_title=%{\n} + #else + # #@rdf_title=%{ dc.title="#{seg_name}#{@md.title}"\n} + # @dc_title=%{\n} + #end + end + if @md.dc_creator # DublinCore 2 - creator/author (author) + @rdf_creator=%{ dc.creator="#{@md.dc_creator}"\n} + @dc_creator=%{\n} + end + if @md.dc_subject # DublinCore 3 - subject (us library of congress, eric or udc, or schema???) + @rdf_subject=%{ dc.subject="#{@md.dc_subject}"\n} + @dc_subject=%{\n} + end + if @md.dc_description # DublinCore 4 - description + @rdf_description=%{ dc.description="#{@md.description}"\n} + @dc_description=%{\n} + end + if @md.dc_publisher # DublinCore 5 - publisher (current copy published by) + @rdf_publisher=%{ dc.publisher="#{@md.dc_publisher}"\n} + @dc_publisher=%{\n} + end + if @md.dc_contributor # DublinCore 6 - contributor + @rdf_contributor=%{ dc.contributor="#{@md.dc_contributor}"\n} + @dc_contributor=%{\n} + end + if @md.dc_date # DublinCore 7 - date year-mm-dd + @rdf_date=%{ dc.date="#{@md.dc_date}"\n} + @dc_date=%{\n} + end + if @md.dc_date_created # DublinCore 7 - date.created year-mm-dd + @rdf_date_created=%{ dc.date.created="#{@md.dc_date_created}"\n} + @dc_date_created=%{\n} + end + if @md.dc_date_issued # DublinCore 7 - date.issued year-mm-dd + @rdf_date_issued=%{ dc.date.issued="#{@md.dc_date_issued}"\n} + @dc_date_issued=%{\n} + end + if @md.dc_date_available # DublinCore 7 - date.available year-mm-dd + @rdf_date_available=%{ dc.date.available="#{@md.dc_date_available}"\n} + @dc_date_available=%{\n} + end + if @md.dc_date_valid # DublinCore 7 - date.valid year-mm-dd + @rdf_date_valid=%{ dc.date.valid="#{@md.dc_date_valid}"\n} + @dc_date_valid=%{\n} + end + if @md.dc_date_modified # DublinCore 7 - date.modified year-mm-dd + @rdf_date_modified=%{ dc.date.modified="#{@md.dc_date_modified}"\n} + @dc_date_modified=%{\n} + end + if @md.dc_type # DublinCore 8 - type (genre eg. report, convention etc) + @rdf_type=%{ dc.type="#{@md.dc_type}"\n} + @dc_type=%{\n} + end + if @md.dc_format # DublinCore 9 - format (use your mime type) + @rdf_format=%{ dc.format="#{@md.dc_format}"\n} + @dc_format=%{\n} + end + if @md.dc_identifier # DublinCore 10 - identifier (your identifier, could use urn which is free) + @rdf_identifier=%{ dc.identifier="#{@md.dc_identifier}"\n} + @dc_identifier=%{\n} + end + if @md.dc_source # DublinCore 11 - source (document source) + @rdf_source=%{ dc.source="#{@md.dc_source}"\n} + @dc_source=%{\n} + end + if @md.dc_language[:name] # DublinCore 12 - language (English) + @rdf_language=%{ dc.language="#{@md.dc_language[:name]}"\n} + @dc_language=%{\n} + end + if @md.language_original[:name] # DublinCore 12 - language (English) + @rdf_language_original=%{ dc.language="#{@md.language_original[:name]}"\n} + @language_original=%{\n} + end + if @md.dc_relation # DublinCore 13 - relation + @rdf_relation=%{ dc.relation="#{@md.dc_relation}"\n} + @dc_relation=%{\n} + end + if @md.dc_coverage # DublinCore 14 - coverage + @rdf_coverage=%{ dc.coverage="#{@md.dc_coverage}"\n} + @dc_coverage=%{\n} + end + if @md.dc_rights # DublinCore 15 - rights + @rdf_rights=%{ dc.rights="#{@md.dc_rights}"\n} + @dc_rights=%{\n} + end + @copyright=%{\n} if @md.rights # possibly redundant see dc.rights + @owner=%{\n} if @md.owner + @keywords=%{\n} if @md.keywords + @vz=SiSU_Env::Get_init.instance.skin #margin,paragraph,table,banner,url,png,txt,color,font,nav_txt,nav_png,credits,js,php + @index=case @md.file_type + when /php/; 'index' # @index="index.php" + else 'index' + end + end + def toc_head_escript #embedded script in this case PHP + # %{

PHP or other embedded script for object persistence may go HERE

} + end + #def seg_head_escript #embedded script in this case PHP + # # %{

PHP or other embedded script for object persistence may go HERE

} + #end + def table_close + ' ' + end + def buttons_home + %{\n#{@banner.home_and_index_buttons}\n} + end + def copyat + %{copy @
#{@txt.home}} + end + def toc_head + # + # + # + #Dublin Core + < + +#{@md.html_title} + + + +#@dc_title +#@dc_creator +#@dc_subject +#@dc_description +#@dc_publisher +#@dc_contributor +#@dc_date +#@dc_date_created +#@dc_date_issued +#@dc_date_available +#@dc_date_valid +#@dc_date_modified +#@dc_type +#@dc_format +#@dc_identifier +#@dc_source +#@dc_language +#@dc_relation +#@dc_coverage +#@dc_rights +#@copyright +#@owner +#{@png.ico} +#{@txt.generator} +#{@js.head} +\n +#{@color.body} +#{@font.css_table_file} + + + +#{@js.top} +WOK + end + end + class Format_text_object + @@dp=nil + attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped + def initialize(md,*txt) + @md=md + txt[0].gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ + @one,@two,@three=txt[0],txt[1],txt[2] + @format,@parablock=txt[0],txt[1] + if txt[2]=~/\d+/ + @paranum=/(\d+)/m.match(txt[2])[1] + @headname='' + #if txt[2]=~/\d+/ + m=/\d~(\S+)/m.match(format) + headname=m[1] if m + @headname=%{} unless headname.nil? + @p_num=SiSU_XML_format::Paragraph_number.new(@md,@paranum) + end + #{ + rgx=/^[1-6-]~{1,2}/ #watch + link=txt[0].gsub(rgx,'') if @one =~rgx + @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + rgx=/~\{\d+\s+(.+?)<#@dp>\}~/ + link=txt[0].gsub(rgx,'\1') if txt[0] =~rgx + @link,@linkname=link,txt[1] + @vz=SiSU_Env::Get_init.instance.skin + end + def scr_endnote_body + "#@one " + end + end + class Format_scroll < Format_text_object + def initialize(*txt) + super(*txt) + end + def heading_body + %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.display}

\n} + end + def heading_body1 + %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.display}

\n} + end + def heading_body2 + %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.display}

\n} + end + def heading_body3 + %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.display}

\n} + end + def heading_body4 + %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.display}

\n} + end + def heading_body5 + %{
#{@p_num.name}#@headname#@parablock
} + + %{

#{@p_num.display}

\n} + end + def heading_body6 + %{
#{@p_num.name}#@headname#@parablock
} + + %{

#{@p_num.display}

\n} + end + end + class XML + end +end +__END__ + -- cgit v1.2.3