• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching +defs:xml +defs:ns

0 ;;; xml.el --- XML parser
8 ;; Keywords: xml, data
56 ;; The functions `xml-parse-file', `xml-parse-region' and
57 ;; `xml-parse-tag' return a list with the following format:
59 ;; xml-list ::= (node node ...)
73 ;; * xml:base, xml:space support
92 (defconst xml-undefined-entity "?"
95 (defvar xml-entity-alist
103 (defvar xml-sub-parser nil
106 (defvar xml-validating-parser nil
109 (defsubst xml-node-name (node)
125 (defsubst xml-node-attributes (node)
130 (defsubst xml-node-children (node)
135 (defun xml-get-children (node child-name)
137 CHILD-NAME should match the value returned by `xml-node-name'."
139 (dolist (child (xml-node-children node))
141 (equal (xml-node-name child) child-name))
145 (defun xml-get-attribute-or-nil (node attribute)
149 See also `xml-get-attribute'."
150 (cdr (assoc attribute (xml-node-attributes node))))
152 (defsubst xml-get-attribute (node attribute)
156 See also `xml-get-attribute-or-nil'."
157 (or (xml-get-attribute-or-nil node attribute) ""))
166 (defun xml-parse-file (file &optional parse-dtd parse-ns)
175 (xml-parse-region (point-min)
178 parse-dtd parse-ns)))
181 (xml-parse-region (point-min)
184 parse-dtd parse-ns))))
187 (defvar xml-name-re)
188 (defvar xml-entity-value-re)
189 (defvar xml-att-def-re)
198 (defvar xml-name-start-char-re (concat "[" start-chars "]"))
200 (defvar xml-name-char-re (concat "[" name-chars "]"))
202 (defvar xml-name-re (concat xml-name-start-char-re xml-name-char-re "*"))
204 (defvar xml-names-re (concat xml-name-re "\\(?: " xml-name-re "\\)*"))
206 (defvar xml-nmtoken-re (concat xml-name-char-re "+"))
208 (defvar xml-nmtokens-re (concat xml-nmtoken-re "\\(?: " xml-name-re "\\)*"))
210 (defvar xml-char-ref-re "\\(?:&#[0-9]+;\\|&#x[0-9a-fA-F]+;\\)")
212 (defvar xml-entity-ref (concat "&" xml-name-re ";"))
214 (defvar xml-pe-reference-re (concat "%" xml-name-re ";"))
216 (defvar xml-reference-re (concat "\\(?:" xml-entity-ref "\\|" xml-char-ref-re "\\)"))
218 (defvar xml-att-value-re (concat "\\(?:\"\\(?:[^&\"]\\|" xml-reference-re "\\)*\"\\|"
219 "'\\(?:[^&']\\|" xml-reference-re "\\)*'\\)"))
227 (defvar xml-tokenized-type-re "\\(?:ID\\|IDREF\\|IDREFS\\|ENTITY\\|ENTITIES\\|NMTOKEN\\|NMTOKENS\\)")
229 (defvar xml-notation-type-re (concat "\\(?:NOTATION" whitespace "(" whitespace "*" xml-name-re
230 "\\(?:" whitespace "*|" whitespace "*" xml-name-re "\\)*" whitespace "*)\\)"))
232 (defvar xml-enumeration-re (concat "\\(?:(" whitespace "*" xml-nmtoken-re
233 "\\(?:" whitespace "*|" whitespace "*" xml-nmtoken-re "\\)*"
236 (defvar xml-enumerated-type-re (concat "\\(?:" xml-notation-type-re "\\|" xml-enumeration-re "\\)"))
239 (defvar xml-att-type-re (concat "\\(?:CDATA\\|" xml-tokenized-type-re "\\|" xml-notation-type-re"\\|" xml-enumerated-type-re "\\)"))
241 (defvar xml-default-decl-re (concat "\\(?:#REQUIRED\\|#IMPLIED\\|\\(?:#FIXED" whitespace "\\)*" xml-att-value-re "\\)"))
243 (defvar xml-att-def-re (concat "\\(?:" whitespace "*" xml-name-re
244 whitespace "*" xml-att-type-re
245 whitespace "*" xml-default-decl-re "\\)"))
248 (defvar xml-entity-value-re (concat "\\(?:\"\\(?:[^%&\"]\\|" xml-pe-reference-re
249 "\\|" xml-reference-re "\\)*\"\\|'\\(?:[^%&']\\|"
250 xml-pe-reference-re "\\|" xml-reference-re "\\)*'\\)")))
268 (defvar xml-syntax-table
290 "Syntax table used by `xml-parse-region'.")
295 (defconst xml-name-regexp "[[:alpha:]_:][[:alnum:]._:-]*"))
302 (defun xml-parse-region (beg end &optional buffer parse-dtd parse-ns)
314 xml result dtd)
325 (setq result (xml-parse-tag parse-dtd parse-ns))
326 (if (and xml result (not xml-sub-parser))
335 (add-to-list 'xml (cdr result))))
337 (add-to-list 'xml result)))))
340 (cons dtd (nreverse xml))
341 (nreverse xml)))))))
343 (defun xml-maybe-do-ns (name default xml-ns)
353 (if (consp xml-ns)
359 ;; matching cons in xml-ns. In which case we
360 (ns (or (cdr (assoc (if special "xmlns" prefix)
361 xml-ns))
363 (cons ns (if special "" lname)))
366 (defun xml-parse-fragment (&optional parse-dtd parse-ns)
367 "Parse xml-like fragments."
368 (let ((xml-sub-parser t)
371 (let ((bit (xml-parse-tag
372 parse-dtd parse-ns)))
380 (defun xml-parse-tag (&optional parse-dtd parse-ns)
389 (let ((xml-validating-parser (or parse-dtd xml-validating-parser))
390 (xml-ns (if (consp parse-ns)
391 parse-ns
392 (if parse-ns
396 ;; "xml" namespace
397 (cons "xml" "http://www.w3.org/XML/1998/namespace")
401 ;; Processing instructions (like the <?xml version="1.0"?> tag at the
406 (xml-parse-tag parse-dtd xml-ns))
414 (xml-parse-string))))
417 (let ((dtd (xml-parse-dtd parse-ns)))
419 (if xml-validating-parser
420 (cons dtd (xml-parse-tag nil xml-ns))
421 (xml-parse-tag nil xml-ns))))
436 (attrs (xml-parse-attlist xml-ns))
440 (when (consp xml-ns)
446 xml-ns))))
448 (setq children (list attrs (xml-maybe-do-ns node-name "" xml-ns)))
469 (let ((tag (xml-parse-tag nil xml-ns)))
473 (let ((expansion (xml-parse-string)))
489 (unless xml-sub-parser ; Usually, we error out.
494 (xml-parse-string)))))
496 (defun xml-parse-string ()
506 ;; http://www.w3.org/TR/2000/REC-xml-20001006#sec-line-ends
512 (xml-substitute-special string)))
514 (defun xml-parse-attlist (&optional xml-ns)
521 (concat "\\(" xml-name-regexp "\\)\\s-*=\\s-*")))
523 (setq name (xml-maybe-do-ns (match-string-no-properties 1) nil xml-ns))
526 ;; See also: http://www.w3.org/TR/2000/REC-xml-20001006#AVNormalize
545 (let ((expansion (xml-substitute-special string)))
566 (defun xml-skip-dtd ()
569 (let ((xml-validating-parser nil))
570 (xml-parse-dtd)))
572 (defun xml-parse-dtd (&optional parse-ns)
577 xml-validating-parser)
581 (looking-at xml-name-regexp)
636 (setq type (xml-parse-elem-type (match-string-no-properties 1 type))))
640 (if xml-validating-parser
645 xml-validating-parser)
654 ((looking-at (concat "<!ATTLIST[ \t\n\r]*\\(" xml-name-re
655 "\\)[ \t\n\r]*\\(" xml-att-def-re
663 ((looking-at (concat "<!ENTITY[ \t\n\r]*\\(" xml-name-re
664 "\\)[ \t\n\r]*\\(" xml-entity-value-re
670 (setq xml-entity-alist
671 (append xml-entity-alist
676 (xml-parse-fragment
677 xml-validating-parser
678 parse-ns))))))))
679 ((or (looking-at (concat "<!ENTITY[ \t\n\r]+\\(" xml-name-re
682 (looking-at (concat "<!ENTITY[ \t\n\r]+\\(" xml-name-re
692 (setq xml-entity-alist
693 (append xml-entity-alist
697 (xml-parse-fragment
698 xml-validating-parser
699 parse-ns))))))))
701 ((or (looking-at (concat "<!ENTITY[ \t\n\r]+%[ \t\n\r]+\\(" xml-name-re
706 "\\(" xml-name-re "\\)[ \t\n\r]+"
714 ((looking-at (concat "%" xml-name-re ";"))
717 (when xml-validating-parser
723 (defun xml-parse-elem-type (string)
733 (mapcar 'xml-parse-elem-type
737 (mapcar 'xml-parse-elem-type
762 (defun xml-substitute-special (string)
774 (entity (assoc this-part xml-entity-alist))
791 (if xml-validating-parser
794 xml-undefined-entity)))))
837 (defun xml-debug-print (xml &optional indent-string)
842 (dolist (node xml)
843 (xml-debug-print-internal node indent-string)))
845 (defalias 'xml-print 'xml-debug-print)
847 (defun xml-debug-print-internal (xml indent-string)
850 (let ((tree xml)
852 (insert indent-string ?< (symbol-name (xml-node-name tree)))
855 (setq attlist (xml-node-attributes tree))
860 (setq tree (xml-node-children tree))
871 (xml-debug-print-internal node (concat indent-string " ")))
879 (insert ?< ?/ (symbol-name (xml-node-name xml)) ?>))))
881 (provide 'xml)
884 ;;; xml.el ends here