Changeset 1544
- Timestamp:
- 05/23/10 11:52:41 (15 years ago)
- Files:
-
- trunk/docsrc/changelog.dd (modified) (1 diff)
- trunk/phobos/std/xml.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/changelog.dd
r1533 r1544 4 4 5 5 6 6 $(VERSION 047, May 9, 2010, =================================================, 7 7 8 8 $(WHATSNEW 9 9 $(LI std.functional: toDelegate now accepts callable(function pointers, delegates and objects implement opCall) ) 10 10 $(LI std.traits: Added templates to get compile-time information about functions.) 11 11 $(LI std.typecons: Added tie and AutoImplement.) 12 12 ) 13 13 $(BUGSFIXED 14 $(LI $(BUGZILLA 2835): std.socket.TcpSocket doesn't actually connect) 15 $(LI $(BUGZILLA 3200): std.xml doesn't follow spec for Tag.text) 14 16 $(LI $(BUGZILLA 3873): std.range.repeat should have popBack defined) 15 17 $(LI $(BUGZILLA 4202): Changset 1517 doesn't compile) 16 18 ) 17 19 ) 18 20 19 21 <div id=version> 20 22 $(UL 21 23 $(NEW 047) 22 24 $(NEW 046) 23 25 $(NEW 045) trunk/phobos/std/xml.d
r1500 r1544 984 984 if (optc(s,'/')) type = TagType.END; 985 985 name = munch(s,"^/>"~whitespace); 986 986 munch(s,whitespace); 987 987 while(s.length > 0 && s[0] != '>' && s[0] != '/') 988 988 { 989 989 string key = munch(s,"^="~whitespace); 990 990 munch(s,whitespace); 991 991 reqc(s,'='); 992 992 munch(s,whitespace); 993 993 reqc(s,'"'); 994 string val = encode(munch(s,"^\""));994 string val = decode(munch(s,"^\""), DecodeMode.LOOSE); 995 995 reqc(s,'"'); 996 996 munch(s,whitespace); 997 997 attr[key] = val; 998 998 } 999 999 if (optc(s,'/')) 1000 1000 { 1001 1001 if (type == TagType.END) throw new TagException(""); 1002 1002 type = TagType.EMPTY; 1003 1003 } 1004 1004 reqc(s,'>'); … … 1938 1938 } 1939 1939 } 1940 1940 else if (tag_.isEnd) 1941 1941 { 1942 1942 auto startTag = startTags[tag_.name]; 1943 1943 string text; 1944 1944 1945 1945 immutable(char)* p = startTag.tagString.ptr 1946 1946 + startTag.tagString.length; 1947 1947 immutable(char)* q = tag_.tagString.ptr; 1948 text = p[0..(q-p)];1948 text = decode(p[0..(q-p)], DecodeMode.LOOSE); 1949 1949 1950 1950 auto element = new Element(startTag); 1951 1951 if (text.length != 0) element ~= new Text(text); 1952 1952 1953 1953 auto handler = tag_.name in onEndTag; 1954 1954 if (handler !is null) (*handler)(element); 1955 1955 else 1956 1956 { 1957 1957 handler = null in onEndTag; 1958 1958 if (handler !is null) (*handler)(element); … … 2611 2611 ]"); 2612 2612 assert(false); 2613 2613 } 2614 2614 catch(CheckException e) 2615 2615 { 2616 2616 int n = e.toString().indexOf("end tag name \"genres\" differs" 2617 2617 " from start tag name \"genre\""); 2618 2618 assert(n != -1); 2619 2619 } 2620 2620 } 2621 } 2622 2623 unittest 2624 { 2625 string s = q"EOS 2626 <?xml version="1.0" encoding="utf-8"?> <Tests> 2627 <Test thing="What & Up">What & Up Second</Test> 2628 </Tests> 2629 EOS"; 2630 auto xml = new DocumentParser(s); 2631 2632 xml.onStartTag["Test"] = (ElementParser xml) { 2633 assert(xml.tag.attr["thing"] == "What & Up"); 2634 }; 2635 2636 xml.onEndTag["Test"] = (in Element e) { 2637 assert(e.text == "What & Up Second"); 2638 }; 2639 xml.parse(); 2621 2640 } 2622 2641 2623 2642 /** The base class for exceptions thrown by this module */ 2624 2643 class XMLException : Exception { this(string msg) { super(msg); } } 2625 2644 2626 2645 // Other exceptions 2627 2646 2628 2647 /// Thrown during Comment constructor 2629 2648 class CommentException : XMLException 2630 2649 { private this(string msg) { super(msg); } }
