I've been trying to use the CXML catalog feature, but so far I haven't had any success. Is there something that I am doing that is obviously wrong?
Things such as:
(setf cxml:*catalog* (cxml:make-catalog)) (cxml:resolve-extid "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" cxml:*catalog*)
Return NIL, when using the Debian /etc/xml/catalog
I've checked and it's in there under a few lines of delegates, so I tried making my own:
<?xml version='1.0'?> <!DOCTYPE catalog PUBLIC "-//GlobalTransCorp//DTD XML Catalogs V1.0-Based Extension V1.0//EN" "http://globaltranscorp.org/oasis/catalog/xml/tr9401.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:soc="urn:oasis:names:tc:entity:xmlns:tr9401:catalog" xmlns:unk="urn:oasis:names:tc:entity:xmlns:unknown" > <group prefer="public"> <public publicId="-//W3C//DTD XHTML 1.1//EN" uri="/usr/share/xml/xhtml/schema/dtd/1.1/xhtml11-flat.dtd"/> <soc:dtddecl publicId="-//W3C//DTD XHTML 1.1//EN" uri="/usr/share/xml/xhtml/schema/dtd/1.1/xml1.dcl"/> </group> </catalog>
Passing that file to cxml:make-catalog and doing the same thing, but resolve-extid still comes back with NIL.
Thank you very much
Quoting Adam C. Emerson (aemerson@acm.org):
I've been trying to use the CXML catalog feature, but so far I haven't had any success. Is there something that I am doing that is obviously wrong?
No, that catalog file looks fine. This is obviously an under-tested feature in CXML...
Three issues:
1. The catalog spec demands that errors encountered while parsing the catalog file are to be ignored, thereby obscuring problem #2. 2. The catalog format is specified with Schema (for namespace support), not actually with a DTD. Since CXML doesn't have Schema support yet, I decided back then to validate against the DTD instead, against the advice to the contrary in the spec. I should have have known better -- your file fails DTD validation despite probably being correct (due to the extra namespace declarations not allowed by the DTD). 3. And then there's also an obvious bug in <group> handling in CXML...
Can you try the attached patch? It disables validation (more of a workaround than a solution, but probably better than nothing for now) and fixes bug #3.
Thanks, David
On Mon, Jan 09, 2006 at 01:14:11AM +0100, David Lichteblau wrote:
No, that catalog file looks fine. This is obviously an under-tested feature in CXML...
Three issues:
- The catalog spec demands that errors encountered while parsing the catalog file are to be ignored, thereby obscuring problem #2.
- The catalog format is specified with Schema (for namespace support), not actually with a DTD. Since CXML doesn't have Schema support yet, I decided back then to validate against the DTD instead, against the advice to the contrary in the spec. I should have have known better -- your file fails DTD validation despite probably being correct (due to the extra namespace declarations not allowed by the DTD).
- And then there's also an obvious bug in <group> handling in CXML...
Can you try the attached patch? It disables validation (more of a workaround than a solution, but probably better than nothing for now) and fixes bug #3.
Thanks, David
No, it gives an error:
An attempt to access an array of element-type NIL was made. Congratulations! [Condition of type SB-KERNEL:NIL-ARRAY-ACCESSED-ERROR]
See also: Common Lisp Hyperspec, UPGRADED-ARRAY-ELEMENT-TYPE [function] Common Lisp Hyperspec, 15.1.2.1 [section] Common Lisp Hyperspec, 15.1.2.2 [section]
Restarts: 0: [ABORT-REQUEST] Abort handling SLIME request. 1: [ABORT] Exit debugger, returning to top level.
Backtrace: 0: (PURI::ESCAPE-P #<unavailable argument>) 1: (PURI:PARSE-URI #<unavailable argument> :CLASS #<unavailable argument>) 2: ((FLET CXML::GETURI) "uri") 3: ((SB-PCL::FAST-METHOD SAX:START-ELEMENT (CXML::CATALOG-PARSER T T T T)) #<unavailable argument> #<unavailable argument> #<CXML::CATALOG-PARSER {10052EF001}> #<unavailable argument> "public" "public" (#S(SAX::ATTRIBUTE :NAMESPACE-URI NIL :LOCAL-NAME NIL :QNAME "uri" :VALUE "xhtml11-flat.dtd" :SPECIFIED-P T) #S(SAX::ATTRIBUTE :NAMESPACE-URI NIL :LOCAL-NAME NIL :QNAME "publicId" :VALUE "-//W3C//DTD XHTML 1.1//EN" :SPECIFIED-P T))) 4: (CXML::P/ELEMENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>))) 5: (CXML::P/CONTENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>))) 6: (CXML::P/ELEMENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>))) 7: (CXML::P/CONTENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>))) 8: (CXML::P/ELEMENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>))) 9: (CXML::P/DOCUMENT #S(CXML::ZSTREAM :TOKEN-CATEGORY NIL :TOKEN-SEMANTIC NIL :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]>)) #<CXML::RECODER {10052EF151}> :VALIDATE NIL :DTD #S(CXML::EXTID :PUBLIC NIL :SYSTEM #<URI http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd%3E) :ROOT "catalog" :ENTITY-RESOLVER #<CLOSURE (FLET CXML::ENTITY-RESOLVER) {10052ECC19}> :DISALLOW-INTERNAL-SUBSET NIL :RECODE T) 10: (CXML::PARSE-XSTREAM #<RUNES:XSTREAM [main document :MAIN file://+/usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml]> #<CXML::RECODER {10052EF151}> :VALIDATE NIL :DTD #S(CXML::EXTID :PUBLIC NIL :SYSTEM #<URI http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd%3E) :ROOT "catalog" :ENTITY-RESOLVER #<CLOSURE (FLET CXML::ENTITY-RESOLVER) {10052ECC19}>) 11: (CXML::PARSE-CATALOG-FILE/STRICT #<URI /usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml>) 12: (CXML::PARSE-CATALOG-FILE #<URI /usr/share/xml/xhtml/schema/dtd/1.1/catalog.xml>) 13: (CXML::FIND-CATALOG-FILE #<unavailable argument> #S(CXML::CATALOG :MAIN-FILES (#S(CXML::ENTRY-FILE :SYSTEM-ENTRIES NIL :REWRITE-SYSTEM-ENTRIES NIL :DELEGATE-SYSTEM-ENTRIES # :PUBLIC-ENTRIES NIL :DELEGATE-PUBLIC-ENTRIES # :URI-ENTRIES NIL :REWRITE-URI-ENTRIES NIL :DELEGATE-URI-ENTRIES # :NEXT-CATALOG-ENTRIES NIL)) :DTD-CACHE #<HASH-TABLE :TEST EQL :COUNT 1 {1004071061}> :FILE-TABLE #<HASH-TABLE :TEST EQL :COUNT 2 {1004078AF1}>)) 14: (CXML:RESOLVE-EXTID #<unavailable argument> #<unavailable argument> #S(CXML::CATALOG :MAIN-FILES (#S(CXML::ENTRY-FILE :SYSTEM-ENTRIES NIL :REWRITE-SYSTEM-ENTRIES NIL :DELEGATE-SYSTEM-ENTRIES # :PUBLIC-ENTRIES NIL :DELEGATE-PUBLIC-ENTRIES # :URI-ENTRIES NIL :REWRITE-URI-ENTRIES NIL :DELEGATE-URI-ENTRIES # :NEXT-CATALOG-ENTRIES NIL)) :DTD-CACHE #<HASH-TABLE :TEST EQL :COUNT 1 {1004071061}> :FILE-TABLE #<HASH-TABLE :TEST EQL :COUNT 2 {1004078AF1}>)) 15: (SB-INT:EVAL-IN-LEXENV (CXML:RESOLVE-EXTID "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" CXML:*CATALOG*) #<NULL-LEXENV>) 16: (SWANK::EVAL-REGION "(cxml:RESOLVE-EXTID "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%5C" cxml:*catalog*) " T) 17: ((LAMBDA NIL)) 18: ((SB-PCL::FAST-METHOD SWANK-BACKEND:CALL-WITH-SYNTAX-HOOKS (T)) #<unused argument> #<unused argument> #<CLOSURE (LAMBDA NIL) {1004230B99}>) 19: (SWANK::CALL-WITH-BUFFER-SYNTAX #<CLOSURE (LAMBDA NIL) {1004230B99}>) 20: (SB-INT:EVAL-IN-LEXENV (SWANK:LISTENER-EVAL "(cxml:RESOLVE-EXTID "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%5C" cxml:*catalog*) ") #<NULL-LEXENV>) 21: ((LAMBDA NIL)) 22: ((SB-PCL::FAST-METHOD SWANK-BACKEND:CALL-WITH-DEBUGGER-HOOK (T T)) #<unused argument> #<unused argument> #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL) {1004230349}>) 23: ((LAMBDA NIL)) 24: ((LAMBDA NIL)) 25: (SWANK::CALL-WITH-REDIRECTED-IO #<SWANK::CONNECTION {1002A86F01}> #<CLOSURE (LAMBDA NIL) {100421FDD9}>) 26: (SWANK::CALL-WITH-CONNECTION #<SWANK::CONNECTION {1002A86F01}> #<FUNCTION (LAMBDA NIL) {10031B6C99}>) 27: (SWANK::HANDLE-REQUEST #<SWANK::CONNECTION {1002A86F01}>) 28: (SWANK::PROCESS-AVAILABLE-INPUT #<SB-SYS:FD-STREAM for "a constant string" {1002A7C801}> #<CLOSURE (LAMBDA NIL) {100421FDB9}>) 29: ((FLET SWANK::HANDLER)) 30: ((LAMBDA (SWANK-BACKEND::_)) #<unused argument>) 31: (SB-IMPL::SUB-SERVE-EVENT NIL 0) 32: (SB-SYS:WAIT-UNTIL-FD-USABLE 0 :INPUT NIL) 33: (SB-IMPL::REFILL-BUFFER/FD #<SB-SYS:FD-STREAM for "standard input" {1002326A01}>) 34: (SB-IMPL::INPUT-CHAR/UTF-8 #<SB-SYS:FD-STREAM for "standard input" {1002326A01}> NIL #:EOF-OBJECT) 35: (READ-CHAR #<SB-SYS:FD-STREAM for "standard input" {1002326A01}> NIL #:EOF-OBJECT #<unused argument>) 36: (READ-CHAR #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {1000198211}> NIL #:EOF-OBJECT #<unused argument>) 37: (READ-CHAR #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {1002901171}> NIL #:EOF-OBJECT #<unused argument>) 38: (READ-PRESERVING-WHITESPACE #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {1002901171}> NIL (NIL) T) 39: (READ-PRESERVING-WHITESPACE #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {1002901171}> NIL (NIL) NIL) 40: (READ #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {1002901171}> NIL (NIL) NIL) 41: (SB-IMPL::REPL-READ-FORM-FUN #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {1002901171}> #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-OUTPUT* {10029012C1}>) 42: (SB-IMPL::REPL-FUN NIL) 43: ((LAMBDA NIL)) 44: ((LAMBDA NIL)) 45: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<CLOSURE (LAMBDA NIL) {1002393009}>) 46: (SB-IMPL::TOPLEVEL-REPL NIL) 47: (SB-IMPL::TOPLEVEL-INIT) 48: ((LABELS SB-IMPL::RESTART-LISP))
I am using the CVS version of CXML, however, so I had to modify the patch slightly (just the first hunk, changing parser-error to xml-parse-error) to get it to apply.
Quoting Adam C. Emerson (aemerson@acm.org):
An attempt to access an array of element-type NIL was made. Congratulations! [Condition of type SB-KERNEL:NIL-ARRAY-ACCESSED-ERROR]
Heh.
Well, the puri library was apparently written by someone trying to maximize speed at all cost. It doesn't work with non-simple strings.
Here's a second attempt at the patch, including a workaround for that.
I'm also attaching an unrelated patch to puri, which you might need if you're running a very current SBCL. (puri uses sb-kernel:shrink-vector, which is not exactly a supported interface in SBCL and has recently changed behaviour.)