(in-package "KPML")

;;; File: xml-loaders.lisp
;;; John Bateman
;;; File created: Bremen, September 2002
;;; KPML 4.0

;;; ----------------------------------------------------------------------
;;; One big jump for KPML 4.0 is being able to load files that are
;;; structured by XML and which are written in Unicode. This allows
;;; us to generate, for example, the Chinese examples properly.
;;; Firstly, loading Unicode files is made transparent for lexicon
;;; files so that they are recognised without the user doing
;;; anything about them. Secondly, we have explicit mode setting
;;; for expecting XML-structured Lexicons. 
;;;
;;; But we do recognise when XML should happen
;;; silently too...  which will only work at present in the case 
;;; that the XML file is also a lexicon.
;;; ----------------------------------------------------------------------

;;; Version 1.0 beta
;;; We start with something relative simple, but which makes a lot of
;;; difference to how things look--i.e., using XML-based Unicode Lexicons.
;;; Bremen, September 2002


  ;; At present, manage the objects that are desired to be in XML
  ;; by placing them on the following list. Only :lexeme currently
  ;; supported for input.
(defvar *kpml-xml-object-list* '(:lexeme))

(defun XML-MODE (object-type)
  (member object-type *kpml-xml-object-list*))


;;; ----------------------------------------------------------------------
;;; Lexicon processing...
;;; ......................................................................

  ;; Process the XML lexicon files, either as Unicode or Not as they
  ;; have been saved. If some weird character coding is selected, it
  ;; will probably break. Safest to stick to ASCII, European, or UTF-8.
  ;; This should at some stage be done with standard lisp XML input
  ;; processing routines, but such are not available in LWW4.1 nor
  ;; in ANSI-CL, so wing it. Essentially, we put together a standard
  ;; call to the load-ml-lexicon function out of the bits and pieces
  ;; we pick out of the XML.
  ;;
  ;; Tries to avoid blowing up during compilation if someone loads this
  ;; without having loaded CL-XML.

(defun KPML-XML-LEXICON-LOAD (file)
  (cond ((find-package "XML-PARSER")
	 (let ((docnode 
		(apply (find-symbol "DOCUMENT-PARSER" 
				    (find-package "XML-PARSER"))
		       `(,(pathname file) :trace nil))))
	   (apply (find-symbol "DOM-LEXICON->KPML" 
			       (find-package "XML-PARSER"))
		  (list docnode))
	   T))
	(t
	 (warning "No XML processing package installed!!")
	 (return-from KPML-XML-LEXICON-LOAD NIL))))


