Source Code Cross Referenced for HTMLStripReader.java in  » Search-Engine » apache-solr-1.2.0 » org » apache » solr » analysis » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » apache solr 1.2.0 » org.apache.solr.analysis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */package org.apache.solr.analysis;
0017:
0018:        import java.io.Reader;
0019:        import java.io.BufferedReader;
0020:        import java.io.IOException;
0021:        import java.io.InputStreamReader;
0022:        import java.util.HashMap;
0023:
0024:        /**
0025:         * A Reader that wraps another reader and attempts to strip out HTML constructs.
0026:         *
0027:         *
0028:         * @author yonik
0029:         * @version $Id: HTMLStripReader.java 472574 2006-11-08 18:25:52Z yonik $
0030:         */
0031:
0032:        public class HTMLStripReader extends Reader {
0033:            private final Reader in;
0034:            private final int READAHEAD = 4096;
0035:
0036:            // pushback buffer
0037:            private final StringBuilder pushed = new StringBuilder();
0038:
0039:            private static final int EOF = -1;
0040:            private static final int MISMATCH = -2;
0041:            private static final int MATCH = -3;
0042:
0043:            // temporary buffer
0044:            private final StringBuilder sb = new StringBuilder();
0045:
0046:            public static void main(String[] args) throws IOException {
0047:                Reader in = new HTMLStripReader(
0048:                        new InputStreamReader(System.in));
0049:                int ch;
0050:                while ((ch = in.read()) != -1)
0051:                    System.out.print((char) ch);
0052:            }
0053:
0054:            public HTMLStripReader(Reader source) {
0055:                super ();
0056:                this .in = source.markSupported() ? source : new BufferedReader(
0057:                        source);
0058:            }
0059:
0060:            private int next() throws IOException {
0061:                int len = pushed.length();
0062:                if (len > 0) {
0063:                    int ch = pushed.charAt(len - 1);
0064:                    pushed.setLength(len - 1);
0065:                    return ch;
0066:                }
0067:                return in.read();
0068:            }
0069:
0070:            private int nextSkipWS() throws IOException {
0071:                int ch = next();
0072:                while (isSpace(ch))
0073:                    ch = next();
0074:                return ch;
0075:            }
0076:
0077:            private int peek() throws IOException {
0078:                int len = pushed.length();
0079:                if (len > 0) {
0080:                    return pushed.charAt(len - 1);
0081:                }
0082:                int ch = in.read();
0083:                push(ch);
0084:                return ch;
0085:            }
0086:
0087:            private void push(int ch) {
0088:                pushed.append((char) ch);
0089:            }
0090:
0091:            private boolean isSpace(int ch) {
0092:                switch (ch) {
0093:                case ' ':
0094:                case '\n':
0095:                case '\r':
0096:                case '\t':
0097:                    return true;
0098:                default:
0099:                    return false;
0100:                }
0101:            }
0102:
0103:            private boolean isHex(int ch) {
0104:                return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z')
0105:                        || (ch >= 'a' && ch <= 'z');
0106:            }
0107:
0108:            private boolean isAlpha(int ch) {
0109:                return ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z';
0110:            }
0111:
0112:            private boolean isDigit(int ch) {
0113:                return ch >= '0' && ch <= '9';
0114:            }
0115:
0116:            /*** From HTML 4.0
0117:             [4]   	NameChar	   ::=   	Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
0118:             [5]   	Name	   ::=   	(Letter | '_' | ':') (NameChar)*
0119:             [6]   	Names	   ::=   	Name (#x20 Name)*
0120:             [7]   	Nmtoken	   ::=   	(NameChar)+
0121:             [8]   	Nmtokens	   ::=   	Nmtoken (#x20 Nmtoken)*
0122:             ***/
0123:
0124:            // should I include all id chars allowable by HTML/XML here?
0125:            // including accented chars, ':', etc?
0126:            private boolean isIdChar(int ch) {
0127:                // return Character.isUnicodeIdentifierPart(ch);
0128:                // isUnicodeIdentiferPart doesn't include '-'... shoudl I still
0129:                // use it and add in '-',':',etc?
0130:                return isAlpha(ch) || isDigit(ch) || ch == '.' || ch == '-'
0131:                        || ch == '_' || ch == ':' || Character.isLetter(ch);
0132:
0133:            }
0134:
0135:            private boolean isFirstIdChar(int ch) {
0136:                return Character.isUnicodeIdentifierStart(ch);
0137:                // return isAlpha(ch) || ch=='_' || Character.isLetter(ch);
0138:            }
0139:
0140:            private void saveState() throws IOException {
0141:                in.mark(READAHEAD);
0142:            }
0143:
0144:            private void restoreState() throws IOException {
0145:                in.reset();
0146:                pushed.setLength(0);
0147:            }
0148:
0149:            private int readNumericEntity() throws IOException {
0150:                // "&#" has already been read at this point
0151:
0152:                // is this decimal, hex, or nothing at all.
0153:                int ch = next();
0154:                int base = 10;
0155:                boolean invalid = false;
0156:                sb.setLength(0);
0157:
0158:                if (isDigit(ch)) {
0159:                    // decimal character entity
0160:                    sb.append((char) ch);
0161:                    for (int i = 0; i < 10; i++) {
0162:                        ch = next();
0163:                        if (isDigit(ch)) {
0164:                            sb.append((char) ch);
0165:                        } else {
0166:                            break;
0167:                        }
0168:                    }
0169:                } else if (ch == 'x') {
0170:                    // hex character entity
0171:                    base = 16;
0172:                    sb.setLength(0);
0173:                    for (int i = 0; i < 10; i++) {
0174:                        ch = next();
0175:                        if (isHex(ch)) {
0176:                            sb.append((char) ch);
0177:                        } else {
0178:                            break;
0179:                        }
0180:                    }
0181:                } else {
0182:                    return MISMATCH;
0183:                }
0184:
0185:                // In older HTML, an entity may not have always been terminated
0186:                // with a semicolon.  We'll also treat EOF or whitespace as terminating
0187:                // the entity.
0188:                if (ch == ';' || ch == -1) {
0189:                    return Integer.parseInt(sb.toString(), base);
0190:                }
0191:
0192:                // if whitespace terminated the entity, we need to return
0193:                // that whitespace on the next call to read().
0194:                if (isSpace(ch)) {
0195:                    push(ch);
0196:                    return Integer.parseInt(sb.toString(), base);
0197:                }
0198:
0199:                // Not an entity...
0200:                return MISMATCH;
0201:            }
0202:
0203:            private int readEntity() throws IOException {
0204:                int ch = next();
0205:                if (ch == '#')
0206:                    return readNumericEntity();
0207:
0208:                //read an entity reference
0209:
0210:                // for an entity reference, require the ';' for safety.
0211:                // otherwise we may try and convert part of some company
0212:                // names to an entity.  "Alpha&Beta Corp" for instance.
0213:                //
0214:                // TODO: perhaps I should special case some of the
0215:                // more common ones like &amp to make the ';' optional...
0216:
0217:                sb.setLength(0);
0218:                sb.append((char) ch);
0219:
0220:                for (int i = 0; i < READAHEAD; i++) {
0221:                    ch = next();
0222:                    if (Character.isLetter(ch)) {
0223:                        sb.append((char) ch);
0224:                    } else {
0225:                        break;
0226:                    }
0227:                }
0228:
0229:                if (ch == ';') {
0230:                    String entity = sb.toString();
0231:                    Character entityChar = entityTable.get(entity);
0232:                    if (entityChar != null) {
0233:                        return entityChar.charValue();
0234:                    }
0235:                }
0236:
0237:                return MISMATCH;
0238:            }
0239:
0240:            /*** valid comments according to HTML specs
0241:             <!-- Hello -->
0242:             <!-- Hello -- -- Hello-->
0243:             <!---->
0244:             <!------ Hello -->
0245:             <!>
0246:             <!------> Hello -->
0247:
0248:             #comments inside of an entity decl:
0249:             <!ENTITY amp     CDATA "&#38;"   -- ampersand, U+0026 ISOnum -->
0250:
0251:             Turns out, IE & mozilla don't parse comments correctly.
0252:             Since this is meant to be a practical stripper, I'll just
0253:             try and duplicate what the browsers do.
0254:
0255:             <!-- (stuff_including_markup)* -->
0256:             <!FOO (stuff, not including markup) >
0257:             <! (stuff, not including markup)* >
0258:
0259:
0260:             ***/
0261:
0262:            private int readBang(boolean inScript) throws IOException {
0263:                // at this point, "<!" has been read
0264:
0265:                int ret = readComment(inScript);
0266:                if (ret == MATCH)
0267:                    return MATCH;
0268:
0269:                int ch = next();
0270:                if (ch == '>')
0271:                    return MATCH;
0272:
0273:                // if it starts with <! and isn't a comment,
0274:                // simply read until ">"
0275:                while (true) {
0276:                    ch = next();
0277:                    if (ch == '>') {
0278:                        return MATCH;
0279:                    } else if (ch < 0) {
0280:                        return MISMATCH;
0281:                    }
0282:                }
0283:            }
0284:
0285:            // tries to read comments the way browsers do, not
0286:            // strictly by the standards.
0287:            //
0288:            // GRRRR.  it turns out that in the wild, a <script> can have a HTML comment
0289:            // that contains a script that contains a quoted comment.
0290:            // <script><!-- document.write("<!--embedded comment-->") --></script>
0291:            //
0292:            private int readComment(boolean inScript) throws IOException {
0293:                // at this point "<!" has  been read
0294:                int ch = next();
0295:                if (ch != '-') {
0296:                    // not a comment
0297:                    push(ch);
0298:                    return MISMATCH;
0299:                }
0300:
0301:                ch = next();
0302:                if (ch != '-') {
0303:                    // not a comment
0304:                    push(ch);
0305:                    push('-');
0306:                    return MISMATCH;
0307:                }
0308:
0309:                while (true) {
0310:                    ch = next();
0311:                    if (ch < 0)
0312:                        return MISMATCH;
0313:                    if (ch == '-') {
0314:                        ch = next();
0315:                        if (ch < 0)
0316:                            return MISMATCH;
0317:                        if (ch != '-') {
0318:                            push(ch);
0319:                            continue;
0320:                        }
0321:
0322:                        ch = next();
0323:                        if (ch < 0)
0324:                            return MISMATCH;
0325:                        if (ch != '>') {
0326:                            push(ch);
0327:                            push('-');
0328:                            continue;
0329:                        }
0330:
0331:                        return MATCH;
0332:                    } else if ((ch == '\'' || ch == '"') && inScript) {
0333:                        push(ch);
0334:                        int ret = readScriptString();
0335:                        // if this wasn't a string, there's not much we can do
0336:                        // at this point without having a stack of stream states in
0337:                        // order to "undo" just the latest.
0338:                    } else if (ch == '<') {
0339:                        eatSSI();
0340:                    }
0341:                }
0342:            }
0343:
0344:            private int readTag() throws IOException {
0345:                // at this point '<' has already been read
0346:                int ch = next();
0347:                if (!isAlpha(ch)) {
0348:                    push(ch);
0349:                    return MISMATCH;
0350:                }
0351:
0352:                sb.setLength(0);
0353:                sb.append((char) ch);
0354:
0355:                while (true) {
0356:                    ch = next();
0357:                    if (isIdChar(ch)) {
0358:                        sb.append((char) ch);
0359:                    } else if (ch == '/') {
0360:                        // Hmmm, a tag can close with "/>" as well as "/ >"
0361:                        // read end tag '/>' or '/ >', etc
0362:                        return nextSkipWS() == '>' ? MATCH : MISMATCH;
0363:                    } else {
0364:                        break;
0365:                    }
0366:                }
0367:
0368:                // After the tag id, there needs to be either whitespace or
0369:                // '>'
0370:                if (!(ch == '>' || isSpace(ch))) {
0371:                    return MISMATCH;
0372:                }
0373:
0374:                if (ch != '>') {
0375:                    // process attributes
0376:                    while (true) {
0377:                        ch = next();
0378:                        if (isSpace(ch)) {
0379:                            continue;
0380:                        } else if (isFirstIdChar(ch)) {
0381:                            push(ch);
0382:                            int ret = readAttr2();
0383:                            if (ret == MISMATCH)
0384:                                return ret;
0385:                        } else if (ch == '/') {
0386:                            // read end tag '/>' or '/ >', etc
0387:                            return nextSkipWS() == '>' ? MATCH : MISMATCH;
0388:                        } else if (ch == '>') {
0389:                            break;
0390:                        } else {
0391:                            return MISMATCH;
0392:                        }
0393:                    }
0394:                }
0395:
0396:                // We only get to this point after we have read the
0397:                // entire tag.  Now let's see if it's a special tag.
0398:                String name = sb.toString();
0399:                if (name.equals("script") || name.equals("style")) {
0400:                    // The content of script and style elements is
0401:                    //  CDATA in HTML 4 but PCDATA in XHTML.
0402:
0403:                    /* From HTML4:
0404:                      Although the STYLE and SCRIPT elements use CDATA for their data model,
0405:                      for these elements, CDATA must be handled differently by user agents.
0406:                      Markup and entities must be treated as raw text and passed to the application
0407:                      as is. The first occurrence of the character sequence "</" (end-tag open
0408:                      delimiter) is treated as terminating the end of the element's content. In
0409:                      valid documents, this would be the end tag for the element.
0410:                     */
0411:
0412:                    // discard everything until endtag is hit (except
0413:                    // if it occurs in a comment.
0414:                    // reset the stream mark to here, since we know that we sucessfully matched
0415:                    // a tag, and if we can't find the end tag, this is where we will want
0416:                    // to roll back to.
0417:                    saveState();
0418:                    pushed.setLength(0);
0419:                    return findEndTag();
0420:                }
0421:                return MATCH;
0422:            }
0423:
0424:            // find an end tag, but beware of comments...
0425:            // <script><!-- </script> -->foo</script>
0426:            // beware markup in script strings: </script>...document.write("</script>")foo</script>
0427:            // TODO: do I need to worry about CDATA sections "<![CDATA["  ?
0428:            int findEndTag() throws IOException {
0429:                while (true) {
0430:                    int ch = next();
0431:                    if (ch == '<') {
0432:                        ch = next();
0433:                        // skip looking for end-tag in comments
0434:                        if (ch == '!') {
0435:                            int ret = readBang(true);
0436:                            if (ret == MATCH)
0437:                                continue;
0438:                            // yikes... what now?  It wasn't a comment, but I can't get
0439:                            // back to the state I was at.  Just continue from where I
0440:                            // am I guess...
0441:                            continue;
0442:                        }
0443:                        // did we match "</"
0444:                        if (ch != '/') {
0445:                            push(ch);
0446:                            continue;
0447:                        }
0448:                        int ret = readName();
0449:                        if (ret == MISMATCH)
0450:                            return MISMATCH;
0451:                        ch = nextSkipWS();
0452:                        if (ch != '>')
0453:                            return MISMATCH;
0454:                        return MATCH;
0455:                    } else if (ch == '\'' || ch == '"') {
0456:                        // read javascript string to avoid a false match.
0457:                        push(ch);
0458:                        int ret = readScriptString();
0459:                        // what to do about a non-match (non-terminated string?)
0460:                        // play it safe and index the rest of the data I guess...
0461:                        if (ret == MISMATCH)
0462:                            return MISMATCH;
0463:                    } else if (ch < 0) {
0464:                        return MISMATCH;
0465:                    }
0466:                }
0467:            }
0468:
0469:            // read a string escaped by backslashes
0470:            private int readScriptString() throws IOException {
0471:                int quoteChar = next();
0472:                if (quoteChar != '\'' && quoteChar != '"')
0473:                    return MISMATCH;
0474:                while (true) {
0475:                    int ch = next();
0476:                    if (ch == quoteChar)
0477:                        return MATCH;
0478:                    else if (ch == '\\') {
0479:                        ch = next();
0480:                    } else if (ch < 0) {
0481:                        return MISMATCH;
0482:                    } else if (ch == '<') {
0483:                        eatSSI();
0484:                    }
0485:                }
0486:            }
0487:
0488:            private int readName() throws IOException {
0489:                int ch = read();
0490:                if (!isFirstIdChar(ch))
0491:                    return MISMATCH;
0492:                ch = read();
0493:                while (isIdChar(ch))
0494:                    ch = read();
0495:                if (ch != -1)
0496:                    push(ch);
0497:                return MATCH;
0498:            }
0499:
0500:            /***
0501:            [10]   	AttValue	   ::=   	'"' ([^<&"] | Reference)* '"'
0502:                  |  "'" ([^<&'] | Reference)* "'"
0503:
0504:            need to also handle unquoted attributes, and attributes w/o values:
0505:            <td id=msviGlobalToolbar height="22" nowrap align=left>
0506:
0507:             ***/
0508:            private int readAttr() throws IOException {
0509:                int ch = read();
0510:                if (!isFirstIdChar(ch))
0511:                    return MISMATCH;
0512:                ch = read();
0513:                while (isIdChar(ch))
0514:                    ch = read();
0515:                if (isSpace(ch))
0516:                    ch = nextSkipWS();
0517:
0518:                // attributes may not have a value at all!
0519:                // if (ch != '=') return MISMATCH;
0520:                if (ch != '=') {
0521:                    push(ch);
0522:                    return MATCH;
0523:                }
0524:
0525:                int quoteChar = nextSkipWS();
0526:
0527:                if (quoteChar == '"' || quoteChar == '\'') {
0528:                    // TODO: should I set a max size to try and find the other
0529:                    // quote?  Otherwise, I may read to much to restore
0530:                    // the stream.
0531:                    while (true) {
0532:                        ch = next();
0533:                        if (ch < 0)
0534:                            return MISMATCH;
0535:                        else if (ch == quoteChar) {
0536:                            return MATCH;
0537:                            //} else if (ch=='<') {
0538:                            //  return MISMATCH;
0539:                        }
0540:                    }
0541:                } else {
0542:                    // unquoted attribute
0543:                    while (true) {
0544:                        ch = next();
0545:                        if (ch < 0)
0546:                            return MISMATCH;
0547:                        else if (isSpace(ch)) {
0548:                            push(ch);
0549:                            return MATCH;
0550:                        } else if (ch == '>') {
0551:                            push(ch);
0552:                            return MATCH;
0553:                        }
0554:                    }
0555:                }
0556:
0557:            }
0558:
0559:            // This reads attributes and attempts to handle any
0560:            // embedded server side includes that would otherwise
0561:            // mess up the quote handling.
0562:            //  <a href="a/<!--#echo "path"-->">
0563:            private int readAttr2() throws IOException {
0564:                int ch = read();
0565:                if (!isFirstIdChar(ch))
0566:                    return MISMATCH;
0567:                ch = read();
0568:                while (isIdChar(ch))
0569:                    ch = read();
0570:                if (isSpace(ch))
0571:                    ch = nextSkipWS();
0572:
0573:                // attributes may not have a value at all!
0574:                // if (ch != '=') return MISMATCH;
0575:                if (ch != '=') {
0576:                    push(ch);
0577:                    return MATCH;
0578:                }
0579:
0580:                int quoteChar = nextSkipWS();
0581:
0582:                if (quoteChar == '"' || quoteChar == '\'') {
0583:                    // TODO: should I set a max size to try and find the other
0584:                    // quote?  Otherwise, I may read to much to restore
0585:                    // the stream.
0586:                    while (true) {
0587:                        ch = next();
0588:                        if (ch < 0)
0589:                            return MISMATCH;
0590:                        else if (ch == '<') {
0591:                            eatSSI();
0592:                        } else if (ch == quoteChar) {
0593:                            return MATCH;
0594:                            //} else if (ch=='<') {
0595:                            //  return MISMATCH;
0596:                        }
0597:                    }
0598:                } else {
0599:                    // unquoted attribute
0600:                    while (true) {
0601:                        ch = next();
0602:                        if (ch < 0)
0603:                            return MISMATCH;
0604:                        else if (isSpace(ch)) {
0605:                            push(ch);
0606:                            return MATCH;
0607:                        } else if (ch == '>') {
0608:                            push(ch);
0609:                            return MATCH;
0610:                        } else if (ch == '<') {
0611:                            eatSSI();
0612:                        }
0613:                    }
0614:                }
0615:
0616:            }
0617:
0618:            // skip past server side include
0619:            private int eatSSI() throws IOException {
0620:                // at this point, only a "<" was read.
0621:                // on a mismatch, push back the last char so that if it was
0622:                // a quote that closes the attribute, it will be re-read and matched.
0623:                int ch = next();
0624:                if (ch != '!') {
0625:                    push(ch);
0626:                    return MISMATCH;
0627:                }
0628:                ch = next();
0629:                if (ch != '-') {
0630:                    push(ch);
0631:                    return MISMATCH;
0632:                }
0633:                ch = next();
0634:                if (ch != '-') {
0635:                    push(ch);
0636:                    return MISMATCH;
0637:                }
0638:                ch = next();
0639:                if (ch != '#') {
0640:                    push(ch);
0641:                    return MISMATCH;
0642:                }
0643:
0644:                push('#');
0645:                push('-');
0646:                push('-');
0647:                return readComment(false);
0648:            }
0649:
0650:            private int readProcessingInstruction() throws IOException {
0651:                // "<?" has already been read
0652:
0653:                while (true) {
0654:                    int ch = next();
0655:                    if (ch == '?' && peek() == '>') {
0656:                        next();
0657:                        return MATCH;
0658:                    } else if (ch == -1) {
0659:                        return MISMATCH;
0660:                    }
0661:                }
0662:            }
0663:
0664:            public int read() throws IOException {
0665:                // TODO: Do we ever want to preserve CDATA sections?
0666:                // where do we have to worry about them?
0667:                // <![ CDATA [ unescaped markup ]]>
0668:
0669:                while (true) {
0670:                    int ch = next();
0671:
0672:                    switch (ch) {
0673:                    case '&':
0674:                        saveState();
0675:                        ch = readEntity();
0676:                        if (ch >= 0)
0677:                            return ch;
0678:                        if (ch == MISMATCH) {
0679:                            restoreState();
0680:                            return '&';
0681:                        }
0682:                        break;
0683:
0684:                    case '<':
0685:                        saveState();
0686:                        ch = next();
0687:                        int ret = MISMATCH;
0688:                        if (ch == '!') {
0689:                            ret = readBang(false);
0690:                        } else if (ch == '/') {
0691:                            ret = readName();
0692:                            if (ret == MATCH) {
0693:                                ch = nextSkipWS();
0694:                                ret = ch == '>' ? MATCH : MISMATCH;
0695:                            }
0696:                        } else if (isAlpha(ch)) {
0697:                            push(ch);
0698:                            ret = readTag();
0699:                        } else if (ch == '?') {
0700:                            ret = readProcessingInstruction();
0701:                        }
0702:
0703:                        // matched something to be discarded, so break
0704:                        // from this case and continue in the loop
0705:                        if (ret == MATCH)
0706:                            break;
0707:
0708:                        // didn't match any HTML constructs, so roll back
0709:                        // the stream state and just return '<'
0710:                        restoreState();
0711:                        return '<';
0712:
0713:                    default:
0714:                        return ch;
0715:                    }
0716:
0717:                }
0718:
0719:            }
0720:
0721:            public int read(char cbuf[], int off, int len) throws IOException {
0722:                int i = 0;
0723:                for (i = 0; i < len; i++) {
0724:                    int ch = read();
0725:                    if (ch == -1)
0726:                        break;
0727:                    cbuf[off++] = (char) ch;
0728:                }
0729:                if (i == 0) {
0730:                    if (len == 0)
0731:                        return 0;
0732:                    return -1;
0733:                }
0734:                return i;
0735:            }
0736:
0737:            public void close() throws IOException {
0738:                in.close();
0739:            }
0740:
0741:            private static final HashMap<String, Character> entityTable;
0742:            static {
0743:                entityTable = new HashMap<String, Character>();
0744:                // entityName and entityVal generated from the python script
0745:                // included in comments at the end of this file.
0746:                final String[] entityName = { "zwnj", "aring", "gt", "yen",
0747:                        "ograve", "Chi", "delta", "rang", "sup", "trade",
0748:                        "Ntilde", "xi", "upsih", "nbsp", "Atilde", "radic",
0749:                        "otimes", "aelig", "oelig", "equiv", "ni", "infin",
0750:                        "Psi", "auml", "cup", "Epsilon", "otilde", "lt",
0751:                        "Icirc", "Eacute", "Lambda", "sbquo", "Prime", "prime",
0752:                        "psi", "Kappa", "rsaquo", "Tau", "uacute", "ocirc",
0753:                        "lrm", "zwj", "cedil", "Alpha", "not", "amp", "AElig",
0754:                        "oslash", "acute", "lceil", "alefsym", "laquo", "shy",
0755:                        "loz", "ge", "Igrave", "nu", "Ograve", "lsaquo",
0756:                        "sube", "euro", "rarr", "sdot", "rdquo", "Yacute",
0757:                        "lfloor", "lArr", "Auml", "Dagger", "brvbar", "Otilde",
0758:                        "szlig", "clubs", "diams", "agrave", "Ocirc", "Iota",
0759:                        "Theta", "Pi", "zeta", "Scaron", "frac14", "egrave",
0760:                        "sub", "iexcl", "frac12", "ordf", "sum", "prop",
0761:                        "Uuml", "ntilde", "atilde", "asymp", "uml", "prod",
0762:                        "nsub", "reg", "rArr", "Oslash", "emsp", "THORN",
0763:                        "yuml", "aacute", "Mu", "hArr", "le", "thinsp", "dArr",
0764:                        "ecirc", "bdquo", "Sigma", "Aring", "tilde", "nabla",
0765:                        "mdash", "uarr", "times", "Ugrave", "Eta", "Agrave",
0766:                        "chi", "real", "circ", "eth", "rceil", "iuml", "gamma",
0767:                        "lambda", "harr", "Egrave", "frac34", "dagger",
0768:                        "divide", "Ouml", "image", "ndash", "hellip", "igrave",
0769:                        "Yuml", "ang", "alpha", "frasl", "ETH", "lowast", "Nu",
0770:                        "plusmn", "bull", "sup1", "sup2", "sup3", "Aacute",
0771:                        "cent", "oline", "Beta", "perp", "Delta", "there4",
0772:                        "pi", "iota", "empty", "euml", "notin", "iacute",
0773:                        "para", "epsilon", "weierp", "OElig", "uuml", "larr",
0774:                        "icirc", "Upsilon", "omicron", "upsilon", "copy",
0775:                        "Iuml", "Oacute", "Xi", "kappa", "ccedil", "Ucirc",
0776:                        "cap", "mu", "scaron", "lsquo", "isin", "Zeta",
0777:                        "minus", "deg", "and", "tau", "pound", "curren", "int",
0778:                        "ucirc", "rfloor", "ensp", "crarr", "ugrave", "exist",
0779:                        "cong", "theta", "oplus", "permil", "Acirc", "piv",
0780:                        "Euml", "Phi", "Iacute", "quot", "Uacute", "Omicron",
0781:                        "ne", "iquest", "eta", "rsquo", "yacute", "Rho",
0782:                        "darr", "Ecirc", "Omega", "acirc", "sim", "phi",
0783:                        "sigmaf", "macr", "thetasym", "Ccedil", "ordm", "uArr",
0784:                        "forall", "beta", "fnof", "rho", "micro", "eacute",
0785:                        "omega", "middot", "Gamma", "rlm", "lang", "spades",
0786:                        "supe", "thorn", "ouml", "or", "raquo", "part", "sect",
0787:                        "ldquo", "hearts", "sigma", "oacute" };
0788:                final char[] entityVal = { 8204, 229, 62, 165, 242, 935, 948,
0789:                        9002, 8835, 8482, 209, 958, 978, 160, 195, 8730, 8855,
0790:                        230, 339, 8801, 8715, 8734, 936, 228, 8746, 917, 245,
0791:                        60, 206, 201, 923, 8218, 8243, 8242, 968, 922, 8250,
0792:                        932, 250, 244, 8206, 8205, 184, 913, 172, 38, 198, 248,
0793:                        180, 8968, 8501, 171, 173, 9674, 8805, 204, 957, 210,
0794:                        8249, 8838, 8364, 8594, 8901, 8221, 221, 8970, 8656,
0795:                        196, 8225, 166, 213, 223, 9827, 9830, 224, 212, 921,
0796:                        920, 928, 950, 352, 188, 232, 8834, 161, 189, 170,
0797:                        8721, 8733, 220, 241, 227, 8776, 168, 8719, 8836, 174,
0798:                        8658, 216, 8195, 222, 255, 225, 924, 8660, 8804, 8201,
0799:                        8659, 234, 8222, 931, 197, 732, 8711, 8212, 8593, 215,
0800:                        217, 919, 192, 967, 8476, 710, 240, 8969, 239, 947,
0801:                        955, 8596, 200, 190, 8224, 247, 214, 8465, 8211, 8230,
0802:                        236, 376, 8736, 945, 8260, 208, 8727, 925, 177, 8226,
0803:                        185, 178, 179, 193, 162, 8254, 914, 8869, 916, 8756,
0804:                        960, 953, 8709, 235, 8713, 237, 182, 949, 8472, 338,
0805:                        252, 8592, 238, 933, 959, 965, 169, 207, 211, 926, 954,
0806:                        231, 219, 8745, 956, 353, 8216, 8712, 918, 8722, 176,
0807:                        8743, 964, 163, 164, 8747, 251, 8971, 8194, 8629, 249,
0808:                        8707, 8773, 952, 8853, 8240, 194, 982, 203, 934, 205,
0809:                        34, 218, 927, 8800, 191, 951, 8217, 253, 929, 8595,
0810:                        202, 937, 226, 8764, 966, 962, 175, 977, 199, 186,
0811:                        8657, 8704, 946, 402, 961, 181, 233, 969, 183, 915,
0812:                        8207, 9001, 9824, 8839, 254, 246, 8744, 187, 8706, 167,
0813:                        8220, 9829, 963, 243 };
0814:                for (int i = 0; i < entityName.length; i++) {
0815:                    entityTable.put(entityName[i], new Character(entityVal[i]));
0816:                }
0817:                // special-case nbsp to a simple space instead of 0xa0
0818:                entityTable.put("nbsp", new Character(' '));
0819:            }
0820:
0821:        }
0822:
0823:        /********************* htmlentity.py **********************
0824:         # a simple python script to generate an HTML entity table
0825:         # from text taken from http://www.w3.org/TR/REC-html40/sgml/entities.html
0826:
0827:         text="""
0828:         24 Character entity references in HTML 4
0829:
0830:         Contents
0831:
0832:         1. Introduction to character entity references
0833:         2. Character entity references for ISO 8859-1 characters
0834:         1. The list of characters
0835:         3. Character entity references for symbols, mathematical symbols, and Greek letters
0836:         1. The list of characters
0837:         4. Character entity references for markup-significant and internationalization characters
0838:         1. The list of characters
0839:
0840:         24.1 Introduction to character entity references
0841:         A character entity reference is an SGML construct that references a character of the document character set.
0842:
0843:         This version of HTML supports several sets of character entity references:
0844:
0845:         * ISO 8859-1 (Latin-1) characters In accordance with section 14 of [RFC1866], the set of Latin-1 entities has been extended by this specification to cover the whole right part of ISO-8859-1 (all code positions with the high-order bit set), including the already commonly used &nbsp;, &copy; and &reg;. The names of the entities are taken from the appendices of SGML (defined in [ISO8879]).
0846:         * symbols, mathematical symbols, and Greek letters. These characters may be represented by glyphs in the Adobe font "Symbol".
0847:         * markup-significant and internationalization characters (e.g., for bidirectional text).
0848:
0849:         The following sections present the complete lists of character entity references. Although, by convention, [ISO10646] the comments following each entry are usually written with uppercase letters, we have converted them to lowercase in this specification for reasons of readability.
0850:         24.2 Character entity references for ISO 8859-1 characters
0851:
0852:         The character entity references in this section produce characters whose numeric equivalents should already be supported by conforming HTML 2.0 user agents. Thus, the character entity reference &divide; is a more convenient form than &#247; for obtaining the division sign.
0853:
0854:         To support these named entities, user agents need only recognize the entity names and convert them to characters that lie within the repertoire of [ISO88591].
0855:
0856:         Character 65533 (FFFD hexadecimal) is the last valid character in UCS-2. 65534 (FFFE hexadecimal) is unassigned and reserved as the byte-swapped version of ZERO WIDTH NON-BREAKING SPACE for byte-order detection purposes. 65535 (FFFF hexadecimal) is unassigned.
0857:         24.2.1 The list of characters
0858:
0859:         <!-- Portions (c) International Organization for Standardization 1986
0860:         Permission to copy in any form is granted for use with
0861:         conforming SGML systems and applications as defined in
0862:         ISO 8879, provided this notice is included in all copies.
0863:         -->
0864:         <!-- Character entity set. Typical invocation:
0865:         <!ENTITY % HTMLlat1 PUBLIC
0866:         "-//W3C//ENTITIES Latin 1//EN//HTML">
0867:         %HTMLlat1;
0868:         -->
0869:
0870:         <!ENTITY nbsp   CDATA "&#160;" -- no-break space = non-breaking space,
0871:         U+00A0 ISOnum -->
0872:         <!ENTITY iexcl  CDATA "&#161;" -- inverted exclamation mark, U+00A1 ISOnum -->
0873:         <!ENTITY cent   CDATA "&#162;" -- cent sign, U+00A2 ISOnum -->
0874:         <!ENTITY pound  CDATA "&#163;" -- pound sign, U+00A3 ISOnum -->
0875:         <!ENTITY curren CDATA "&#164;" -- currency sign, U+00A4 ISOnum -->
0876:         <!ENTITY yen    CDATA "&#165;" -- yen sign = yuan sign, U+00A5 ISOnum -->
0877:         <!ENTITY brvbar CDATA "&#166;" -- broken bar = broken vertical bar,
0878:         U+00A6 ISOnum -->
0879:         <!ENTITY sect   CDATA "&#167;" -- section sign, U+00A7 ISOnum -->
0880:         <!ENTITY uml    CDATA "&#168;" -- diaeresis = spacing diaeresis,
0881:         U+00A8 ISOdia -->
0882:         <!ENTITY copy   CDATA "&#169;" -- copyright sign, U+00A9 ISOnum -->
0883:         <!ENTITY ordf   CDATA "&#170;" -- feminine ordinal indicator, U+00AA ISOnum -->
0884:         <!ENTITY laquo  CDATA "&#171;" -- left-pointing double angle quotation mark
0885:         = left pointing guillemet, U+00AB ISOnum -->
0886:         <!ENTITY not    CDATA "&#172;" -- not sign, U+00AC ISOnum -->
0887:         <!ENTITY shy    CDATA "&#173;" -- soft hyphen = discretionary hyphen,
0888:         U+00AD ISOnum -->
0889:         <!ENTITY reg    CDATA "&#174;" -- registered sign = registered trade mark sign,
0890:         U+00AE ISOnum -->
0891:         <!ENTITY macr   CDATA "&#175;" -- macron = spacing macron = overline
0892:         = APL overbar, U+00AF ISOdia -->
0893:         <!ENTITY deg    CDATA "&#176;" -- degree sign, U+00B0 ISOnum -->
0894:         <!ENTITY plusmn CDATA "&#177;" -- plus-minus sign = plus-or-minus sign,
0895:         U+00B1 ISOnum -->
0896:         <!ENTITY sup2   CDATA "&#178;" -- superscript two = superscript digit two
0897:         = squared, U+00B2 ISOnum -->
0898:         <!ENTITY sup3   CDATA "&#179;" -- superscript three = superscript digit three
0899:         = cubed, U+00B3 ISOnum -->
0900:         <!ENTITY acute  CDATA "&#180;" -- acute accent = spacing acute,
0901:         U+00B4 ISOdia -->
0902:         <!ENTITY micro  CDATA "&#181;" -- micro sign, U+00B5 ISOnum -->
0903:         <!ENTITY para   CDATA "&#182;" -- pilcrow sign = paragraph sign,
0904:         U+00B6 ISOnum -->
0905:         <!ENTITY middot CDATA "&#183;" -- middle dot = Georgian comma
0906:         = Greek middle dot, U+00B7 ISOnum -->
0907:         <!ENTITY cedil  CDATA "&#184;" -- cedilla = spacing cedilla, U+00B8 ISOdia -->
0908:         <!ENTITY sup1   CDATA "&#185;" -- superscript one = superscript digit one,
0909:         U+00B9 ISOnum -->
0910:         <!ENTITY ordm   CDATA "&#186;" -- masculine ordinal indicator,
0911:         U+00BA ISOnum -->
0912:         <!ENTITY raquo  CDATA "&#187;" -- right-pointing double angle quotation mark
0913:         = right pointing guillemet, U+00BB ISOnum -->
0914:         <!ENTITY frac14 CDATA "&#188;" -- vulgar fraction one quarter
0915:         = fraction one quarter, U+00BC ISOnum -->
0916:         <!ENTITY frac12 CDATA "&#189;" -- vulgar fraction one half
0917:         = fraction one half, U+00BD ISOnum -->
0918:         <!ENTITY frac34 CDATA "&#190;" -- vulgar fraction three quarters
0919:         = fraction three quarters, U+00BE ISOnum -->
0920:         <!ENTITY iquest CDATA "&#191;" -- inverted question mark
0921:         = turned question mark, U+00BF ISOnum -->
0922:         <!ENTITY Agrave CDATA "&#192;" -- latin capital letter A with grave
0923:         = latin capital letter A grave,
0924:         U+00C0 ISOlat1 -->
0925:         <!ENTITY Aacute CDATA "&#193;" -- latin capital letter A with acute,
0926:         U+00C1 ISOlat1 -->
0927:         <!ENTITY Acirc  CDATA "&#194;" -- latin capital letter A with circumflex,
0928:         U+00C2 ISOlat1 -->
0929:         <!ENTITY Atilde CDATA "&#195;" -- latin capital letter A with tilde,
0930:         U+00C3 ISOlat1 -->
0931:         <!ENTITY Auml   CDATA "&#196;" -- latin capital letter A with diaeresis,
0932:         U+00C4 ISOlat1 -->
0933:         <!ENTITY Aring  CDATA "&#197;" -- latin capital letter A with ring above
0934:         = latin capital letter A ring,
0935:         U+00C5 ISOlat1 -->
0936:         <!ENTITY AElig  CDATA "&#198;" -- latin capital letter AE
0937:         = latin capital ligature AE,
0938:         U+00C6 ISOlat1 -->
0939:         <!ENTITY Ccedil CDATA "&#199;" -- latin capital letter C with cedilla,
0940:         U+00C7 ISOlat1 -->
0941:         <!ENTITY Egrave CDATA "&#200;" -- latin capital letter E with grave,
0942:         U+00C8 ISOlat1 -->
0943:         <!ENTITY Eacute CDATA "&#201;" -- latin capital letter E with acute,
0944:         U+00C9 ISOlat1 -->
0945:         <!ENTITY Ecirc  CDATA "&#202;" -- latin capital letter E with circumflex,
0946:         U+00CA ISOlat1 -->
0947:         <!ENTITY Euml   CDATA "&#203;" -- latin capital letter E with diaeresis,
0948:         U+00CB ISOlat1 -->
0949:         <!ENTITY Igrave CDATA "&#204;" -- latin capital letter I with grave,
0950:         U+00CC ISOlat1 -->
0951:         <!ENTITY Iacute CDATA "&#205;" -- latin capital letter I with acute,
0952:         U+00CD ISOlat1 -->
0953:         <!ENTITY Icirc  CDATA "&#206;" -- latin capital letter I with circumflex,
0954:         U+00CE ISOlat1 -->
0955:         <!ENTITY Iuml   CDATA "&#207;" -- latin capital letter I with diaeresis,
0956:         U+00CF ISOlat1 -->
0957:         <!ENTITY ETH    CDATA "&#208;" -- latin capital letter ETH, U+00D0 ISOlat1 -->
0958:         <!ENTITY Ntilde CDATA "&#209;" -- latin capital letter N with tilde,
0959:         U+00D1 ISOlat1 -->
0960:         <!ENTITY Ograve CDATA "&#210;" -- latin capital letter O with grave,
0961:         U+00D2 ISOlat1 -->
0962:         <!ENTITY Oacute CDATA "&#211;" -- latin capital letter O with acute,
0963:         U+00D3 ISOlat1 -->
0964:         <!ENTITY Ocirc  CDATA "&#212;" -- latin capital letter O with circumflex,
0965:         U+00D4 ISOlat1 -->
0966:         <!ENTITY Otilde CDATA "&#213;" -- latin capital letter O with tilde,
0967:         U+00D5 ISOlat1 -->
0968:         <!ENTITY Ouml   CDATA "&#214;" -- latin capital letter O with diaeresis,
0969:         U+00D6 ISOlat1 -->
0970:         <!ENTITY times  CDATA "&#215;" -- multiplication sign, U+00D7 ISOnum -->
0971:         <!ENTITY Oslash CDATA "&#216;" -- latin capital letter O with stroke
0972:         = latin capital letter O slash,
0973:         U+00D8 ISOlat1 -->
0974:         <!ENTITY Ugrave CDATA "&#217;" -- latin capital letter U with grave,
0975:         U+00D9 ISOlat1 -->
0976:         <!ENTITY Uacute CDATA "&#218;" -- latin capital letter U with acute,
0977:         U+00DA ISOlat1 -->
0978:         <!ENTITY Ucirc  CDATA "&#219;" -- latin capital letter U with circumflex,
0979:         U+00DB ISOlat1 -->
0980:         <!ENTITY Uuml   CDATA "&#220;" -- latin capital letter U with diaeresis,
0981:         U+00DC ISOlat1 -->
0982:         <!ENTITY Yacute CDATA "&#221;" -- latin capital letter Y with acute,
0983:         U+00DD ISOlat1 -->
0984:         <!ENTITY THORN  CDATA "&#222;" -- latin capital letter THORN,
0985:         U+00DE ISOlat1 -->
0986:         <!ENTITY szlig  CDATA "&#223;" -- latin small letter sharp s = ess-zed,
0987:         U+00DF ISOlat1 -->
0988:         <!ENTITY agrave CDATA "&#224;" -- latin small letter a with grave
0989:         = latin small letter a grave,
0990:         U+00E0 ISOlat1 -->
0991:         <!ENTITY aacute CDATA "&#225;" -- latin small letter a with acute,
0992:         U+00E1 ISOlat1 -->
0993:         <!ENTITY acirc  CDATA "&#226;" -- latin small letter a with circumflex,
0994:         U+00E2 ISOlat1 -->
0995:         <!ENTITY atilde CDATA "&#227;" -- latin small letter a with tilde,
0996:         U+00E3 ISOlat1 -->
0997:         <!ENTITY auml   CDATA "&#228;" -- latin small letter a with diaeresis,
0998:         U+00E4 ISOlat1 -->
0999:         <!ENTITY aring  CDATA "&#229;" -- latin small letter a with ring above
1000:         = latin small letter a ring,
1001:         U+00E5 ISOlat1 -->
1002:         <!ENTITY aelig  CDATA "&#230;" -- latin small letter ae
1003:         = latin small ligature ae, U+00E6 ISOlat1 -->
1004:         <!ENTITY ccedil CDATA "&#231;" -- latin small letter c with cedilla,
1005:         U+00E7 ISOlat1 -->
1006:         <!ENTITY egrave CDATA "&#232;" -- latin small letter e with grave,
1007:         U+00E8 ISOlat1 -->
1008:         <!ENTITY eacute CDATA "&#233;" -- latin small letter e with acute,
1009:         U+00E9 ISOlat1 -->
1010:         <!ENTITY ecirc  CDATA "&#234;" -- latin small letter e with circumflex,
1011:         U+00EA ISOlat1 -->
1012:         <!ENTITY euml   CDATA "&#235;" -- latin small letter e with diaeresis,
1013:         U+00EB ISOlat1 -->
1014:         <!ENTITY igrave CDATA "&#236;" -- latin small letter i with grave,
1015:         U+00EC ISOlat1 -->
1016:         <!ENTITY iacute CDATA "&#237;" -- latin small letter i with acute,
1017:         U+00ED ISOlat1 -->
1018:         <!ENTITY icirc  CDATA "&#238;" -- latin small letter i with circumflex,
1019:         U+00EE ISOlat1 -->
1020:         <!ENTITY iuml   CDATA "&#239;" -- latin small letter i with diaeresis,
1021:         U+00EF ISOlat1 -->
1022:         <!ENTITY eth    CDATA "&#240;" -- latin small letter eth, U+00F0 ISOlat1 -->
1023:         <!ENTITY ntilde CDATA "&#241;" -- latin small letter n with tilde,
1024:         U+00F1 ISOlat1 -->
1025:         <!ENTITY ograve CDATA "&#242;" -- latin small letter o with grave,
1026:         U+00F2 ISOlat1 -->
1027:         <!ENTITY oacute CDATA "&#243;" -- latin small letter o with acute,
1028:         U+00F3 ISOlat1 -->
1029:         <!ENTITY ocirc  CDATA "&#244;" -- latin small letter o with circumflex,
1030:         U+00F4 ISOlat1 -->
1031:         <!ENTITY otilde CDATA "&#245;" -- latin small letter o with tilde,
1032:         U+00F5 ISOlat1 -->
1033:         <!ENTITY ouml   CDATA "&#246;" -- latin small letter o with diaeresis,
1034:         U+00F6 ISOlat1 -->
1035:         <!ENTITY divide CDATA "&#247;" -- division sign, U+00F7 ISOnum -->
1036:         <!ENTITY oslash CDATA "&#248;" -- latin small letter o with stroke,
1037:         = latin small letter o slash,
1038:         U+00F8 ISOlat1 -->
1039:         <!ENTITY ugrave CDATA "&#249;" -- latin small letter u with grave,
1040:         U+00F9 ISOlat1 -->
1041:         <!ENTITY uacute CDATA "&#250;" -- latin small letter u with acute,
1042:         U+00FA ISOlat1 -->
1043:         <!ENTITY ucirc  CDATA "&#251;" -- latin small letter u with circumflex,
1044:         U+00FB ISOlat1 -->
1045:         <!ENTITY uuml   CDATA "&#252;" -- latin small letter u with diaeresis,
1046:         U+00FC ISOlat1 -->
1047:         <!ENTITY yacute CDATA "&#253;" -- latin small letter y with acute,
1048:         U+00FD ISOlat1 -->
1049:         <!ENTITY thorn  CDATA "&#254;" -- latin small letter thorn,
1050:         U+00FE ISOlat1 -->
1051:         <!ENTITY yuml   CDATA "&#255;" -- latin small letter y with diaeresis,
1052:         U+00FF ISOlat1 -->
1053:
1054:         24.3 Character entity references for symbols, mathematical symbols, and Greek letters
1055:
1056:         The character entity references in this section produce characters that may be represented by glyphs in the widely available Adobe Symbol font, including Greek characters, various bracketing symbols, and a selection of mathematical operators such as gradient, product, and summation symbols.
1057:
1058:         To support these entities, user agents may support full [ISO10646] or use other means. Display of glyphs for these characters may be obtained by being able to display the relevant [ISO10646] characters or by other means, such as internally mapping the listed entities, numeric character references, and characters to the appropriate position in some font that contains the requisite glyphs.
1059:
1060:         When to use Greek entities. This entity set contains all the letters used in modern Greek. However, it does not include Greek punctuation, precomposed accented characters nor the non-spacing accents (tonos, dialytika) required to compose them. There are no archaic letters, Coptic-unique letters, or precomposed letters for Polytonic Greek. The entities defined here are not intended for the representation of modern Greek text and would not be an efficient representation; rather, they are intended for occasional Greek letters used in technical and mathematical works.
1061:         24.3.1 The list of characters
1062:
1063:         <!-- Mathematical, Greek and Symbolic characters for HTML -->
1064:
1065:         <!-- Character entity set. Typical invocation:
1066:         <!ENTITY % HTMLsymbol PUBLIC
1067:         "-//W3C//ENTITIES Symbols//EN//HTML">
1068:         %HTMLsymbol; -->
1069:
1070:         <!-- Portions (c) International Organization for Standardization 1986:
1071:         Permission to copy in any form is granted for use with
1072:         conforming SGML systems and applications as defined in
1073:         ISO 8879, provided this notice is included in all copies.
1074:         -->
1075:
1076:         <!-- Relevant ISO entity set is given unless names are newly introduced.
1077:         New names (i.e., not in ISO 8879 list) do not clash with any
1078:         existing ISO 8879 entity names. ISO 10646 character numbers
1079:         are given for each character, in hex. CDATA values are decimal
1080:         conversions of the ISO 10646 values and refer to the document
1081:         character set. Names are ISO 10646 names.
1082:
1083:         -->
1084:
1085:         <!-- Latin Extended-B -->
1086:         <!ENTITY fnof     CDATA "&#402;" -- latin small f with hook = function
1087:         = florin, U+0192 ISOtech -->
1088:
1089:         <!-- Greek -->
1090:         <!ENTITY Alpha    CDATA "&#913;" -- greek capital letter alpha, U+0391 -->
1091:         <!ENTITY Beta     CDATA "&#914;" -- greek capital letter beta, U+0392 -->
1092:         <!ENTITY Gamma    CDATA "&#915;" -- greek capital letter gamma,
1093:         U+0393 ISOgrk3 -->
1094:         <!ENTITY Delta    CDATA "&#916;" -- greek capital letter delta,
1095:         U+0394 ISOgrk3 -->
1096:         <!ENTITY Epsilon  CDATA "&#917;" -- greek capital letter epsilon, U+0395 -->
1097:         <!ENTITY Zeta     CDATA "&#918;" -- greek capital letter zeta, U+0396 -->
1098:         <!ENTITY Eta      CDATA "&#919;" -- greek capital letter eta, U+0397 -->
1099:         <!ENTITY Theta    CDATA "&#920;" -- greek capital letter theta,
1100:         U+0398 ISOgrk3 -->
1101:         <!ENTITY Iota     CDATA "&#921;" -- greek capital letter iota, U+0399 -->
1102:         <!ENTITY Kappa    CDATA "&#922;" -- greek capital letter kappa, U+039A -->
1103:         <!ENTITY Lambda   CDATA "&#923;" -- greek capital letter lambda,
1104:         U+039B ISOgrk3 -->
1105:         <!ENTITY Mu       CDATA "&#924;" -- greek capital letter mu, U+039C -->
1106:         <!ENTITY Nu       CDATA "&#925;" -- greek capital letter nu, U+039D -->
1107:         <!ENTITY Xi       CDATA "&#926;" -- greek capital letter xi, U+039E ISOgrk3 -->
1108:         <!ENTITY Omicron  CDATA "&#927;" -- greek capital letter omicron, U+039F -->
1109:         <!ENTITY Pi       CDATA "&#928;" -- greek capital letter pi, U+03A0 ISOgrk3 -->
1110:         <!ENTITY Rho      CDATA "&#929;" -- greek capital letter rho, U+03A1 -->
1111:         <!-- there is no Sigmaf, and no U+03A2 character either -->
1112:         <!ENTITY Sigma    CDATA "&#931;" -- greek capital letter sigma,
1113:         U+03A3 ISOgrk3 -->
1114:         <!ENTITY Tau      CDATA "&#932;" -- greek capital letter tau, U+03A4 -->
1115:         <!ENTITY Upsilon  CDATA "&#933;" -- greek capital letter upsilon,
1116:         U+03A5 ISOgrk3 -->
1117:         <!ENTITY Phi      CDATA "&#934;" -- greek capital letter phi,
1118:         U+03A6 ISOgrk3 -->
1119:         <!ENTITY Chi      CDATA "&#935;" -- greek capital letter chi, U+03A7 -->
1120:         <!ENTITY Psi      CDATA "&#936;" -- greek capital letter psi,
1121:         U+03A8 ISOgrk3 -->
1122:         <!ENTITY Omega    CDATA "&#937;" -- greek capital letter omega,
1123:         U+03A9 ISOgrk3 -->
1124:
1125:         <!ENTITY alpha    CDATA "&#945;" -- greek small letter alpha,
1126:         U+03B1 ISOgrk3 -->
1127:         <!ENTITY beta     CDATA "&#946;" -- greek small letter beta, U+03B2 ISOgrk3 -->
1128:         <!ENTITY gamma    CDATA "&#947;" -- greek small letter gamma,
1129:         U+03B3 ISOgrk3 -->
1130:         <!ENTITY delta    CDATA "&#948;" -- greek small letter delta,
1131:         U+03B4 ISOgrk3 -->
1132:         <!ENTITY epsilon  CDATA "&#949;" -- greek small letter epsilon,
1133:         U+03B5 ISOgrk3 -->
1134:         <!ENTITY zeta     CDATA "&#950;" -- greek small letter zeta, U+03B6 ISOgrk3 -->
1135:         <!ENTITY eta      CDATA "&#951;" -- greek small letter eta, U+03B7 ISOgrk3 -->
1136:         <!ENTITY theta    CDATA "&#952;" -- greek small letter theta,
1137:         U+03B8 ISOgrk3 -->
1138:         <!ENTITY iota     CDATA "&#953;" -- greek small letter iota, U+03B9 ISOgrk3 -->
1139:         <!ENTITY kappa    CDATA "&#954;" -- greek small letter kappa,
1140:         U+03BA ISOgrk3 -->
1141:         <!ENTITY lambda   CDATA "&#955;" -- greek small letter lambda,
1142:         U+03BB ISOgrk3 -->
1143:         <!ENTITY mu       CDATA "&#956;" -- greek small letter mu, U+03BC ISOgrk3 -->
1144:         <!ENTITY nu       CDATA "&#957;" -- greek small letter nu, U+03BD ISOgrk3 -->
1145:         <!ENTITY xi       CDATA "&#958;" -- greek small letter xi, U+03BE ISOgrk3 -->
1146:         <!ENTITY omicron  CDATA "&#959;" -- greek small letter omicron, U+03BF NEW -->
1147:         <!ENTITY pi       CDATA "&#960;" -- greek small letter pi, U+03C0 ISOgrk3 -->
1148:         <!ENTITY rho      CDATA "&#961;" -- greek small letter rho, U+03C1 ISOgrk3 -->
1149:         <!ENTITY sigmaf   CDATA "&#962;" -- greek small letter final sigma,
1150:         U+03C2 ISOgrk3 -->
1151:         <!ENTITY sigma    CDATA "&#963;" -- greek small letter sigma,
1152:         U+03C3 ISOgrk3 -->
1153:         <!ENTITY tau      CDATA "&#964;" -- greek small letter tau, U+03C4 ISOgrk3 -->
1154:         <!ENTITY upsilon  CDATA "&#965;" -- greek small letter upsilon,
1155:         U+03C5 ISOgrk3 -->
1156:         <!ENTITY phi      CDATA "&#966;" -- greek small letter phi, U+03C6 ISOgrk3 -->
1157:         <!ENTITY chi      CDATA "&#967;" -- greek small letter chi, U+03C7 ISOgrk3 -->
1158:         <!ENTITY psi      CDATA "&#968;" -- greek small letter psi, U+03C8 ISOgrk3 -->
1159:         <!ENTITY omega    CDATA "&#969;" -- greek small letter omega,
1160:         U+03C9 ISOgrk3 -->
1161:         <!ENTITY thetasym CDATA "&#977;" -- greek small letter theta symbol,
1162:         U+03D1 NEW -->
1163:         <!ENTITY upsih    CDATA "&#978;" -- greek upsilon with hook symbol,
1164:         U+03D2 NEW -->
1165:         <!ENTITY piv      CDATA "&#982;" -- greek pi symbol, U+03D6 ISOgrk3 -->
1166:
1167:         <!-- General Punctuation -->
1168:         <!ENTITY bull     CDATA "&#8226;" -- bullet = black small circle,
1169:         U+2022 ISOpub  -->
1170:         <!-- bullet is NOT the same as bullet operator, U+2219 -->
1171:         <!ENTITY hellip   CDATA "&#8230;" -- horizontal ellipsis = three dot leader,
1172:         U+2026 ISOpub  -->
1173:         <!ENTITY prime    CDATA "&#8242;" -- prime = minutes = feet, U+2032 ISOtech -->
1174:         <!ENTITY Prime    CDATA "&#8243;" -- double prime = seconds = inches,
1175:         U+2033 ISOtech -->
1176:         <!ENTITY oline    CDATA "&#8254;" -- overline = spacing overscore,
1177:         U+203E NEW -->
1178:         <!ENTITY frasl    CDATA "&#8260;" -- fraction slash, U+2044 NEW -->
1179:
1180:         <!-- Letterlike Symbols -->
1181:         <!ENTITY weierp   CDATA "&#8472;" -- script capital P = power set
1182:         = Weierstrass p, U+2118 ISOamso -->
1183:         <!ENTITY image    CDATA "&#8465;" -- blackletter capital I = imaginary part,
1184:         U+2111 ISOamso -->
1185:         <!ENTITY real     CDATA "&#8476;" -- blackletter capital R = real part symbol,
1186:         U+211C ISOamso -->
1187:         <!ENTITY trade    CDATA "&#8482;" -- trade mark sign, U+2122 ISOnum -->
1188:         <!ENTITY alefsym  CDATA "&#8501;" -- alef symbol = first transfinite cardinal,
1189:         U+2135 NEW -->
1190:         <!-- alef symbol is NOT the same as hebrew letter alef,
1191:         U+05D0 although the same glyph could be used to depict both characters -->
1192:
1193:         <!-- Arrows -->
1194:         <!ENTITY larr     CDATA "&#8592;" -- leftwards arrow, U+2190 ISOnum -->
1195:         <!ENTITY uarr     CDATA "&#8593;" -- upwards arrow, U+2191 ISOnum-->
1196:         <!ENTITY rarr     CDATA "&#8594;" -- rightwards arrow, U+2192 ISOnum -->
1197:         <!ENTITY darr     CDATA "&#8595;" -- downwards arrow, U+2193 ISOnum -->
1198:         <!ENTITY harr     CDATA "&#8596;" -- left right arrow, U+2194 ISOamsa -->
1199:         <!ENTITY crarr    CDATA "&#8629;" -- downwards arrow with corner leftwards
1200:         = carriage return, U+21B5 NEW -->
1201:         <!ENTITY lArr     CDATA "&#8656;" -- leftwards double arrow, U+21D0 ISOtech -->
1202:         <!-- ISO 10646 does not say that lArr is the same as the 'is implied by' arrow
1203:         but also does not have any other character for that function. So ? lArr can
1204:         be used for 'is implied by' as ISOtech suggests -->
1205:         <!ENTITY uArr     CDATA "&#8657;" -- upwards double arrow, U+21D1 ISOamsa -->
1206:         <!ENTITY rArr     CDATA "&#8658;" -- rightwards double arrow,
1207:         U+21D2 ISOtech -->
1208:         <!-- ISO 10646 does not say this is the 'implies' character but does not have
1209:         another character with this function so ?
1210:         rArr can be used for 'implies' as ISOtech suggests -->
1211:         <!ENTITY dArr     CDATA "&#8659;" -- downwards double arrow, U+21D3 ISOamsa -->
1212:         <!ENTITY hArr     CDATA "&#8660;" -- left right double arrow,
1213:         U+21D4 ISOamsa -->
1214:
1215:         <!-- Mathematical Operators -->
1216:         <!ENTITY forall   CDATA "&#8704;" -- for all, U+2200 ISOtech -->
1217:         <!ENTITY part     CDATA "&#8706;" -- partial differential, U+2202 ISOtech  -->
1218:         <!ENTITY exist    CDATA "&#8707;" -- there exists, U+2203 ISOtech -->
1219:         <!ENTITY empty    CDATA "&#8709;" -- empty set = null set = diameter,
1220:         U+2205 ISOamso -->
1221:         <!ENTITY nabla    CDATA "&#8711;" -- nabla = backward difference,
1222:         U+2207 ISOtech -->
1223:         <!ENTITY isin     CDATA "&#8712;" -- element of, U+2208 ISOtech -->
1224:         <!ENTITY notin    CDATA "&#8713;" -- not an element of, U+2209 ISOtech -->
1225:         <!ENTITY ni       CDATA "&#8715;" -- contains as member, U+220B ISOtech -->
1226:         <!-- should there be a more memorable name than 'ni'? -->
1227:         <!ENTITY prod     CDATA "&#8719;" -- n-ary product = product sign,
1228:         U+220F ISOamsb -->
1229:         <!-- prod is NOT the same character as U+03A0 'greek capital letter pi' though
1230:         the same glyph might be used for both -->
1231:         <!ENTITY sum      CDATA "&#8721;" -- n-ary sumation, U+2211 ISOamsb -->
1232:         <!-- sum is NOT the same character as U+03A3 'greek capital letter sigma'
1233:         though the same glyph might be used for both -->
1234:         <!ENTITY minus    CDATA "&#8722;" -- minus sign, U+2212 ISOtech -->
1235:         <!ENTITY lowast   CDATA "&#8727;" -- asterisk operator, U+2217 ISOtech -->
1236:         <!ENTITY radic    CDATA "&#8730;" -- square root = radical sign,
1237:         U+221A ISOtech -->
1238:         <!ENTITY prop     CDATA "&#8733;" -- proportional to, U+221D ISOtech -->
1239:         <!ENTITY infin    CDATA "&#8734;" -- infinity, U+221E ISOtech -->
1240:         <!ENTITY ang      CDATA "&#8736;" -- angle, U+2220 ISOamso -->
1241:         <!ENTITY and      CDATA "&#8743;" -- logical and = wedge, U+2227 ISOtech -->
1242:         <!ENTITY or       CDATA "&#8744;" -- logical or = vee, U+2228 ISOtech -->
1243:         <!ENTITY cap      CDATA "&#8745;" -- intersection = cap, U+2229 ISOtech -->
1244:         <!ENTITY cup      CDATA "&#8746;" -- union = cup, U+222A ISOtech -->
1245:         <!ENTITY int      CDATA "&#8747;" -- integral, U+222B ISOtech -->
1246:         <!ENTITY there4   CDATA "&#8756;" -- therefore, U+2234 ISOtech -->
1247:         <!ENTITY sim      CDATA "&#8764;" -- tilde operator = varies with = similar to,
1248:         U+223C ISOtech -->
1249:         <!-- tilde operator is NOT the same character as the tilde, U+007E,
1250:         although the same glyph might be used to represent both  -->
1251:         <!ENTITY cong     CDATA "&#8773;" -- approximately equal to, U+2245 ISOtech -->
1252:         <!ENTITY asymp    CDATA "&#8776;" -- almost equal to = asymptotic to,
1253:         U+2248 ISOamsr -->
1254:         <!ENTITY ne       CDATA "&#8800;" -- not equal to, U+2260 ISOtech -->
1255:         <!ENTITY equiv    CDATA "&#8801;" -- identical to, U+2261 ISOtech -->
1256:         <!ENTITY le       CDATA "&#8804;" -- less-than or equal to, U+2264 ISOtech -->
1257:         <!ENTITY ge       CDATA "&#8805;" -- greater-than or equal to,
1258:         U+2265 ISOtech -->
1259:         <!ENTITY sub      CDATA "&#8834;" -- subset of, U+2282 ISOtech -->
1260:         <!ENTITY sup      CDATA "&#8835;" -- superset of, U+2283 ISOtech -->
1261:         <!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
1262:         font encoding and is not included. Should it be, for symmetry?
1263:         It is in ISOamsn  -->
1264:         <!ENTITY nsub     CDATA "&#8836;" -- not a subset of, U+2284 ISOamsn -->
1265:         <!ENTITY sube     CDATA "&#8838;" -- subset of or equal to, U+2286 ISOtech -->
1266:         <!ENTITY supe     CDATA "&#8839;" -- superset of or equal to,
1267:         U+2287 ISOtech -->
1268:         <!ENTITY oplus    CDATA "&#8853;" -- circled plus = direct sum,
1269:         U+2295 ISOamsb -->
1270:         <!ENTITY otimes   CDATA "&#8855;" -- circled times = vector product,
1271:         U+2297 ISOamsb -->
1272:         <!ENTITY perp     CDATA "&#8869;" -- up tack = orthogonal to = perpendicular,
1273:         U+22A5 ISOtech -->
1274:         <!ENTITY sdot     CDATA "&#8901;" -- dot operator, U+22C5 ISOamsb -->
1275:         <!-- dot operator is NOT the same character as U+00B7 middle dot -->
1276:
1277:         <!-- Miscellaneous Technical -->
1278:         <!ENTITY lceil    CDATA "&#8968;" -- left ceiling = apl upstile,
1279:         U+2308 ISOamsc  -->
1280:         <!ENTITY rceil    CDATA "&#8969;" -- right ceiling, U+2309 ISOamsc  -->
1281:         <!ENTITY lfloor   CDATA "&#8970;" -- left floor = apl downstile,
1282:         U+230A ISOamsc  -->
1283:         <!ENTITY rfloor   CDATA "&#8971;" -- right floor, U+230B ISOamsc  -->
1284:         <!ENTITY lang     CDATA "&#9001;" -- left-pointing angle bracket = bra,
1285:         U+2329 ISOtech -->
1286:         <!-- lang is NOT the same character as U+003C 'less than'
1287:         or U+2039 'single left-pointing angle quotation mark' -->
1288:         <!ENTITY rang     CDATA "&#9002;" -- right-pointing angle bracket = ket,
1289:         U+232A ISOtech -->
1290:         <!-- rang is NOT the same character as U+003E 'greater than'
1291:         or U+203A 'single right-pointing angle quotation mark' -->
1292:
1293:         <!-- Geometric Shapes -->
1294:         <!ENTITY loz      CDATA "&#9674;" -- lozenge, U+25CA ISOpub -->
1295:
1296:         <!-- Miscellaneous Symbols -->
1297:         <!ENTITY spades   CDATA "&#9824;" -- black spade suit, U+2660 ISOpub -->
1298:         <!-- black here seems to mean filled as opposed to hollow -->
1299:         <!ENTITY clubs    CDATA "&#9827;" -- black club suit = shamrock,
1300:         U+2663 ISOpub -->
1301:         <!ENTITY hearts   CDATA "&#9829;" -- black heart suit = valentine,
1302:         U+2665 ISOpub -->
1303:         <!ENTITY diams    CDATA "&#9830;" -- black diamond suit, U+2666 ISOpub -->
1304:
1305:         24.4 Character entity references for markup-significant and internationalization characters
1306:
1307:         The character entity references in this section are for escaping markup-significant characters (these are the same as those in HTML 2.0 and 3.2), for denoting spaces and dashes. Other characters in this section apply to internationalization issues such as the disambiguation of bidirectional text (see the section on bidirectional text for details).
1308:
1309:         Entities have also been added for the remaining characters occurring in CP-1252 which do not occur in the HTMLlat1 or HTMLsymbol entity sets. These all occur in the 128 to 159 range within the CP-1252 charset. These entities permit the characters to be denoted in a platform-independent manner.
1310:
1311:         To support these entities, user agents may support full [ISO10646] or use other means. Display of glyphs for these characters may be obtained by being able to display the relevant [ISO10646] characters or by other means, such as internally mapping the listed entities, numeric character references, and characters to the appropriate position in some font that contains the requisite glyphs.
1312:         24.4.1 The list of characters
1313:
1314:         <!-- Special characters for HTML -->
1315:
1316:         <!-- Character entity set. Typical invocation:
1317:         <!ENTITY % HTMLspecial PUBLIC
1318:         "-//W3C//ENTITIES Special//EN//HTML">
1319:         %HTMLspecial; -->
1320:
1321:         <!-- Portions (c) International Organization for Standardization 1986:
1322:         Permission to copy in any form is granted for use with
1323:         conforming SGML systems and applications as defined in
1324:         ISO 8879, provided this notice is included in all copies.
1325:         -->
1326:
1327:         <!-- Relevant ISO entity set is given unless names are newly introduced.
1328:         New names (i.e., not in ISO 8879 list) do not clash with any
1329:         existing ISO 8879 entity names. ISO 10646 character numbers
1330:         are given for each character, in hex. CDATA values are decimal
1331:         conversions of the ISO 10646 values and refer to the document
1332:         character set. Names are ISO 10646 names.
1333:
1334:         -->
1335:
1336:         <!-- C0 Controls and Basic Latin -->
1337:         <!ENTITY quot    CDATA "&#34;"   -- quotation mark = APL quote,
1338:         U+0022 ISOnum -->
1339:         <!ENTITY amp     CDATA "&#38;"   -- ampersand, U+0026 ISOnum -->
1340:         <!ENTITY lt      CDATA "&#60;"   -- less-than sign, U+003C ISOnum -->
1341:         <!ENTITY gt      CDATA "&#62;"   -- greater-than sign, U+003E ISOnum -->
1342:
1343:         <!-- Latin Extended-A -->
1344:         <!ENTITY OElig   CDATA "&#338;"  -- latin capital ligature OE,
1345:         U+0152 ISOlat2 -->
1346:         <!ENTITY oelig   CDATA "&#339;"  -- latin small ligature oe, U+0153 ISOlat2 -->
1347:         <!-- ligature is a misnomer, this is a separate character in some languages -->
1348:         <!ENTITY Scaron  CDATA "&#352;"  -- latin capital letter S with caron,
1349:         U+0160 ISOlat2 -->
1350:         <!ENTITY scaron  CDATA "&#353;"  -- latin small letter s with caron,
1351:         U+0161 ISOlat2 -->
1352:         <!ENTITY Yuml    CDATA "&#376;"  -- latin capital letter Y with diaeresis,
1353:         U+0178 ISOlat2 -->
1354:
1355:         <!-- Spacing Modifier Letters -->
1356:         <!ENTITY circ    CDATA "&#710;"  -- modifier letter circumflex accent,
1357:         U+02C6 ISOpub -->
1358:         <!ENTITY tilde   CDATA "&#732;"  -- small tilde, U+02DC ISOdia -->
1359:
1360:         <!-- General Punctuation -->
1361:         <!ENTITY ensp    CDATA "&#8194;" -- en space, U+2002 ISOpub -->
1362:         <!ENTITY emsp    CDATA "&#8195;" -- em space, U+2003 ISOpub -->
1363:         <!ENTITY thinsp  CDATA "&#8201;" -- thin space, U+2009 ISOpub -->
1364:         <!ENTITY zwnj    CDATA "&#8204;" -- zero width non-joiner,
1365:         U+200C NEW RFC 2070 -->
1366:         <!ENTITY zwj     CDATA "&#8205;" -- zero width joiner, U+200D NEW RFC 2070 -->
1367:         <!ENTITY lrm     CDATA "&#8206;" -- left-to-right mark, U+200E NEW RFC 2070 -->
1368:         <!ENTITY rlm     CDATA "&#8207;" -- right-to-left mark, U+200F NEW RFC 2070 -->
1369:         <!ENTITY ndash   CDATA "&#8211;" -- en dash, U+2013 ISOpub -->
1370:         <!ENTITY mdash   CDATA "&#8212;" -- em dash, U+2014 ISOpub -->
1371:         <!ENTITY lsquo   CDATA "&#8216;" -- left single quotation mark,
1372:         U+2018 ISOnum -->
1373:         <!ENTITY rsquo   CDATA "&#8217;" -- right single quotation mark,
1374:         U+2019 ISOnum -->
1375:         <!ENTITY sbquo   CDATA "&#8218;" -- single low-9 quotation mark, U+201A NEW -->
1376:         <!ENTITY ldquo   CDATA "&#8220;" -- left double quotation mark,
1377:         U+201C ISOnum -->
1378:         <!ENTITY rdquo   CDATA "&#8221;" -- right double quotation mark,
1379:         U+201D ISOnum -->
1380:         <!ENTITY bdquo   CDATA "&#8222;" -- double low-9 quotation mark, U+201E NEW -->
1381:         <!ENTITY dagger  CDATA "&#8224;" -- dagger, U+2020 ISOpub -->
1382:         <!ENTITY Dagger  CDATA "&#8225;" -- double dagger, U+2021 ISOpub -->
1383:         <!ENTITY permil  CDATA "&#8240;" -- per mille sign, U+2030 ISOtech -->
1384:         <!ENTITY lsaquo  CDATA "&#8249;" -- single left-pointing angle quotation mark,
1385:         U+2039 ISO proposed -->
1386:         <!-- lsaquo is proposed but not yet ISO standardized -->
1387:         <!ENTITY rsaquo  CDATA "&#8250;" -- single right-pointing angle quotation mark,
1388:         U+203A ISO proposed -->
1389:         <!-- rsaquo is proposed but not yet ISO standardized -->
1390:         <!ENTITY euro   CDATA "&#8364;"  -- euro sign, U+20AC NEW -->
1391:         """
1392:
1393:         codes={}
1394:         for line in text.split('\n'):
1395:         parts = line.split()
1396:         if len(parts)<3 or parts[0]!='<!ENTITY' or parts[2]!='CDATA': continue
1397:         codes[parts[1]] = parts[3].strip('&#";')
1398:
1399:         print 'entityName={', ','.join([ '"'+key+'"' for key in codes]), '};'
1400:         print 'entityVal={', ','.join([ str(codes[key]) for key in codes]), '};'
1401:
1402:
1403:         ********************** end htmlentity.py ********************/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.