Debian Codegraph @

src/test/resources/dxml-nashorn.generated.js

raw symbols SCIP
1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
4
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
7
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId])
10 /******/ return installedModules[moduleId].exports;
11
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
14 /******/ i: moduleId,
15 /******/ l: false,
16 /******/ exports: {}
17 /******/ };
18
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
24
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
27 /******/ }
28
29
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
32
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
35
36 /******/ // identity function for calling harmory imports with the correct context
37 /******/ __webpack_require__.i = function(value) { return value; };
38
39 /******/ // define getter function for harmory exports
40 /******/ __webpack_require__.d = function(exports, name, getter) {
41 /******/ Object.defineProperty(exports, name, {
42 /******/ configurable: false,
43 /******/ enumerable: true,
44 /******/ get: getter
45 /******/ });
46 /******/ };
47
48 /******/ // getDefaultExport function for compatibility with non-harmony modules
49 /******/ __webpack_require__.n = function(module) {
50 /******/ var getter = module && module.__esModule ?
51 /******/ function getDefault() { return module['default']; } :
52 /******/ function getModuleExports() { return module; };
53 /******/ __webpack_require__.d(getter, 'a', getter);
54 /******/ return getter;
55 /******/ };
56
57 /******/ // Object.prototype.hasOwnProperty.call
58 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59
60 /******/ // __webpack_public_path__
61 /******/ __webpack_require__.p = "";
62
63 /******/ // Load entry module and return exports
64 /******/ return __webpack_require__(__webpack_require__.s = 4);
65 /******/ })
66 /************************************************************************/
67 /******/ ([
68 /* 0 */
69 /***/ function(module, exports) {
70
71 /*
72 * DOM Level 2
73 * Object DOMException
74 * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
75 * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
76 */
77
78 function copy(src,dest){
79 for(var p in src){
80 dest[p] = src[p];
81 }
82 }
83 /**
84 ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
85 ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
86 */
87 function _extends(Class,Super){
88 var pt = Class.prototype;
89 if(Object.create){
90 var ppt = Object.create(Super.prototype)
91 pt.__proto__ = ppt;
92 }
93 if(!(pt instanceof Super)){
94 function t(){};
95 t.prototype = Super.prototype;
96 t = new t();
97 copy(pt,t);
98 Class.prototype = pt = t;
99 }
100 if(pt.constructor != Class){
101 if(typeof Class != 'function'){
102 console.error("unknow Class:"+Class)
103 }
104 pt.constructor = Class
105 }
106 }
107 var htmlns = 'http://www.w3.org/1999/xhtml' ;
108 // Node Types
109 var NodeType = {}
110 var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
111 var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
112 var TEXT_NODE = NodeType.TEXT_NODE = 3;
113 var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
114 var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
115 var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
116 var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
117 var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
118 var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
119 var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
120 var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
121 var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
122
123 // ExceptionCode
124 var ExceptionCode = {}
125 var ExceptionMessage = {};
126 var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
127 var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
128 var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
129 var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
130 var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
131 var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
132 var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
133 var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
134 var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
135 var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
136 //level2
137 var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
138 var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
139 var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
140 var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
141 var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
142
143
144 function DOMException(code, message) {
145 if(message instanceof Error){
146 var error = message;
147 }else{
148 error = this;
149 Error.call(this, ExceptionMessage[code]);
150 this.message = ExceptionMessage[code];
151 if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
152 }
153 error.code = code;
154 if(message) this.message = this.message + ": " + message;
155 return error;
156 };
157 DOMException.prototype = Error.prototype;
158 copy(ExceptionCode,DOMException)
159 /**
160 * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
161 * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
162 * The items in the NodeList are accessible via an integral index, starting from 0.
163 */
164 function NodeList() {
165 };
166 NodeList.prototype = {
167 /**
168 * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
169 * @standard level1
170 */
171 length:0,
172 /**
173 * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
174 * @standard level1
175 * @param index unsigned long
176 * Index into the collection.
177 * @return Node
178 * The node at the indexth position in the NodeList, or null if that is not a valid index.
179 */
180 item: function(index) {
181 return this[index] || null;
182 },
183 toString:function(isHTML,nodeFilter){
184 for(var buf = [], i = 0;i<this.length;i++){
185 serializeToString(this[i],buf,isHTML,nodeFilter);
186 }
187 return buf.join('');
188 }
189 };
190 function LiveNodeList(node,refresh){
191 this._node = node;
192 this._refresh = refresh
193 _updateLiveList(this);
194 }
195 function _updateLiveList(list){
196 var inc = list._node._inc || list._node.ownerDocument._inc;
197 if(list._inc != inc){
198 var ls = list._refresh(list._node);
199 //console.log(ls.length)
200 __set__(list,'length',ls.length);
201 copy(ls,list);
202 list._inc = inc;
203 }
204 }
205 LiveNodeList.prototype.item = function(i){
206 _updateLiveList(this);
207 return this[i];
208 }
209
210 _extends(LiveNodeList,NodeList);
211 /**
212 *
213 * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
214 * NamedNodeMap objects in the DOM are live.
215 * used for attributes or DocumentType entities
216 */
217 function NamedNodeMap() {
218 };
219
220 function _findNodeIndex(list,node){
221 var i = list.length;
222 while(i--){
223 if(list[i] === node){return i}
224 }
225 }
226
227 function _addNamedNode(el,list,newAttr,oldAttr){
228 if(oldAttr){
229 list[_findNodeIndex(list,oldAttr)] = newAttr;
230 }else{
231 list[list.length++] = newAttr;
232 }
233 if(el){
234 newAttr.ownerElement = el;
235 var doc = el.ownerDocument;
236 if(doc){
237 oldAttr && _onRemoveAttribute(doc,el,oldAttr);
238 _onAddAttribute(doc,el,newAttr);
239 }
240 }
241 }
242 function _removeNamedNode(el,list,attr){
243 //console.log('remove attr:'+attr)
244 var i = _findNodeIndex(list,attr);
245 if(i>=0){
246 var lastIndex = list.length-1
247 while(i<lastIndex){
248 list[i] = list[++i]
249 }
250 list.length = lastIndex;
251 if(el){
252 var doc = el.ownerDocument;
253 if(doc){
254 _onRemoveAttribute(doc,el,attr);
255 attr.ownerElement = null;
256 }
257 }
258 }else{
259 throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
260 }
261 }
262 NamedNodeMap.prototype = {
263 length:0,
264 item:NodeList.prototype.item,
265 getNamedItem: function(key) {
266 // if(key.indexOf(':')>0 || key == 'xmlns'){
267 // return null;
268 // }
269 //console.log()
270 var i = this.length;
271 while(i--){
272 var attr = this[i];
273 //console.log(attr.nodeName,key)
274 if(attr.nodeName == key){
275 return attr;
276 }
277 }
278 },
279 setNamedItem: function(attr) {
280 var el = attr.ownerElement;
281 if(el && el!=this._ownerElement){
282 throw new DOMException(INUSE_ATTRIBUTE_ERR);
283 }
284 var oldAttr = this.getNamedItem(attr.nodeName);
285 _addNamedNode(this._ownerElement,this,attr,oldAttr);
286 return oldAttr;
287 },
288 /* returns Node */
289 setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
290 var el = attr.ownerElement, oldAttr;
291 if(el && el!=this._ownerElement){
292 throw new DOMException(INUSE_ATTRIBUTE_ERR);
293 }
294 oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
295 _addNamedNode(this._ownerElement,this,attr,oldAttr);
296 return oldAttr;
297 },
298
299 /* returns Node */
300 removeNamedItem: function(key) {
301 var attr = this.getNamedItem(key);
302 _removeNamedNode(this._ownerElement,this,attr);
303 return attr;
304
305
306 },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
307
308 //for level2
309 removeNamedItemNS:function(namespaceURI,localName){
310 var attr = this.getNamedItemNS(namespaceURI,localName);
311 _removeNamedNode(this._ownerElement,this,attr);
312 return attr;
313 },
314 getNamedItemNS: function(namespaceURI, localName) {
315 var i = this.length;
316 while(i--){
317 var node = this[i];
318 if(node.localName == localName && node.namespaceURI == namespaceURI){
319 return node;
320 }
321 }
322 return null;
323 }
324 };
325 /**
326 * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
327 */
328 function DOMImplementation(/* Object */ features) {
329 this._features = {};
330 if (features) {
331 for (var feature in features) {
332 this._features = features[feature];
333 }
334 }
335 };
336
337 DOMImplementation.prototype = {
338 hasFeature: function(/* string */ feature, /* string */ version) {
339 var versions = this._features[feature.toLowerCase()];
340 if (versions && (!version || version in versions)) {
341 return true;
342 } else {
343 return false;
344 }
345 },
346 // Introduced in DOM Level 2:
347 createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
348 var doc = new Document();
349 doc.implementation = this;
350 doc.childNodes = new NodeList();
351 doc.doctype = doctype;
352 if(doctype){
353 doc.appendChild(doctype);
354 }
355 if(qualifiedName){
356 var root = doc.createElementNS(namespaceURI,qualifiedName);
357 doc.appendChild(root);
358 }
359 return doc;
360 },
361 // Introduced in DOM Level 2:
362 createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
363 var node = new DocumentType();
364 node.name = qualifiedName;
365 node.nodeName = qualifiedName;
366 node.publicId = publicId;
367 node.systemId = systemId;
368 // Introduced in DOM Level 2:
369 //readonly attribute DOMString internalSubset;
370
371 //TODO:..
372 // readonly attribute NamedNodeMap entities;
373 // readonly attribute NamedNodeMap notations;
374 return node;
375 }
376 };
377
378
379 /**
380 * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
381 */
382
383 function Node() {
384 };
385
386 Node.prototype = {
387 firstChild : null,
388 lastChild : null,
389 previousSibling : null,
390 nextSibling : null,
391 attributes : null,
392 parentNode : null,
393 childNodes : null,
394 ownerDocument : null,
395 nodeValue : null,
396 namespaceURI : null,
397 prefix : null,
398 localName : null,
399 // Modified in DOM Level 2:
400 insertBefore:function(newChild, refChild){//raises
401 return _insertBefore(this,newChild,refChild);
402 },
403 replaceChild:function(newChild, oldChild){//raises
404 this.insertBefore(newChild,oldChild);
405 if(oldChild){
406 this.removeChild(oldChild);
407 }
408 },
409 removeChild:function(oldChild){
410 return _removeChild(this,oldChild);
411 },
412 appendChild:function(newChild){
413 return this.insertBefore(newChild,null);
414 },
415 hasChildNodes:function(){
416 return this.firstChild != null;
417 },
418 cloneNode:function(deep){
419 return cloneNode(this.ownerDocument||this,this,deep);
420 },
421 // Modified in DOM Level 2:
422 normalize:function(){
423 var child = this.firstChild;
424 while(child){
425 var next = child.nextSibling;
426 if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
427 this.removeChild(next);
428 child.appendData(next.data);
429 }else{
430 child.normalize();
431 child = next;
432 }
433 }
434 },
435 // Introduced in DOM Level 2:
436 isSupported:function(feature, version){
437 return this.ownerDocument.implementation.hasFeature(feature,version);
438 },
439 // Introduced in DOM Level 2:
440 hasAttributes:function(){
441 return this.attributes.length>0;
442 },
443 lookupPrefix:function(namespaceURI){
444 var el = this;
445 while(el){
446 var map = el._nsMap;
447 //console.dir(map)
448 if(map){
449 for(var n in map){
450 if(map[n] == namespaceURI){
451 return n;
452 }
453 }
454 }
455 el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
456 }
457 return null;
458 },
459 // Introduced in DOM Level 3:
460 lookupNamespaceURI:function(prefix){
461 var el = this;
462 while(el){
463 var map = el._nsMap;
464 //console.dir(map)
465 if(map){
466 if(prefix in map){
467 return map[prefix] ;
468 }
469 }
470 el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
471 }
472 return null;
473 },
474 // Introduced in DOM Level 3:
475 isDefaultNamespace:function(namespaceURI){
476 var prefix = this.lookupPrefix(namespaceURI);
477 return prefix == null;
478 }
479 };
480
481
482 function _xmlEncoder(c){
483 return c == '<' && '&lt;' ||
484 c == '>' && '&gt;' ||
485 c == '&' && '&amp;' ||
486 c == '"' && '&quot;' ||
487 '&#'+c.charCodeAt()+';'
488 }
489
490
491 copy(NodeType,Node);
492 copy(NodeType,Node.prototype);
493
494 /**
495 * @param callback return true for continue,false for break
496 * @return boolean true: break visit;
497 */
498 function _visitNode(node,callback){
499 if(callback(node)){
500 return true;
501 }
502 if(node = node.firstChild){
503 do{
504 if(_visitNode(node,callback)){return true}
505 }while(node=node.nextSibling)
506 }
507 }
508
509
510
511 function Document(){
512 }
513 function _onAddAttribute(doc,el,newAttr){
514 doc && doc._inc++;
515 var ns = newAttr.namespaceURI ;
516 if(ns == 'http://www.w3.org/2000/xmlns/'){
517 //update namespace
518 el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
519 }
520 }
521 function _onRemoveAttribute(doc,el,newAttr,remove){
522 doc && doc._inc++;
523 var ns = newAttr.namespaceURI ;
524 if(ns == 'http://www.w3.org/2000/xmlns/'){
525 //update namespace
526 delete el._nsMap[newAttr.prefix?newAttr.localName:'']
527 }
528 }
529 function _onUpdateChild(doc,el,newChild){
530 if(doc && doc._inc){
531 doc._inc++;
532 //update childNodes
533 var cs = el.childNodes;
534 if(newChild){
535 cs[cs.length++] = newChild;
536 }else{
537 //console.log(1)
538 var child = el.firstChild;
539 var i = 0;
540 while(child){
541 cs[i++] = child;
542 child =child.nextSibling;
543 }
544 cs.length = i;
545 }
546 }
547 }
548
549 /**
550 * attributes;
551 * children;
552 *
553 * writeable properties:
554 * nodeValue,Attr:value,CharacterData:data
555 * prefix
556 */
557 function _removeChild(parentNode,child){
558 var previous = child.previousSibling;
559 var next = child.nextSibling;
560 if(previous){
561 previous.nextSibling = next;
562 }else{
563 parentNode.firstChild = next
564 }
565 if(next){
566 next.previousSibling = previous;
567 }else{
568 parentNode.lastChild = previous;
569 }
570 _onUpdateChild(parentNode.ownerDocument,parentNode);
571 return child;
572 }
573 /**
574 * preformance key(refChild == null)
575 */
576 function _insertBefore(parentNode,newChild,nextChild){
577 var cp = newChild.parentNode;
578 if(cp){
579 cp.removeChild(newChild);//remove and update
580 }
581 if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
582 var newFirst = newChild.firstChild;
583 if (newFirst == null) {
584 return newChild;
585 }
586 var newLast = newChild.lastChild;
587 }else{
588 newFirst = newLast = newChild;
589 }
590 var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
591
592 newFirst.previousSibling = pre;
593 newLast.nextSibling = nextChild;
594
595
596 if(pre){
597 pre.nextSibling = newFirst;
598 }else{
599 parentNode.firstChild = newFirst;
600 }
601 if(nextChild == null){
602 parentNode.lastChild = newLast;
603 }else{
604 nextChild.previousSibling = newLast;
605 }
606 do{
607 newFirst.parentNode = parentNode;
608 }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
609 _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
610 //console.log(parentNode.lastChild.nextSibling == null)
611 if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
612 newChild.firstChild = newChild.lastChild = null;
613 }
614 return newChild;
615 }
616 function _appendSingleChild(parentNode,newChild){
617 var cp = newChild.parentNode;
618 if(cp){
619 var pre = parentNode.lastChild;
620 cp.removeChild(newChild);//remove and update
621 var pre = parentNode.lastChild;
622 }
623 var pre = parentNode.lastChild;
624 newChild.parentNode = parentNode;
625 newChild.previousSibling = pre;
626 newChild.nextSibling = null;
627 if(pre){
628 pre.nextSibling = newChild;
629 }else{
630 parentNode.firstChild = newChild;
631 }
632 parentNode.lastChild = newChild;
633 _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
634 return newChild;
635 //console.log("__aa",parentNode.lastChild.nextSibling == null)
636 }
637 Document.prototype = {
638 //implementation : null,
639 nodeName : '#document',
640 nodeType : DOCUMENT_NODE,
641 doctype : null,
642 documentElement : null,
643 _inc : 1,
644
645 insertBefore : function(newChild, refChild){//raises
646 if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
647 var child = newChild.firstChild;
648 while(child){
649 var next = child.nextSibling;
650 this.insertBefore(child,refChild);
651 child = next;
652 }
653 return newChild;
654 }
655 if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
656 this.documentElement = newChild;
657 }
658
659 return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
660 },
661 removeChild : function(oldChild){
662 if(this.documentElement == oldChild){
663 this.documentElement = null;
664 }
665 return _removeChild(this,oldChild);
666 },
667 // Introduced in DOM Level 2:
668 importNode : function(importedNode,deep){
669 return importNode(this,importedNode,deep);
670 },
671 // Introduced in DOM Level 2:
672 getElementById : function(id){
673 var rtv = null;
674 _visitNode(this.documentElement,function(node){
675 if(node.nodeType == ELEMENT_NODE){
676 if(node.getAttribute('id') == id){
677 rtv = node;
678 return true;
679 }
680 }
681 })
682 return rtv;
683 },
684
685 //document factory method:
686 createElement : function(tagName){
687 var node = new Element();
688 node.ownerDocument = this;
689 node.nodeName = tagName;
690 node.tagName = tagName;
691 node.childNodes = new NodeList();
692 var attrs = node.attributes = new NamedNodeMap();
693 attrs._ownerElement = node;
694 return node;
695 },
696 createDocumentFragment : function(){
697 var node = new DocumentFragment();
698 node.ownerDocument = this;
699 node.childNodes = new NodeList();
700 return node;
701 },
702 createTextNode : function(data){
703 var node = new Text();
704 node.ownerDocument = this;
705 node.appendData(data)
706 return node;
707 },
708 createComment : function(data){
709 var node = new Comment();
710 node.ownerDocument = this;
711 node.appendData(data)
712 return node;
713 },
714 createCDATASection : function(data){
715 var node = new CDATASection();
716 node.ownerDocument = this;
717 node.appendData(data)
718 return node;
719 },
720 createProcessingInstruction : function(target,data){
721 var node = new ProcessingInstruction();
722 node.ownerDocument = this;
723 node.tagName = node.target = target;
724 node.nodeValue= node.data = data;
725 return node;
726 },
727 createAttribute : function(name){
728 var node = new Attr();
729 node.ownerDocument = this;
730 node.name = name;
731 node.nodeName = name;
732 node.localName = name;
733 node.specified = true;
734 return node;
735 },
736 createEntityReference : function(name){
737 var node = new EntityReference();
738 node.ownerDocument = this;
739 node.nodeName = name;
740 return node;
741 },
742 // Introduced in DOM Level 2:
743 createElementNS : function(namespaceURI,qualifiedName){
744 var node = new Element();
745 var pl = qualifiedName.split(':');
746 var attrs = node.attributes = new NamedNodeMap();
747 node.childNodes = new NodeList();
748 node.ownerDocument = this;
749 node.nodeName = qualifiedName;
750 node.tagName = qualifiedName;
751 node.namespaceURI = namespaceURI;
752 if(pl.length == 2){
753 node.prefix = pl[0];
754 node.localName = pl[1];
755 }else{
756 //el.prefix = null;
757 node.localName = qualifiedName;
758 }
759 attrs._ownerElement = node;
760 return node;
761 },
762 // Introduced in DOM Level 2:
763 createAttributeNS : function(namespaceURI,qualifiedName){
764 var node = new Attr();
765 var pl = qualifiedName.split(':');
766 node.ownerDocument = this;
767 node.nodeName = qualifiedName;
768 node.name = qualifiedName;
769 node.namespaceURI = namespaceURI;
770 node.specified = true;
771 if(pl.length == 2){
772 node.prefix = pl[0];
773 node.localName = pl[1];
774 }else{
775 //el.prefix = null;
776 node.localName = qualifiedName;
777 }
778 return node;
779 }
780 };
781 _extends(Document,Node);
782
783
784 function Element() {
785 this._nsMap = {};
786 };
787 Element.prototype = {
788 nodeType : ELEMENT_NODE,
789 hasAttribute : function(name){
790 return this.getAttributeNode(name)!=null;
791 },
792 getAttribute : function(name){
793 var attr = this.getAttributeNode(name);
794 return attr && attr.value || '';
795 },
796 getAttributeNode : function(name){
797 return this.attributes.getNamedItem(name);
798 },
799 setAttribute : function(name, value){
800 var attr = this.ownerDocument.createAttribute(name);
801 attr.value = attr.nodeValue = "" + value;
802 this.setAttributeNode(attr)
803 },
804 removeAttribute : function(name){
805 var attr = this.getAttributeNode(name)
806 attr && this.removeAttributeNode(attr);
807 },
808
809 //four real opeartion method
810 appendChild:function(newChild){
811 if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
812 return this.insertBefore(newChild,null);
813 }else{
814 return _appendSingleChild(this,newChild);
815 }
816 },
817 setAttributeNode : function(newAttr){
818 return this.attributes.setNamedItem(newAttr);
819 },
820 setAttributeNodeNS : function(newAttr){
821 return this.attributes.setNamedItemNS(newAttr);
822 },
823 removeAttributeNode : function(oldAttr){
824 //console.log(this == oldAttr.ownerElement)
825 return this.attributes.removeNamedItem(oldAttr.nodeName);
826 },
827 //get real attribute name,and remove it by removeAttributeNode
828 removeAttributeNS : function(namespaceURI, localName){
829 var old = this.getAttributeNodeNS(namespaceURI, localName);
830 old && this.removeAttributeNode(old);
831 },
832
833 hasAttributeNS : function(namespaceURI, localName){
834 return this.getAttributeNodeNS(namespaceURI, localName)!=null;
835 },
836 getAttributeNS : function(namespaceURI, localName){
837 var attr = this.getAttributeNodeNS(namespaceURI, localName);
838 return attr && attr.value || '';
839 },
840 setAttributeNS : function(namespaceURI, qualifiedName, value){
841 var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
842 attr.value = attr.nodeValue = "" + value;
843 this.setAttributeNode(attr)
844 },
845 getAttributeNodeNS : function(namespaceURI, localName){
846 return this.attributes.getNamedItemNS(namespaceURI, localName);
847 },
848
849 getElementsByTagName : function(tagName){
850 return new LiveNodeList(this,function(base){
851 var ls = [];
852 _visitNode(base,function(node){
853 if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
854 ls.push(node);
855 }
856 });
857 return ls;
858 });
859 },
860 getElementsByTagNameNS : function(namespaceURI, localName){
861 return new LiveNodeList(this,function(base){
862 var ls = [];
863 _visitNode(base,function(node){
864 if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
865 ls.push(node);
866 }
867 });
868 return ls;
869
870 });
871 }
872 };
873 Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
874 Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
875
876
877 _extends(Element,Node);
878 function Attr() {
879 };
880 Attr.prototype.nodeType = ATTRIBUTE_NODE;
881 _extends(Attr,Node);
882
883
884 function CharacterData() {
885 };
886 CharacterData.prototype = {
887 data : '',
888 substringData : function(offset, count) {
889 return this.data.substring(offset, offset+count);
890 },
891 appendData: function(text) {
892 text = this.data+text;
893 this.nodeValue = this.data = text;
894 this.length = text.length;
895 },
896 insertData: function(offset,text) {
897 this.replaceData(offset,0,text);
898
899 },
900 appendChild:function(newChild){
901 throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
902 },
903 deleteData: function(offset, count) {
904 this.replaceData(offset,count,"");
905 },
906 replaceData: function(offset, count, text) {
907 var start = this.data.substring(0,offset);
908 var end = this.data.substring(offset+count);
909 text = start + text + end;
910 this.nodeValue = this.data = text;
911 this.length = text.length;
912 }
913 }
914 _extends(CharacterData,Node);
915 function Text() {
916 };
917 Text.prototype = {
918 nodeName : "#text",
919 nodeType : TEXT_NODE,
920 splitText : function(offset) {
921 var text = this.data;
922 var newText = text.substring(offset);
923 text = text.substring(0, offset);
924 this.data = this.nodeValue = text;
925 this.length = text.length;
926 var newNode = this.ownerDocument.createTextNode(newText);
927 if(this.parentNode){
928 this.parentNode.insertBefore(newNode, this.nextSibling);
929 }
930 return newNode;
931 }
932 }
933 _extends(Text,CharacterData);
934 function Comment() {
935 };
936 Comment.prototype = {
937 nodeName : "#comment",
938 nodeType : COMMENT_NODE
939 }
940 _extends(Comment,CharacterData);
941
942 function CDATASection() {
943 };
944 CDATASection.prototype = {
945 nodeName : "#cdata-section",
946 nodeType : CDATA_SECTION_NODE
947 }
948 _extends(CDATASection,CharacterData);
949
950
951 function DocumentType() {
952 };
953 DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
954 _extends(DocumentType,Node);
955
956 function Notation() {
957 };
958 Notation.prototype.nodeType = NOTATION_NODE;
959 _extends(Notation,Node);
960
961 function Entity() {
962 };
963 Entity.prototype.nodeType = ENTITY_NODE;
964 _extends(Entity,Node);
965
966 function EntityReference() {
967 };
968 EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
969 _extends(EntityReference,Node);
970
971 function DocumentFragment() {
972 };
973 DocumentFragment.prototype.nodeName = "#document-fragment";
974 DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
975 _extends(DocumentFragment,Node);
976
977
978 function ProcessingInstruction() {
979 }
980 ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
981 _extends(ProcessingInstruction,Node);
982 function XMLSerializer(){}
983 XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
984 return nodeSerializeToString.call(node,isHtml,nodeFilter);
985 }
986 Node.prototype.toString = nodeSerializeToString;
987 function nodeSerializeToString(isHtml,nodeFilter){
988 var buf = [];
989 var refNode = this.nodeType == 9?this.documentElement:this;
990 var prefix = refNode.prefix;
991 var uri = refNode.namespaceURI;
992
993 if(uri && prefix == null){
994 //console.log(prefix)
995 var prefix = refNode.lookupPrefix(uri);
996 if(prefix == null){
997 //isHTML = true;
998 var visibleNamespaces=[
999 {namespace:uri,prefix:null}
1000 //{namespace:uri,prefix:''}
1001 ]
1002 }
1003 }
1004 serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
1005 //console.log('###',this.nodeType,uri,prefix,buf.join(''))
1006 return buf.join('');
1007 }
1008 function needNamespaceDefine(node,isHTML, visibleNamespaces) {
1009 var prefix = node.prefix||'';
1010 var uri = node.namespaceURI;
1011 if (!prefix && !uri){
1012 return false;
1013 }
1014 if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
1015 || uri == 'http://www.w3.org/2000/xmlns/'){
1016 return false;
1017 }
1018
1019 var i = visibleNamespaces.length
1020 //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
1021 while (i--) {
1022 var ns = visibleNamespaces[i];
1023 // get namespace prefix
1024 //console.log(node.nodeType,node.tagName,ns.prefix,prefix)
1025 if (ns.prefix == prefix){
1026 return ns.namespace != uri;
1027 }
1028 }
1029 //console.log(isHTML,uri,prefix=='')
1030 //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
1031 // return false;
1032 //}
1033 //node.flag = '11111'
1034 //console.error(3,true,node.flag,node.prefix,node.namespaceURI)
1035 return true;
1036 }
1037 function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
1038 if(nodeFilter){
1039 node = nodeFilter(node);
1040 if(node){
1041 if(typeof node == 'string'){
1042 buf.push(node);
1043 return;
1044 }
1045 }else{
1046 return;
1047 }
1048 //buf.sort.apply(attrs, attributeSorter);
1049 }
1050 switch(node.nodeType){
1051 case ELEMENT_NODE:
1052 if (!visibleNamespaces) visibleNamespaces = [];
1053 var startVisibleNamespaces = visibleNamespaces.length;
1054 var attrs = node.attributes;
1055 var len = attrs.length;
1056 var child = node.firstChild;
1057 var nodeName = node.tagName;
1058
1059 isHTML = (htmlns === node.namespaceURI) ||isHTML
1060 buf.push('<',nodeName);
1061
1062
1063
1064 for(var i=0;i<len;i++){
1065 // add namespaces for attributes
1066 var attr = attrs.item(i);
1067 if (attr.prefix == 'xmlns') {
1068 visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
1069 }else if(attr.nodeName == 'xmlns'){
1070 visibleNamespaces.push({ prefix: '', namespace: attr.value });
1071 }
1072 }
1073 for(var i=0;i<len;i++){
1074 var attr = attrs.item(i);
1075 if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
1076 var prefix = attr.prefix||'';
1077 var uri = attr.namespaceURI;
1078 var ns = prefix ? ' xmlns:' + prefix : " xmlns";
1079 buf.push(ns, '="' , uri , '"');
1080 visibleNamespaces.push({ prefix: prefix, namespace:uri });
1081 }
1082 serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
1083 }
1084 // add namespace for current node
1085 if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
1086 var prefix = node.prefix||'';
1087 var uri = node.namespaceURI;
1088 var ns = prefix ? ' xmlns:' + prefix : " xmlns";
1089 buf.push(ns, '="' , uri , '"');
1090 visibleNamespaces.push({ prefix: prefix, namespace:uri });
1091 }
1092
1093 if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
1094 buf.push('>');
1095 //if is cdata child node
1096 if(isHTML && /^script$/i.test(nodeName)){
1097 while(child){
1098 if(child.data){
1099 buf.push(child.data);
1100 }else{
1101 serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
1102 }
1103 child = child.nextSibling;
1104 }
1105 }else
1106 {
1107 while(child){
1108 serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
1109 child = child.nextSibling;
1110 }
1111 }
1112 buf.push('</',nodeName,'>');
1113 }else{
1114 buf.push('/>');
1115 }
1116 // remove added visible namespaces
1117 //visibleNamespaces.length = startVisibleNamespaces;
1118 return;
1119 case DOCUMENT_NODE:
1120 case DOCUMENT_FRAGMENT_NODE:
1121 var child = node.firstChild;
1122 while(child){
1123 serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
1124 child = child.nextSibling;
1125 }
1126 return;
1127 case ATTRIBUTE_NODE:
1128 return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
1129 case TEXT_NODE:
1130 return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
1131 case CDATA_SECTION_NODE:
1132 return buf.push( '<![CDATA[',node.data,']]>');
1133 case COMMENT_NODE:
1134 return buf.push( "<!--",node.data,"-->");
1135 case DOCUMENT_TYPE_NODE:
1136 var pubid = node.publicId;
1137 var sysid = node.systemId;
1138 buf.push('<!DOCTYPE ',node.name);
1139 if(pubid){
1140 buf.push(' PUBLIC "',pubid);
1141 if (sysid && sysid!='.') {
1142 buf.push( '" "',sysid);
1143 }
1144 buf.push('">');
1145 }else if(sysid && sysid!='.'){
1146 buf.push(' SYSTEM "',sysid,'">');
1147 }else{
1148 var sub = node.internalSubset;
1149 if(sub){
1150 buf.push(" [",sub,"]");
1151 }
1152 buf.push(">");
1153 }
1154 return;
1155 case PROCESSING_INSTRUCTION_NODE:
1156 return buf.push( "<?",node.target," ",node.data,"?>");
1157 case ENTITY_REFERENCE_NODE:
1158 return buf.push( '&',node.nodeName,';');
1159 //case ENTITY_NODE:
1160 //case NOTATION_NODE:
1161 default:
1162 buf.push('??',node.nodeName);
1163 }
1164 }
1165 function importNode(doc,node,deep){
1166 var node2;
1167 switch (node.nodeType) {
1168 case ELEMENT_NODE:
1169 node2 = node.cloneNode(false);
1170 node2.ownerDocument = doc;
1171 //var attrs = node2.attributes;
1172 //var len = attrs.length;
1173 //for(var i=0;i<len;i++){
1174 //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
1175 //}
1176 case DOCUMENT_FRAGMENT_NODE:
1177 break;
1178 case ATTRIBUTE_NODE:
1179 deep = true;
1180 break;
1181 //case ENTITY_REFERENCE_NODE:
1182 //case PROCESSING_INSTRUCTION_NODE:
1183 ////case TEXT_NODE:
1184 //case CDATA_SECTION_NODE:
1185 //case COMMENT_NODE:
1186 // deep = false;
1187 // break;
1188 //case DOCUMENT_NODE:
1189 //case DOCUMENT_TYPE_NODE:
1190 //cannot be imported.
1191 //case ENTITY_NODE:
1192 //case NOTATION_NODE:
1193 //can not hit in level3
1194 //default:throw e;
1195 }
1196 if(!node2){
1197 node2 = node.cloneNode(false);//false
1198 }
1199 node2.ownerDocument = doc;
1200 node2.parentNode = null;
1201 if(deep){
1202 var child = node.firstChild;
1203 while(child){
1204 node2.appendChild(importNode(doc,child,deep));
1205 child = child.nextSibling;
1206 }
1207 }
1208 return node2;
1209 }
1210 //
1211 //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
1212 // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
1213 function cloneNode(doc,node,deep){
1214 var node2 = new node.constructor();
1215 for(var n in node){
1216 var v = node[n];
1217 if(typeof v != 'object' ){
1218 if(v != node2[n]){
1219 node2[n] = v;
1220 }
1221 }
1222 }
1223 if(node.childNodes){
1224 node2.childNodes = new NodeList();
1225 }
1226 node2.ownerDocument = doc;
1227 switch (node2.nodeType) {
1228 case ELEMENT_NODE:
1229 var attrs = node.attributes;
1230 var attrs2 = node2.attributes = new NamedNodeMap();
1231 var len = attrs.length
1232 attrs2._ownerElement = node2;
1233 for(var i=0;i<len;i++){
1234 node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
1235 }
1236 break;;
1237 case ATTRIBUTE_NODE:
1238 deep = true;
1239 }
1240 if(deep){
1241 var child = node.firstChild;
1242 while(child){
1243 node2.appendChild(cloneNode(doc,child,deep));
1244 child = child.nextSibling;
1245 }
1246 }
1247 return node2;
1248 }
1249
1250 function __set__(object,key,value){
1251 object[key] = value
1252 }
1253 //do dynamic
1254 try{
1255 if(Object.defineProperty){
1256 Object.defineProperty(LiveNodeList.prototype,'length',{
1257 get:function(){
1258 _updateLiveList(this);
1259 return this.$$length;
1260 }
1261 });
1262 Object.defineProperty(Node.prototype,'textContent',{
1263 get:function(){
1264 return getTextContent(this);
1265 },
1266 set:function(data){
1267 switch(this.nodeType){
1268 case ELEMENT_NODE:
1269 case DOCUMENT_FRAGMENT_NODE:
1270 while(this.firstChild){
1271 this.removeChild(this.firstChild);
1272 }
1273 if(data || String(data)){
1274 this.appendChild(this.ownerDocument.createTextNode(data));
1275 }
1276 break;
1277 default:
1278 //TODO:
1279 this.data = data;
1280 this.value = data;
1281 this.nodeValue = data;
1282 }
1283 }
1284 })
1285
1286 function getTextContent(node){
1287 switch(node.nodeType){
1288 case ELEMENT_NODE:
1289 case DOCUMENT_FRAGMENT_NODE:
1290 var buf = [];
1291 node = node.firstChild;
1292 while(node){
1293 if(node.nodeType!==7 && node.nodeType !==8){
1294 buf.push(getTextContent(node));
1295 }
1296 node = node.nextSibling;
1297 }
1298 return buf.join('');
1299 default:
1300 return node.nodeValue;
1301 }
1302 }
1303 __set__ = function(object,key,value){
1304 //console.log(value)
1305 object['$$'+key] = value
1306 }
1307 }
1308 }catch(e){//ie8
1309 }
1310
1311 //if(typeof require == 'function'){
1312 exports.DOMImplementation = DOMImplementation;
1313 exports.XMLSerializer = XMLSerializer;
1314 //}
1315
1316
1317 /***/ },
1318 /* 1 */
1319 /***/ function(module, exports) {
1320
1321 var g;
1322
1323 // This works in non-strict mode
1324 g = (function() { return this; })();
1325
1326 try {
1327 // This works if eval is allowed (see CSP)
1328 g = g || Function("return this")() || (1,eval)("this");
1329 } catch(e) {
1330 // This works if the window reference is available
1331 if(typeof window === "object")
1332 g = window;
1333 }
1334
1335 // g can still be undefined, but nothing to do about it...
1336 // We return undefined, instead of nothing here, so it's
1337 // easier to handle this case. if(!global) { ...}
1338
1339 module.exports = g;
1340
1341
1342 /***/ },
1343 /* 2 */
1344 /***/ function(module, exports, __webpack_require__) {
1345
1346 function DOMParser(options){
1347 this.options = options ||{locator:{}};
1348
1349 }
1350 DOMParser.prototype.parseFromString = function(source,mimeType){
1351 var options = this.options;
1352 var sax = new XMLReader();
1353 var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
1354 var errorHandler = options.errorHandler;
1355 var locator = options.locator;
1356 var defaultNSMap = options.xmlns||{};
1357 var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}
1358 if(locator){
1359 domBuilder.setDocumentLocator(locator)
1360 }
1361
1362 sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
1363 sax.domBuilder = options.domBuilder || domBuilder;
1364 if(/\/x?html?$/.test(mimeType)){
1365 entityMap.nbsp = '\xa0';
1366 entityMap.copy = '\xa9';
1367 defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
1368 }
1369 defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
1370 if(source){
1371 sax.parse(source,defaultNSMap,entityMap);
1372 }else{
1373 sax.errorHandler.error("invalid doc source");
1374 }
1375 return domBuilder.doc;
1376 }
1377 function buildErrorHandler(errorImpl,domBuilder,locator){
1378 if(!errorImpl){
1379 if(domBuilder instanceof DOMHandler){
1380 return domBuilder;
1381 }
1382 errorImpl = domBuilder ;
1383 }
1384 var errorHandler = {}
1385 var isCallback = errorImpl instanceof Function;
1386 locator = locator||{}
1387 function build(key){
1388 var fn = errorImpl[key];
1389 if(!fn && isCallback){
1390 fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
1391 }
1392 errorHandler[key] = fn && function(msg){
1393 fn('[xmldom '+key+']\t'+msg+_locator(locator));
1394 }||function(){};
1395 }
1396 build('warning');
1397 build('error');
1398 build('fatalError');
1399 return errorHandler;
1400 }
1401
1402 //console.log('#\n\n\n\n\n\n\n####')
1403 /**
1404 * +ContentHandler+ErrorHandler
1405 * +LexicalHandler+EntityResolver2
1406 * -DeclHandler-DTDHandler
1407 *
1408 * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
1409 * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
1410 * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
1411 */
1412 function DOMHandler() {
1413 this.cdata = false;
1414 }
1415 function position(locator,node){
1416 node.lineNumber = locator.lineNumber;
1417 node.columnNumber = locator.columnNumber;
1418 }
1419 /**
1420 * @see org.xml.sax.ContentHandler#startDocument
1421 * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
1422 */
1423 DOMHandler.prototype = {
1424 startDocument : function() {
1425 this.doc = new DOMImplementation().createDocument(null, null, null);
1426 if (this.locator) {
1427 this.doc.documentURI = this.locator.systemId;
1428 }
1429 },
1430 startElement:function(namespaceURI, localName, qName, attrs) {
1431 var doc = this.doc;
1432 var el = doc.createElementNS(namespaceURI, qName||localName);
1433 var len = attrs.length;
1434 appendElement(this, el);
1435 this.currentElement = el;
1436
1437 this.locator && position(this.locator,el)
1438 for (var i = 0 ; i < len; i++) {
1439 var namespaceURI = attrs.getURI(i);
1440 var value = attrs.getValue(i);
1441 var qName = attrs.getQName(i);
1442 var attr = doc.createAttributeNS(namespaceURI, qName);
1443 this.locator &&position(attrs.getLocator(i),attr);
1444 attr.value = attr.nodeValue = value;
1445 el.setAttributeNode(attr)
1446 }
1447 },
1448 endElement:function(namespaceURI, localName, qName) {
1449 var current = this.currentElement
1450 var tagName = current.tagName;
1451 this.currentElement = current.parentNode;
1452 },
1453 startPrefixMapping:function(prefix, uri) {
1454 },
1455 endPrefixMapping:function(prefix) {
1456 },
1457 processingInstruction:function(target, data) {
1458 var ins = this.doc.createProcessingInstruction(target, data);
1459 this.locator && position(this.locator,ins)
1460 appendElement(this, ins);
1461 },
1462 ignorableWhitespace:function(ch, start, length) {
1463 },
1464 characters:function(chars, start, length) {
1465 chars = _toString.apply(this,arguments)
1466 //console.log(chars)
1467 if(chars){
1468 if (this.cdata) {
1469 var charNode = this.doc.createCDATASection(chars);
1470 } else {
1471 var charNode = this.doc.createTextNode(chars);
1472 }
1473 if(this.currentElement){
1474 this.currentElement.appendChild(charNode);
1475 }else if(/^\s*$/.test(chars)){
1476 this.doc.appendChild(charNode);
1477 //process xml
1478 }
1479 this.locator && position(this.locator,charNode)
1480 }
1481 },
1482 skippedEntity:function(name) {
1483 },
1484 endDocument:function() {
1485 this.doc.normalize();
1486 },
1487 setDocumentLocator:function (locator) {
1488 if(this.locator = locator){// && !('lineNumber' in locator)){
1489 locator.lineNumber = 0;
1490 }
1491 },
1492 //LexicalHandler
1493 comment:function(chars, start, length) {
1494 chars = _toString.apply(this,arguments)
1495 var comm = this.doc.createComment(chars);
1496 this.locator && position(this.locator,comm)
1497 appendElement(this, comm);
1498 },
1499
1500 startCDATA:function() {
1501 //used in characters() methods
1502 this.cdata = true;
1503 },
1504 endCDATA:function() {
1505 this.cdata = false;
1506 },
1507
1508 startDTD:function(name, publicId, systemId) {
1509 var impl = this.doc.implementation;
1510 if (impl && impl.createDocumentType) {
1511 var dt = impl.createDocumentType(name, publicId, systemId);
1512 this.locator && position(this.locator,dt)
1513 appendElement(this, dt);
1514 }
1515 },
1516 /**
1517 * @see org.xml.sax.ErrorHandler
1518 * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
1519 */
1520 warning:function(error) {
1521 console.warn('[xmldom warning]\t'+error,_locator(this.locator));
1522 },
1523 error:function(error) {
1524 console.error('[xmldom error]\t'+error,_locator(this.locator));
1525 },
1526 fatalError:function(error) {
1527 console.error('[xmldom fatalError]\t'+error,_locator(this.locator));
1528 throw error;
1529 }
1530 }
1531 function _locator(l){
1532 if(l){
1533 return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
1534 }
1535 }
1536 function _toString(chars,start,length){
1537 if(typeof chars == 'string'){
1538 return chars.substr(start,length)
1539 }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
1540 if(chars.length >= start+length || start){
1541 return new java.lang.String(chars,start,length)+'';
1542 }
1543 return chars;
1544 }
1545 }
1546
1547 /*
1548 * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
1549 * used method of org.xml.sax.ext.LexicalHandler:
1550 * #comment(chars, start, length)
1551 * #startCDATA()
1552 * #endCDATA()
1553 * #startDTD(name, publicId, systemId)
1554 *
1555 *
1556 * IGNORED method of org.xml.sax.ext.LexicalHandler:
1557 * #endDTD()
1558 * #startEntity(name)
1559 * #endEntity(name)
1560 *
1561 *
1562 * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
1563 * IGNORED method of org.xml.sax.ext.DeclHandler
1564 * #attributeDecl(eName, aName, type, mode, value)
1565 * #elementDecl(name, model)
1566 * #externalEntityDecl(name, publicId, systemId)
1567 * #internalEntityDecl(name, value)
1568 * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
1569 * IGNORED method of org.xml.sax.EntityResolver2
1570 * #resolveEntity(String name,String publicId,String baseURI,String systemId)
1571 * #resolveEntity(publicId, systemId)
1572 * #getExternalSubset(name, baseURI)
1573 * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
1574 * IGNORED method of org.xml.sax.DTDHandler
1575 * #notationDecl(name, publicId, systemId) {};
1576 * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
1577 */
1578 "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
1579 DOMHandler.prototype[key] = function(){return null}
1580 })
1581
1582 /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
1583 function appendElement (hander,node) {
1584 if (!hander.currentElement) {
1585 hander.doc.appendChild(node);
1586 } else {
1587 hander.currentElement.appendChild(node);
1588 }
1589 }//appendChild and setAttributeNS are preformance key
1590
1591 //if(typeof require == 'function'){
1592 var XMLReader = __webpack_require__(3).XMLReader;
1593 var DOMImplementation = exports.DOMImplementation = __webpack_require__(0).DOMImplementation;
1594 exports.XMLSerializer = __webpack_require__(0).XMLSerializer ;
1595 exports.DOMParser = DOMParser;
1596 //}
1597
1598
1599 /***/ },
1600 /* 3 */
1601 /***/ function(module, exports) {
1602
1603 //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
1604 //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
1605 //[5] Name ::= NameStartChar (NameChar)*
1606 var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
1607 var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
1608 var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
1609 //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
1610 //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
1611
1612 //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
1613 //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
1614 var S_TAG = 0;//tag name offerring
1615 var S_ATTR = 1;//attr name offerring
1616 var S_ATTR_SPACE=2;//attr name end and space offer
1617 var S_EQ = 3;//=space?
1618 var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
1619 var S_ATTR_END = 5;//attr value end and no space(quot end)
1620 var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
1621 var S_TAG_CLOSE = 7;//closed el<el />
1622
1623 function XMLReader(){
1624
1625 }
1626
1627 XMLReader.prototype = {
1628 parse:function(source,defaultNSMap,entityMap){
1629 var domBuilder = this.domBuilder;
1630 domBuilder.startDocument();
1631 _copy(defaultNSMap ,defaultNSMap = {})
1632 parse(source,defaultNSMap,entityMap,
1633 domBuilder,this.errorHandler);
1634 domBuilder.endDocument();
1635 }
1636 }
1637 function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
1638 function fixedFromCharCode(code) {
1639 // String.prototype.fromCharCode does not supports
1640 // > 2 bytes unicode chars directly
1641 if (code > 0xffff) {
1642 code -= 0x10000;
1643 var surrogate1 = 0xd800 + (code >> 10)
1644 , surrogate2 = 0xdc00 + (code & 0x3ff);
1645
1646 return String.fromCharCode(surrogate1, surrogate2);
1647 } else {
1648 return String.fromCharCode(code);
1649 }
1650 }
1651 function entityReplacer(a){
1652 var k = a.slice(1,-1);
1653 if(k in entityMap){
1654 return entityMap[k];
1655 }else if(k.charAt(0) === '#'){
1656 return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
1657 }else{
1658 errorHandler.error('entity not found:'+a);
1659 return a;
1660 }
1661 }
1662 function appendText(end){//has some bugs
1663 if(end>start){
1664 var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
1665 locator&&position(start);
1666 domBuilder.characters(xt,0,end-start);
1667 start = end
1668 }
1669 }
1670 function position(p,m){
1671 while(p>=lineEnd && (m = linePattern.exec(source))){
1672 lineStart = m.index;
1673 lineEnd = lineStart + m[0].length;
1674 locator.lineNumber++;
1675 //console.log('line++:',locator,startPos,endPos)
1676 }
1677 locator.columnNumber = p-lineStart+1;
1678 }
1679 var lineStart = 0;
1680 var lineEnd = 0;
1681 var linePattern = /.*(?:\r\n?|\n)|.*$/g
1682 var locator = domBuilder.locator;
1683
1684 var parseStack = [{currentNSMap:defaultNSMapCopy}]
1685 var closeMap = {};
1686 var start = 0;
1687 while(true){
1688 try{
1689 var tagStart = source.indexOf('<',start);
1690 if(tagStart<0){
1691 if(!source.substr(start).match(/^\s*$/)){
1692 var doc = domBuilder.doc;
1693 var text = doc.createTextNode(source.substr(start));
1694 doc.appendChild(text);
1695 domBuilder.currentElement = text;
1696 }
1697 return;
1698 }
1699 if(tagStart>start){
1700 appendText(tagStart);
1701 }
1702 switch(source.charAt(tagStart+1)){
1703 case '/':
1704 var end = source.indexOf('>',tagStart+3);
1705 var tagName = source.substring(tagStart+2,end);
1706 var config = parseStack.pop();
1707 if(end<0){
1708
1709 tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
1710 //console.error('#@@@@@@'+tagName)
1711 errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
1712 end = tagStart+1+tagName.length;
1713 }else if(tagName.match(/\s</)){
1714 tagName = tagName.replace(/[\s<].*/,'');
1715 errorHandler.error("end tag name: "+tagName+' maybe not complete');
1716 end = tagStart+1+tagName.length;
1717 }
1718 //console.error(parseStack.length,parseStack)
1719 //console.error(config);
1720 var localNSMap = config.localNSMap;
1721 var endMatch = config.tagName == tagName;
1722 var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
1723 if(endIgnoreCaseMach){
1724 domBuilder.endElement(config.uri,config.localName,tagName);
1725 if(localNSMap){
1726 for(var prefix in localNSMap){
1727 domBuilder.endPrefixMapping(prefix) ;
1728 }
1729 }
1730 if(!endMatch){
1731 errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
1732 }
1733 }else{
1734 parseStack.push(config)
1735 }
1736
1737 end++;
1738 break;
1739 // end elment
1740 case '?':// <?...?>
1741 locator&&position(tagStart);
1742 end = parseInstruction(source,tagStart,domBuilder);
1743 break;
1744 case '!':// <!doctype,<![CDATA,<!--
1745 locator&&position(tagStart);
1746 end = parseDCC(source,tagStart,domBuilder,errorHandler);
1747 break;
1748 default:
1749 locator&&position(tagStart);
1750 var el = new ElementAttributes();
1751 var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
1752 //elStartEnd
1753 var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
1754 var len = el.length;
1755
1756
1757 if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
1758 el.closed = true;
1759 if(!entityMap.nbsp){
1760 errorHandler.warning('unclosed xml attribute');
1761 }
1762 }
1763 if(locator && len){
1764 var locator2 = copyLocator(locator,{});
1765 //try{//attribute position fixed
1766 for(var i = 0;i<len;i++){
1767 var a = el[i];
1768 position(a.offset);
1769 a.locator = copyLocator(locator,{});
1770 }
1771 //}catch(e){console.error('@@@@@'+e)}
1772 domBuilder.locator = locator2
1773 if(appendElement(el,domBuilder,currentNSMap)){
1774 parseStack.push(el)
1775 }
1776 domBuilder.locator = locator;
1777 }else{
1778 if(appendElement(el,domBuilder,currentNSMap)){
1779 parseStack.push(el)
1780 }
1781 }
1782
1783
1784
1785 if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
1786 end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
1787 }else{
1788 end++;
1789 }
1790 }
1791 }catch(e){
1792 errorHandler.error('element parse error: '+e)
1793 //errorHandler.error('element parse error: '+e);
1794 end = -1;
1795 //throw e;
1796 }
1797 if(end>start){
1798 start = end;
1799 }else{
1800 //TODO: 这里有可能sax回退,有位置错误风险
1801 appendText(Math.max(tagStart,start)+1);
1802 }
1803 }
1804 }
1805 function copyLocator(f,t){
1806 t.lineNumber = f.lineNumber;
1807 t.columnNumber = f.columnNumber;
1808 return t;
1809 }
1810
1811 /**
1812 * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
1813 * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
1814 */
1815 function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
1816 var attrName;
1817 var value;
1818 var p = ++start;
1819 var s = S_TAG;//status
1820 while(true){
1821 var c = source.charAt(p);
1822 switch(c){
1823 case '=':
1824 if(s === S_ATTR){//attrName
1825 attrName = source.slice(start,p);
1826 s = S_EQ;
1827 }else if(s === S_ATTR_SPACE){
1828 s = S_EQ;
1829 }else{
1830 //fatalError: equal must after attrName or space after attrName
1831 throw new Error('attribute equal must after attrName');
1832 }
1833 break;
1834 case '\'':
1835 case '"':
1836 if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
1837 ){//equal
1838 if(s === S_ATTR){
1839 errorHandler.warning('attribute value must after "="')
1840 attrName = source.slice(start,p)
1841 }
1842 start = p+1;
1843 p = source.indexOf(c,start)
1844 if(p>0){
1845 value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1846 el.add(attrName,value,start-1);
1847 s = S_ATTR_END;
1848 }else{
1849 //fatalError: no end quot match
1850 throw new Error('attribute value no end \''+c+'\' match');
1851 }
1852 }else if(s == S_ATTR_NOQUOT_VALUE){
1853 value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1854 //console.log(attrName,value,start,p)
1855 el.add(attrName,value,start);
1856 //console.dir(el)
1857 errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
1858 start = p+1;
1859 s = S_ATTR_END
1860 }else{
1861 //fatalError: no equal before
1862 throw new Error('attribute value must after "="');
1863 }
1864 break;
1865 case '/':
1866 switch(s){
1867 case S_TAG:
1868 el.setTagName(source.slice(start,p));
1869 case S_ATTR_END:
1870 case S_TAG_SPACE:
1871 case S_TAG_CLOSE:
1872 s =S_TAG_CLOSE;
1873 el.closed = true;
1874 case S_ATTR_NOQUOT_VALUE:
1875 case S_ATTR:
1876 case S_ATTR_SPACE:
1877 break;
1878 //case S_EQ:
1879 default:
1880 throw new Error("attribute invalid close char('/')")
1881 }
1882 break;
1883 case ''://end document
1884 //throw new Error('unexpected end of input')
1885 errorHandler.error('unexpected end of input');
1886 if(s == S_TAG){
1887 el.setTagName(source.slice(start,p));
1888 }
1889 return p;
1890 case '>':
1891 switch(s){
1892 case S_TAG:
1893 el.setTagName(source.slice(start,p));
1894 case S_ATTR_END:
1895 case S_TAG_SPACE:
1896 case S_TAG_CLOSE:
1897 break;//normal
1898 case S_ATTR_NOQUOT_VALUE://Compatible state
1899 case S_ATTR:
1900 value = source.slice(start,p);
1901 if(value.slice(-1) === '/'){
1902 el.closed = true;
1903 value = value.slice(0,-1)
1904 }
1905 case S_ATTR_SPACE:
1906 if(s === S_ATTR_SPACE){
1907 value = attrName;
1908 }
1909 if(s == S_ATTR_NOQUOT_VALUE){
1910 errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1911 el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
1912 }else{
1913 if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
1914 errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
1915 }
1916 el.add(value,value,start)
1917 }
1918 break;
1919 case S_EQ:
1920 throw new Error('attribute value missed!!');
1921 }
1922 // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
1923 return p;
1924 /*xml space '\x20' | #x9 | #xD | #xA; */
1925 case '\u0080':
1926 c = ' ';
1927 default:
1928 if(c<= ' '){//space
1929 switch(s){
1930 case S_TAG:
1931 el.setTagName(source.slice(start,p));//tagName
1932 s = S_TAG_SPACE;
1933 break;
1934 case S_ATTR:
1935 attrName = source.slice(start,p)
1936 s = S_ATTR_SPACE;
1937 break;
1938 case S_ATTR_NOQUOT_VALUE:
1939 var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1940 errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1941 el.add(attrName,value,start)
1942 case S_ATTR_END:
1943 s = S_TAG_SPACE;
1944 break;
1945 //case S_TAG_SPACE:
1946 //case S_EQ:
1947 //case S_ATTR_SPACE:
1948 // void();break;
1949 //case S_TAG_CLOSE:
1950 //ignore warning
1951 }
1952 }else{//not space
1953 //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
1954 //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
1955 switch(s){
1956 //case S_TAG:void();break;
1957 //case S_ATTR:void();break;
1958 //case S_ATTR_NOQUOT_VALUE:void();break;
1959 case S_ATTR_SPACE:
1960 var tagName = el.tagName;
1961 if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
1962 errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
1963 }
1964 el.add(attrName,attrName,start);
1965 start = p;
1966 s = S_ATTR;
1967 break;
1968 case S_ATTR_END:
1969 errorHandler.warning('attribute space is required"'+attrName+'"!!')
1970 case S_TAG_SPACE:
1971 s = S_ATTR;
1972 start = p;
1973 break;
1974 case S_EQ:
1975 s = S_ATTR_NOQUOT_VALUE;
1976 start = p;
1977 break;
1978 case S_TAG_CLOSE:
1979 throw new Error("elements closed character '/' and '>' must be connected to");
1980 }
1981 }
1982 }//end outer switch
1983 //console.log('p++',p)
1984 p++;
1985 }
1986 }
1987 /**
1988 * @return true if has new namespace define
1989 */
1990 function appendElement(el,domBuilder,currentNSMap){
1991 var tagName = el.tagName;
1992 var localNSMap = null;
1993 //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
1994 var i = el.length;
1995 while(i--){
1996 var a = el[i];
1997 var qName = a.qName;
1998 var value = a.value;
1999 var nsp = qName.indexOf(':');
2000 if(nsp>0){
2001 var prefix = a.prefix = qName.slice(0,nsp);
2002 var localName = qName.slice(nsp+1);
2003 var nsPrefix = prefix === 'xmlns' && localName
2004 }else{
2005 localName = qName;
2006 prefix = null
2007 nsPrefix = qName === 'xmlns' && ''
2008 }
2009 //can not set prefix,because prefix !== ''
2010 a.localName = localName ;
2011 //prefix == null for no ns prefix attribute
2012 if(nsPrefix !== false){//hack!!
2013 if(localNSMap == null){
2014 localNSMap = {}
2015 //console.log(currentNSMap,0)
2016 _copy(currentNSMap,currentNSMap={})
2017 //console.log(currentNSMap,1)
2018 }
2019 currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
2020 a.uri = 'http://www.w3.org/2000/xmlns/'
2021 domBuilder.startPrefixMapping(nsPrefix, value)
2022 }
2023 }
2024 var i = el.length;
2025 while(i--){
2026 a = el[i];
2027 var prefix = a.prefix;
2028 if(prefix){//no prefix attribute has no namespace
2029 if(prefix === 'xml'){
2030 a.uri = 'http://www.w3.org/XML/1998/namespace';
2031 }if(prefix !== 'xmlns'){
2032 a.uri = currentNSMap[prefix || '']
2033
2034 //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
2035 }
2036 }
2037 }
2038 var nsp = tagName.indexOf(':');
2039 if(nsp>0){
2040 prefix = el.prefix = tagName.slice(0,nsp);
2041 localName = el.localName = tagName.slice(nsp+1);
2042 }else{
2043 prefix = null;//important!!
2044 localName = el.localName = tagName;
2045 }
2046 //no prefix element has default namespace
2047 var ns = el.uri = currentNSMap[prefix || ''];
2048 domBuilder.startElement(ns,localName,tagName,el);
2049 //endPrefixMapping and startPrefixMapping have not any help for dom builder
2050 //localNSMap = null
2051 if(el.closed){
2052 domBuilder.endElement(ns,localName,tagName);
2053 if(localNSMap){
2054 for(prefix in localNSMap){
2055 domBuilder.endPrefixMapping(prefix)
2056 }
2057 }
2058 }else{
2059 el.currentNSMap = currentNSMap;
2060 el.localNSMap = localNSMap;
2061 //parseStack.push(el);
2062 return true;
2063 }
2064 }
2065 function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
2066 if(/^(?:script|textarea)$/i.test(tagName)){
2067 var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
2068 var text = source.substring(elStartEnd+1,elEndStart);
2069 if(/[&<]/.test(text)){
2070 if(/^script$/i.test(tagName)){
2071 //if(!/\]\]>/.test(text)){
2072 //lexHandler.startCDATA();
2073 domBuilder.characters(text,0,text.length);
2074 //lexHandler.endCDATA();
2075 return elEndStart;
2076 //}
2077 }//}else{//text area
2078 text = text.replace(/&#?\w+;/g,entityReplacer);
2079 domBuilder.characters(text,0,text.length);
2080 return elEndStart;
2081 //}
2082
2083 }
2084 }
2085 return elStartEnd+1;
2086 }
2087 function fixSelfClosed(source,elStartEnd,tagName,closeMap){
2088 //if(tagName in closeMap){
2089 var pos = closeMap[tagName];
2090 if(pos == null){
2091 //console.log(tagName)
2092 pos = source.lastIndexOf('</'+tagName+'>')
2093 if(pos<elStartEnd){//忘记闭合
2094 pos = source.lastIndexOf('</'+tagName)
2095 }
2096 closeMap[tagName] =pos
2097 }
2098 return pos<elStartEnd;
2099 //}
2100 }
2101 function _copy(source,target){
2102 for(var n in source){target[n] = source[n]}
2103 }
2104 function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
2105 var next= source.charAt(start+2)
2106 switch(next){
2107 case '-':
2108 if(source.charAt(start + 3) === '-'){
2109 var end = source.indexOf('-->',start+4);
2110 //append comment source.substring(4,end)//<!--
2111 if(end>start){
2112 domBuilder.comment(source,start+4,end-start-4);
2113 return end+3;
2114 }else{
2115 errorHandler.error("Unclosed comment");
2116 return -1;
2117 }
2118 }else{
2119 //error
2120 return -1;
2121 }
2122 default:
2123 if(source.substr(start+3,6) == 'CDATA['){
2124 var end = source.indexOf(']]>',start+9);
2125 domBuilder.startCDATA();
2126 domBuilder.characters(source,start+9,end-start-9);
2127 domBuilder.endCDATA()
2128 return end+3;
2129 }
2130 //<!DOCTYPE
2131 //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
2132 var matchs = split(source,start);
2133 var len = matchs.length;
2134 if(len>1 && /!doctype/i.test(matchs[0][0])){
2135 var name = matchs[1][0];
2136 var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
2137 var sysid = len>4 && matchs[4][0];
2138 var lastMatch = matchs[len-1]
2139 domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
2140 sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
2141 domBuilder.endDTD();
2142
2143 return lastMatch.index+lastMatch[0].length
2144 }
2145 }
2146 return -1;
2147 }
2148
2149
2150
2151 function parseInstruction(source,start,domBuilder){
2152 var end = source.indexOf('?>',start);
2153 if(end){
2154 var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
2155 if(match){
2156 var len = match[0].length;
2157 domBuilder.processingInstruction(match[1], match[2]) ;
2158 return end+2;
2159 }else{//error
2160 return -1;
2161 }
2162 }
2163 return -1;
2164 }
2165
2166 /**
2167 * @param source
2168 */
2169 function ElementAttributes(source){
2170
2171 }
2172 ElementAttributes.prototype = {
2173 setTagName:function(tagName){
2174 if(!tagNamePattern.test(tagName)){
2175 throw new Error('invalid tagName:'+tagName)
2176 }
2177 this.tagName = tagName
2178 },
2179 add:function(qName,value,offset){
2180 if(!tagNamePattern.test(qName)){
2181 throw new Error('invalid attribute:'+qName)
2182 }
2183 this[this.length++] = {qName:qName,value:value,offset:offset}
2184 },
2185 length:0,
2186 getLocalName:function(i){return this[i].localName},
2187 getLocator:function(i){return this[i].locator},
2188 getQName:function(i){return this[i].qName},
2189 getURI:function(i){return this[i].uri},
2190 getValue:function(i){return this[i].value}
2191 // ,getIndex:function(uri, localName)){
2192 // if(localName){
2193 //
2194 // }else{
2195 // var qName = uri
2196 // }
2197 // },
2198 // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
2199 // getType:function(uri,localName){}
2200 // getType:function(i){},
2201 }
2202
2203
2204
2205
2206 function _set_proto_(thiz,parent){
2207 thiz.__proto__ = parent;
2208 return thiz;
2209 }
2210 if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
2211 _set_proto_ = function(thiz,parent){
2212 function p(){};
2213 p.prototype = parent;
2214 p = new p();
2215 for(parent in thiz){
2216 p[parent] = thiz[parent];
2217 }
2218 return p;
2219 }
2220 }
2221
2222 function split(source,start){
2223 var match;
2224 var buf = [];
2225 var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
2226 reg.lastIndex = start;
2227 reg.exec(source);//skip <
2228 while(match = reg.exec(source)){
2229 buf.push(match);
2230 if(match[1])return buf;
2231 }
2232 }
2233
2234 exports.XMLReader = XMLReader;
2235
2236
2237
2238 /***/ },
2239 /* 4 */
2240 /***/ function(module, exports, __webpack_require__) {
2241
2242 /* WEBPACK VAR INJECTION */(function(global) {global.console = {
2243 log: print,
2244 warn: print,
2245 error: print
2246 };
2247 global.xmldom = __webpack_require__(2);
2248 global.DOMParser = global.xmldom.DOMParser;
2249 global.XMLSerializer = global.xmldom.XMLSerializer;
2250
2251 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
2252
2253 /***/ }
2254 /******/ ]);