繼我爲最後一個問題提供的答案How to inject elements into character content with Closure XML?我實現了cxml:sax-proxy處理程序(廣播處理程序的特例)的子類。不幸的是,它看起來像庫中的一個錯誤,但它試圖用內部文檔類型定義生成XML,但該文檔是無效的XML。Common Lisp Closure XML包中的廣播處理程序的無效輸出
即,運行與所述命令解析器:
(with-open-file (out #P"teste.xml" :if-exists :supersede :direction :output)
(let ((h (make-instance 'preproc :chained-handler (cxml:make-character-stream-sink out))))
(cxml:parse #P"harem.xml" h :validate t)))
其中文件harem.xml開始(參見文檔類型):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE colHAREM SYSTEM "harem.dtd">
<colHAREM versao="Segundo_dourada_com_relacoes_14Abril2010">
<DOC DOCID="H2-dftre765">
<p>...
命令在teste.xml產生輸出文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE colHAREM SYSTEM "harem.dtd"<!ELEMENT EM #PCDATA>
<!ATTLIST EM ID CDATA #REQUIRED>
<!ATTLIST EM CATEG CDATA #IMPLIED>
<!ATTLIST EM TIPO CDATA #IMPLIED>
<!ATTLIST EM COMENT CDATA #IMPLIED>
<!ATTLIST EM SUBTIPO CDATA #IMPLIED>
<!ELEMENT ALT (#PCDATA|EM)*>
<!ELEMENT OMITIDO (#PCDATA|EM|ALT|p)*>
<!ELEMENT colHAREM (DOC)*>
<!ATTLIST colHAREM versao CDATA #REQUIRED>
<!ELEMENT p (#PCDATA|EM|OMITIDO|ALT)*>
<!ATTLIST p xml:space (default|preserve) "default">
<!ELEMENT DOC (#PCDATA|p|OMITIDO)*>
<!ATTLIST DOC DOCID CDATA #REQUIRED>
>
<colHAREM versao="Segundo_dourada_com_relacoes_14Abril2010">
...
也就是說,處理程序在輸出中寫入DTD,但以錯誤的方式寫入,wi不包括[
和]
內的聲明。這是圖書館或我的代碼中的錯誤嗎?