aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMark A. Hershberger2006-02-02 01:02:31 +0000
committerMark A. Hershberger2006-02-02 01:02:31 +0000
commit5178753d3175190585364a4da85b4e5c8e0671af (patch)
tree924365b8348ac31f0dc02a8807294d33a8d02f2a /lisp
parent5a286ce9e65334aed7383061d95320333c604969 (diff)
downloademacs-5178753d3175190585364a4da85b4e5c8e0671af.tar.gz
emacs-5178753d3175190585364a4da85b4e5c8e0671af.zip
fixing bug report
Diffstat (limited to 'lisp')
-rw-r--r--lisp/xml.el132
1 files changed, 66 insertions, 66 deletions
diff --git a/lisp/xml.el b/lisp/xml.el
index 5b83f4d3479..444b8c62a7f 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -188,62 +188,62 @@ If PARSE-NS is non-nil, then QNAMES are expanded."
188(defvar xml-att-def-re) 188(defvar xml-att-def-re)
189(let* ((start-chars (concat "[:alpha:]:_")) 189(let* ((start-chars (concat "[:alpha:]:_"))
190 (name-chars (concat "-[:digit:]." start-chars)) 190 (name-chars (concat "-[:digit:]." start-chars))
191;;[3] S ::= (#x20 | #x9 | #xD | #xA)+ 191 ;;[3] S ::= (#x20 | #x9 | #xD | #xA)+
192 (whitespace "[ \t\n\r]")) 192 (whitespace "[ \t\n\r]"))
193;;[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] 193 ;;[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6]
194;; | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] 194 ;; | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF]
195;; | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] 195 ;; | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF]
196;; | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] 196 ;; | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
197 (defvar xml-name-start-char-re (concat "[" start-chars "]")) 197 (defvar xml-name-start-char-re (concat "[" start-chars "]"))
198;;[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] 198 ;;[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
199 (defvar xml-name-char-re (concat "[" name-chars "]")) 199 (defvar xml-name-char-re (concat "[" name-chars "]"))
200;;[5] Name ::= NameStartChar (NameChar)* 200 ;;[5] Name ::= NameStartChar (NameChar)*
201 (defvar xml-name-re (concat xml-name-start-char-re xml-name-char-re "*")) 201 (defvar xml-name-re (concat xml-name-start-char-re xml-name-char-re "*"))
202;;[6] Names ::= Name (#x20 Name)* 202 ;;[6] Names ::= Name (#x20 Name)*
203 (defvar xml-names-re (concat xml-name-re "\\(?: " xml-name-re "\\)*")) 203 (defvar xml-names-re (concat xml-name-re "\\(?: " xml-name-re "\\)*"))
204;;[7] Nmtoken ::= (NameChar)+ 204 ;;[7] Nmtoken ::= (NameChar)+
205 (defvar xml-nmtoken-re (concat xml-name-char-re "+")) 205 (defvar xml-nmtoken-re (concat xml-name-char-re "+"))
206;;[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)* 206 ;;[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
207 (defvar xml-nmtokens-re (concat xml-nmtoken-re "\\(?: " xml-name-re "\\)*")) 207 (defvar xml-nmtokens-re (concat xml-nmtoken-re "\\(?: " xml-name-re "\\)*"))
208;;[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';' 208 ;;[66] CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'
209 (defvar xml-char-ref-re "\\(?:&#[0-9]+;\\|&#x[0-9a-fA-F]+;\\)") 209 (defvar xml-char-ref-re "\\(?:&#[0-9]+;\\|&#x[0-9a-fA-F]+;\\)")
210;;[68] EntityRef ::= '&' Name ';' 210 ;;[68] EntityRef ::= '&' Name ';'
211 (defvar xml-entity-ref (concat "&" xml-name-re ";")) 211 (defvar xml-entity-ref (concat "&" xml-name-re ";"))
212;;[69] PEReference ::= '%' Name ';' 212 ;;[69] PEReference ::= '%' Name ';'
213 (defvar xml-pe-reference-re (concat "%" xml-name-re ";")) 213 (defvar xml-pe-reference-re (concat "%" xml-name-re ";"))
214;;[67] Reference ::= EntityRef | CharRef 214 ;;[67] Reference ::= EntityRef | CharRef
215 (defvar xml-reference-re (concat "\\(?:" xml-entity-ref "\\|" xml-char-ref-re "\\)")) 215 (defvar xml-reference-re (concat "\\(?:" xml-entity-ref "\\|" xml-char-ref-re "\\)"))
216;;[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" 216 ;;[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
217 (defvar xml-att-value-re (concat "\\(?:\"\\(?:[^&\"]\\|" xml-reference-re "\\)*\"\\|" 217 (defvar xml-att-value-re (concat "\\(?:\"\\(?:[^&\"]\\|" xml-reference-re "\\)*\"\\|"
218 "'\\(?:[^&']\\|" xml-reference-re "\\)*'\\)")) 218 "'\\(?:[^&']\\|" xml-reference-re "\\)*'\\)"))
219;;[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default] 219 ;;[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]
220;; | 'IDREF' [VC: IDREF] 220 ;; | 'IDREF' [VC: IDREF]
221;; | 'IDREFS' [VC: IDREF] 221 ;; | 'IDREFS' [VC: IDREF]
222;; | 'ENTITY' [VC: Entity Name] 222 ;; | 'ENTITY' [VC: Entity Name]
223;; | 'ENTITIES' [VC: Entity Name] 223 ;; | 'ENTITIES' [VC: Entity Name]
224;; | 'NMTOKEN' [VC: Name Token] 224 ;; | 'NMTOKEN' [VC: Name Token]
225;; | 'NMTOKENS' [VC: Name Token] 225 ;; | 'NMTOKENS' [VC: Name Token]
226 (defvar xml-tokenized-type-re "\\(?:ID\\|IDREF\\|IDREFS\\|ENTITY\\|ENTITIES\\|NMTOKEN\\|NMTOKENS\\)") 226 (defvar xml-tokenized-type-re "\\(?:ID\\|IDREF\\|IDREFS\\|ENTITY\\|ENTITIES\\|NMTOKEN\\|NMTOKENS\\)")
227;;[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' 227 ;;[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'
228 (defvar xml-notation-type-re (concat "\\(?:NOTATION" whitespace "(" whitespace "*" xml-name-re 228 (defvar xml-notation-type-re (concat "\\(?:NOTATION" whitespace "(" whitespace "*" xml-name-re
229 "\\(?:" whitespace "*|" whitespace "*" xml-name-re "\\)*" whitespace "*)\\)")) 229 "\\(?:" whitespace "*|" whitespace "*" xml-name-re "\\)*" whitespace "*)\\)"))
230;;[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [VC: Enumeration] [VC: No Duplicate Tokens] 230 ;;[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [VC: Enumeration] [VC: No Duplicate Tokens]
231 (defvar xml-enumeration-re (concat "\\(?:(" whitespace "*" xml-nmtoken-re 231 (defvar xml-enumeration-re (concat "\\(?:(" whitespace "*" xml-nmtoken-re
232 "\\(?:" whitespace "*|" whitespace "*" xml-nmtoken-re "\\)*" 232 "\\(?:" whitespace "*|" whitespace "*" xml-nmtoken-re "\\)*"
233 whitespace ")\\)")) 233 whitespace ")\\)"))
234;;[57] EnumeratedType ::= NotationType | Enumeration 234 ;;[57] EnumeratedType ::= NotationType | Enumeration
235 (defvar xml-enumerated-type-re (concat "\\(?:" xml-notation-type-re "\\|" xml-enumeration-re "\\)")) 235 (defvar xml-enumerated-type-re (concat "\\(?:" xml-notation-type-re "\\|" xml-enumeration-re "\\)"))
236;;[54] AttType ::= StringType | TokenizedType | EnumeratedType 236 ;;[54] AttType ::= StringType | TokenizedType | EnumeratedType
237;;[55] StringType ::= 'CDATA' 237 ;;[55] StringType ::= 'CDATA'
238 (defvar xml-att-type-re (concat "\\(?:CDATA\\|" xml-tokenized-type-re "\\|" xml-notation-type-re"\\|" xml-enumerated-type-re "\\)")) 238 (defvar xml-att-type-re (concat "\\(?:CDATA\\|" xml-tokenized-type-re "\\|" xml-notation-type-re"\\|" xml-enumerated-type-re "\\)"))
239;;[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue) 239 ;;[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
240 (defvar xml-default-decl-re (concat "\\(?:#REQUIRED\\|#IMPLIED\\|\\(?:#FIXED" whitespace "\\)*" xml-att-value-re "\\)")) 240 (defvar xml-default-decl-re (concat "\\(?:#REQUIRED\\|#IMPLIED\\|\\(?:#FIXED" whitespace "\\)*" xml-att-value-re "\\)"))
241;;[53] AttDef ::= S Name S AttType S DefaultDecl 241 ;;[53] AttDef ::= S Name S AttType S DefaultDecl
242 (defvar xml-att-def-re (concat "\\(?:" whitespace "*" xml-name-re 242 (defvar xml-att-def-re (concat "\\(?:" whitespace "*" xml-name-re
243 whitespace "*" xml-att-type-re 243 whitespace "*" xml-att-type-re
244 whitespace "*" xml-default-decl-re "\\)")) 244 whitespace "*" xml-default-decl-re "\\)"))
245;;[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' 245 ;;[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"'
246;; | "'" ([^%&'] | PEReference | Reference)* "'" 246 ;; | "'" ([^%&'] | PEReference | Reference)* "'"
247 (defvar xml-entity-value-re (concat "\\(?:\"\\(?:[^%&\"]\\|" xml-pe-reference-re 247 (defvar xml-entity-value-re (concat "\\(?:\"\\(?:[^%&\"]\\|" xml-pe-reference-re
248 "\\|" xml-reference-re "\\)*\"\\|'\\(?:[^%&']\\|" 248 "\\|" xml-reference-re "\\)*\"\\|'\\(?:[^%&']\\|"
249 xml-pe-reference-re "\\|" xml-reference-re "\\)*'\\)"))) 249 xml-pe-reference-re "\\|" xml-reference-re "\\)*'\\)")))
@@ -269,7 +269,7 @@ If PARSE-NS is non-nil, then QNAMES are expanded."
269 ;; Get space syntax correct per XML [3]. 269 ;; Get space syntax correct per XML [3].
270 (dotimes (c 31) 270 (dotimes (c 31)
271 (modify-syntax-entry c "." table)) ; all are space in standard table 271 (modify-syntax-entry c "." table)) ; all are space in standard table
272 (dolist (c '(?\t ?\n ?\r)) ; these should be space 272 (dolist (c '(?\t ?\n ?\r)) ; these should be space
273 (modify-syntax-entry c " " table)) 273 (modify-syntax-entry c " " table))
274 ;; For skipping attributes. 274 ;; For skipping attributes.
275 (modify-syntax-entry ?\" "\"" table) 275 (modify-syntax-entry ?\" "\"" table)
@@ -306,16 +306,16 @@ is not well-formed XML.
306If PARSE-DTD is non-nil, the DTD is parsed rather than skipped, 306If PARSE-DTD is non-nil, the DTD is parsed rather than skipped,
307and returned as the first element of the list. 307and returned as the first element of the list.
308If PARSE-NS is non-nil, then QNAMES are expanded." 308If PARSE-NS is non-nil, then QNAMES are expanded."
309 (save-restriction 309 (save-excursion
310 (narrow-to-region beg end) 310 (if buffer
311 ;; Use fixed syntax table to ensure regexp char classes and syntax 311 (set-buffer buffer))
312 ;; specs DTRT. 312 (save-restriction
313 (with-syntax-table (standard-syntax-table) 313 (narrow-to-region beg end)
314 (let ((case-fold-search nil) ; XML is case-sensitive. 314 ;; Use fixed syntax table to ensure regexp char classes and syntax
315 xml result dtd) 315 ;; specs DTRT.
316 (save-excursion 316 (with-syntax-table (standard-syntax-table)
317 (if buffer 317 (let ((case-fold-search nil) ; XML is case-sensitive.
318 (set-buffer buffer)) 318 xml result dtd)
319 (goto-char (point-min)) 319 (goto-char (point-min))
320 (while (not (eobp)) 320 (while (not (eobp))
321 (if (search-forward "<" nil t) 321 (if (search-forward "<" nil t)
@@ -390,7 +390,7 @@ Returns one of:
390 parse-ns 390 parse-ns
391 (if parse-ns 391 (if parse-ns
392 (list 392 (list
393 ;; Default for empty prefix is no namespace 393 ;; Default for empty prefix is no namespace
394 (cons "" "") 394 (cons "" "")
395 ;; "xml" namespace 395 ;; "xml" namespace
396 (cons "xml" "http://www.w3.org/XML/1998/namespace") 396 (cons "xml" "http://www.w3.org/XML/1998/namespace")
@@ -431,12 +431,12 @@ Returns one of:
431 431
432 ;; Parse this node 432 ;; Parse this node
433 (let* ((node-name (match-string 1)) 433 (let* ((node-name (match-string 1))
434 ;; Parse the attribute list. 434 ;; Parse the attribute list.
435 (attrs (xml-parse-attlist xml-ns)) 435 (attrs (xml-parse-attlist xml-ns))
436 children pos) 436 children pos)
437 437
438 ;; add the xmlns:* attrs to our cache 438 ;; add the xmlns:* attrs to our cache
439 (when (consp xml-ns) 439 (when (consp xml-ns)
440 (dolist (attr attrs) 440 (dolist (attr attrs)
441 (when (and (consp (car attr)) 441 (when (and (consp (car attr))
442 (equal "http://www.w3.org/2000/xmlns/" 442 (equal "http://www.w3.org/2000/xmlns/"
@@ -444,7 +444,7 @@ Returns one of:
444 (push (cons (cdar attr) (cdr attr)) 444 (push (cons (cdar attr) (cdr attr))
445 xml-ns)))) 445 xml-ns))))
446 446
447 (setq children (list attrs (xml-maybe-do-ns node-name "" xml-ns))) 447 (setq children (list attrs (xml-maybe-do-ns node-name "" xml-ns)))
448 448
449 ;; is this an empty element ? 449 ;; is this an empty element ?
450 (if (looking-at "/>") 450 (if (looking-at "/>")
@@ -494,21 +494,21 @@ Returns one of:
494 494
495(defun xml-parse-string () 495(defun xml-parse-string ()
496 "Parse the next whatever. Could be a string, or an element." 496 "Parse the next whatever. Could be a string, or an element."
497 (let* ((pos (point)) 497 (let* ((pos (point))
498 (string (progn (if (search-forward "<" nil t) 498 (string (progn (if (search-forward "<" nil t)
499 (forward-char -1) 499 (forward-char -1)
500 (goto-char (point-max))) 500 (goto-char (point-max)))
501 (buffer-substring pos (point))))) 501 (buffer-substring pos (point)))))
502 ;; Clean up the string. As per XML specifications, the XML 502 ;; Clean up the string. As per XML specifications, the XML
503 ;; processor should always pass the whole string to the 503 ;; processor should always pass the whole string to the
504 ;; application. But \r's should be replaced: 504 ;; application. But \r's should be replaced:
505 ;; http://www.w3.org/TR/2000/REC-xml-20001006#sec-line-ends 505 ;; http://www.w3.org/TR/2000/REC-xml-20001006#sec-line-ends
506 (setq pos 0) 506 (setq pos 0)
507 (while (string-match "\r\n?" string pos) 507 (while (string-match "\r\n?" string pos)
508 (setq string (replace-match "\n" t t string)) 508 (setq string (replace-match "\n" t t string))
509 (setq pos (1+ (match-beginning 0)))) 509 (setq pos (1+ (match-beginning 0))))
510 510
511 (xml-substitute-special string))) 511 (xml-substitute-special string)))
512 512
513(defun xml-parse-attlist (&optional xml-ns) 513(defun xml-parse-attlist (&optional xml-ns)
514 "Return the attribute-list after point. 514 "Return the attribute-list after point.
@@ -543,8 +543,8 @@ Leave point at the first non-blank character after the tag."
543 (replace-regexp-in-string "\\s-\\{2,\\}" " " string) 543 (replace-regexp-in-string "\\s-\\{2,\\}" " " string)
544 (let ((expansion (xml-substitute-special string))) 544 (let ((expansion (xml-substitute-special string)))
545 (unless (stringp expansion) 545 (unless (stringp expansion)
546 ; We say this is the constraint. It is acctually that 546 ; We say this is the constraint. It is acctually that
547 ; external entities nor "<" can be in an attribute value. 547 ; external entities nor "<" can be in an attribute value.
548 (error "XML: (Not Well-Formed) Entities in attributes cannot expand into elements")) 548 (error "XML: (Not Well-Formed) Entities in attributes cannot expand into elements"))
549 (push (cons name expansion) attlist))) 549 (push (cons name expansion) attlist)))
550 550