Class: FileTypeXML

Inherits:
FileType show all
Defined in:
lib/ontomde-core/fileTypes.rb

Direct Known Subclasses

FileTypeXSD

Constant Summary collapse

URI_ESCAPE_CHAR_ONE =

a character that can not exist in a URI

'°'

Instance Attribute Summary

Attributes inherited from FileType

#re_begin, #re_end

Instance Method Summary collapse

Methods inherited from FileType

#beginMarkerSkip, #endMarkerSkip, getFileType

Constructor Details

#initialize(ext = '.xml') ⇒ FileTypeXML

Returns a new instance of FileTypeXML.



79
80
81
82
83
# File 'lib/ontomde-core/fileTypes.rb', line 79

def initialize(ext='.xml')
  super(ext)
  @re_begin=/^[ \t]*<\!-- *XMDA BEGIN +reverse="([^"]*)" uri="([^"]*)" *-->/
  @re_end=/^[ \t]*<\!-- *XMDA END +uri="([^"]*)" *-->/
end

Instance Method Details

#beginMarker(uri, reverse) ⇒ Object



87
88
89
# File 'lib/ontomde-core/fileTypes.rb', line 87

def beginMarker(uri,reverse)
  return %{\n<!-- XMDA BEGIN reverse="#{reverse ? 'yes':'no'}" uri="#{escape(uri)}" -->\n}
end

#endMarker(uri) ⇒ Object



90
91
92
# File 'lib/ontomde-core/fileTypes.rb', line 90

def endMarker(uri)
  return %{\n<!-- XMDA END   uri="#{escape(uri)}" -->\n}
end

#escape(txt) ⇒ Object



93
94
95
# File 'lib/ontomde-core/fileTypes.rb', line 93

def escape(txt)
  return txt.tr('-',URI_ESCAPE_CHAR_ONE)
end

#unescape(txt) ⇒ Object



96
97
98
# File 'lib/ontomde-core/fileTypes.rb', line 96

def unescape(txt)
  return txt.tr(URI_ESCAPE_CHAR_ONE,'-')
end

#writeComment(str, writer) ⇒ Object



84
85
86
# File 'lib/ontomde-core/fileTypes.rb', line 84

def writeComment(str,writer)
  writer.write("<!-- #{str} -->")
end